I'm making an Android app and I would like to know how to hide its icon and title from showing in the menu. Everything I've found so far on the internet is hiding
<category android:name="android.intent.category.LAUNCHER" />
in AndroidManifest.xml.
If I do that it doesn't start after installation! Another important note: I need my app to ALWAYS be running, even after restarting the phone.
but if i do that i can't start my app after installation!
Correct. Effectively, as of Android 3.1, you must have a launcher icon, at least at the outset.
i need my application to be ALWAYS turned on, even after restarting the phone (turning it off and on).
I have no idea what "ALWAYS turned on" means in terms of an application. I am going to assume you mean "ALWAYS running".
In that case, this is not possible. Users can and will stop your app by any number of means, such as task killers and the force-stop option in Settings. The Android OS will automatically stop your app if it is hiding in the background for too long. It is considered poor form to have some piece of your application (a service) running constantly -- very few applications need this.
Moreover, please bear in mind that the combination of "I need it always running" and "I do not want it to appear in the launcher" sounds very suspicious, almost as if you are trying to write something that the user might not want to have running.
Then you would need some way to start a service. Or figure out a meaningful way you can actually start up your application without user interaction, there are tons of options.
There are lots of Intent defines for receiving broadcasts through which you can start you activity for example
ACTION_BOOT_COMPLETED
ACTION_POWER_CONNECTED
for further detail check this link
Related
Im using Sumsung GT-S7710 android version 4.1.2 . When I force close my app from app list in my phone manually - separate service process becomes dead. I can see it in studio. And trully it doesnt work any more (I used to check it with shedulled launching of notification sound). But in many places over the net people say android:process=":remote" option will prevent my service from being killed, but it seems not working for Force Close case. Any suggestions appreciated. Thx in advance.
<service android:name=".ActService" android:process=":remote"/>
When I force close my app from app list in my phone manually
What you appear to mean is that you are going to the Settings app, to the Apps screen within there, finding your app, and tapping the "Force Stop" button.
separate service process becomes dead
Sure. All of your processes will be terminated if the user force-stops the app through Settings.
But in many places over the net people say android:process=":remote" option will prevent my service from being killed, but it seems not working for Force Close case.
Correct. It is not supposed to work for that case. Where a separate process may help is if the user swipes your app's task off of the overview screen (a.k.a., the recent-tasks screen).
After 3.1 , Android introduced a security feature, where the application's code can't be run unless the user opens the application. Check the link for more info http://commonsware.com/blog/2011/07/13/boot-completed-regression-confirmed.html
I would like to know if anyone has found any hack or work around for this problem, where i can listen to a system broadcasts like boot, connectivity changed and run a service without opening the installed application.
This is not what the posts said. You can still register broadcast listeners, or alarms. You just need the user to actually start your application once. And, if the user forcefully stops your application, they'll need to start it manually again.
Why would you want a way around this behavior? It seems to make a lot of sense.
I'm working on an Android application, and I want it to get started right after the phone boots up. I used BroadcastReceiver, and the intent filter boot up complete, and the permission, and I think it's working; I turn on the phone, it boots up, and then it shows the main menu, and after 30 seconds or so, my app starts. Is that the normal behaviour for it? I would like it to start right away, without even showing the main menu first. Is that possible? or is this the best i can get? I didn't find anything about this issue in google, and I'm relatively new to Android so I'm not sure if that's the normal behaviour or not. Hope you can help me, thanks.
It sounds like what you are looking for is a Service. It will run in the background and can be set to auto start. I'm not sure that it necessarily come up faster than your activity does, but I think it will. Check these documents: http://developer.android.com/guide/components/services.html
Is it possible to track on Android from where somebody has started an application (i.e. from the drawer, from recent apps menu, or from desktop shortcuts, etc.)?
Sorry, but this isn't possible.
Even if it was, consider how easily such functionality could be abused by malicious software. You can listen to intents directed at you, and those that are broadcast, but application launching should not be a broadcast event.
What you may be able to do is replace the launcher. If the user agrees to it.
You might also be able to hack a work-around by reading the logcat logs. For instance, give your application the android.permission.READ_LOGS permission and parse the logs to determine the application that launched it. This is just an idea, however... it sounds like something you wouldn't want to rely on.
If you built your own home screen it could give you some of that information.
But on a stock device with any available home screens no probably not.
I am not satisfied with any of the app locker programs for Android that I have found and would like to create my own, but I am having trouble figuring out how to implement the actual lock. How does one go about implementing an app locker for Android?
There are two issues:
Detecting an Intent, usually from the launcher calling startActivity() or from an ad launching the market app (I'm not talking about broadcast intents -- I need to handle explicit Activity Intents).
The permissions for the locker apps I have seen all have "read system log files" and/or "retrieve running applications" which suggests they might use polling to look for app launches. I think I could do this, but I would like to find a better solution if possible.
Preventing the locked app from processing the Intent. I would prefer not to allow the locked app to run at all until the passcode is entered since it is impossible to tell what it might do when it starts up.
When running my current app locker, logcat shows "ActivityManager: Starting activity" first with the Intent for the locked app, then again with the Intent for the app locker, with nothing in between (separated by 10-20ms). If I enter the correct passcode then I see "ActivityManager: moveTaskToBack".
I have experimented with a test app which demonstrates that, using my current app locker, none of the Activity callbacks are invoked if the app is locked and I do not enter the correct passcode. So it appears to be preventing the app from starting (but I don't know how).
I could use ActivityManager.killBackgroundProcesses() to stop an app, but I have no guarantee that the app hasn't already started running by the time it gets "killed".
I might be able to use PackageManager.setApplicationEnabledSetting() to prevent an app from being instantiated, but I don't think that will take care of apps that are already running (which shouldn't be allowed to process new Intents or come to the foreground). I might be able to use killBackgroundProcesses() to stop all running locked processes so they would have to be re-instantiated. But I don't like this approach because other apps could mess with the Enabled settings and defeat the lock.
Optimally, the system would send every Intent to my app for inspection and allow me to stop or let it pass through, but I'm pretty sure that's not possible (at least, not for explicit intents to start activities from a launcher).
Does anyone know how app locker apps are implemented, or have any bright ideas on how it could be done?
I would look into the lifecycle. Once the app in question begins to load, some activity from that package will be added to the forefront activity.
A scan of the changes in forefront activities might do the trick.
http://developer.android.com/reference/android/app/Activity.html#ProcessLifecycle