I want to move from current page to login page in my app when clicking the Home Button (not recent button).
It is controlled by the option in iOS (application does not run in background to 'YES').
I don't know how to control it in Android.
I try this:
onDownKey (not working when clicking Home & Recent, but back button works well.)
onPause or onUserLeaveHint (I already controlled others in these methods, so I can't use it)
dispatchKeyEvent (also not working)
No, there is no direct equivalent functionality. ANd you can't detect the home and recents button, the system handles them directly without ever passing them to your app. Tell us why you want this behavior, and we may be able to help you. But this would be extremely unusual behavior for Android. In fact the exact opposite is what's usually the problem- making sure you relaunch correctly if you're killed and relaunched via recents.
Related
I want to know if there's some way to maintain an Android activity always on top regardless of any other apps present in the phone device that might put on top on it, except for home screen via home button, which cannot be helped.
I've checked that if a whatsapp popup displays over my activity, that activity starts showing a strange behavior.
Maybe this can be controlled by some events, but I think it's much easier to avoid anything that might put on top of app, so no strange behavior appears.
Is there any way to do that?
It depends on the level of control that you have over the device. If your app is going to be publicly available you cannot (and should not) do much to prevent other components from coming on top of the stack.
Apart from that, one thing you can do is check for UI changes through this: https://developer.android.com/reference/android/view/View.OnSystemUiVisibilityChangeListener or/and activity lifecycle events (like onPause) and prevent whatever this "strange behaviour" is.
The inverse way to deal with this is to prevent any app from having the "Draw Over Other Apps" permission, but as I said it depends on the environment of your deployment.
developer.chrome.com/apps/getstarted_arc#bestpractices
The ARC allows you to execute native android apps through the chrome browser by wrapping a chrome app around it.(As far as I can tell)
I am re-factoring an Android app to work well on Chrome. The first thing I need to do is to make the back arrow enabled at all times on the top left as shown below.
This is the program that allows Native android apps to run through chrome. I think the answer to my question lies somewhere in "Additional Metadata", or in the source code?
Add {"disableAutoBackButton": "true"} to the metadata. That will enable the back button within an activity. I've found that with my app that has multiple activities, though, it doesn't work to return to my main activity from my settings activity. It could be that I'm doing something wrong with the way I'm handling activities, I guess, but it works on all physical devices.
{"sleepOnBlur":false,"disableAutoBackButton":true}
please supply the above metadata before you download the zip or launch app from the arc welder
the first param prevents excessive pause/resume and also supposed to fix short black screen flash occurring occassionally in some of the apps.
the second params adds persistance back button on top left hence helping to avoid extra code required because of absence of back button in some screens(mostly the first screen)
Is it possible to disable home button temporarily for other apps on a rooted device?
I am making a program that controls other programs. I have full root access.
Is there a way I can disable the home button so that other apps can't use it if they
aren't allowed? Implementing a home screen doesn't work because I want to disable
the button for other programs as well.
I suppose maybe I could just restart the program
that pressed home to get back again but that is kind of an ugly solution.
I found this:
http://www.droidforums.net/forum/android-hacks-help/23552-disable-search-button.html
It works, but I would prefer not to save to a file all the time (flash wearing). Also it seems to only be working on bootup. Or is there a way to reload the configuration?
I found a workaround:
Make a home screen activity that intercept your HOME press and then just call finish() in onCreate(). This code can launch another "launcher" at will, or do nothing as you please.
I was studying some tutorials on Android programming and I realized that pressing the Home button on the emulator takes me tot he phones Desktop, but my sample that was running at the time only goes to the background and does not get destroyed. However, if I press the return button, the app is destroyed as well. So I am assuming there might be other apps running int he background as well, those which I am not aware of. Is there something in the android emulator resembling the task manager from windows, which shows what apps are currently running on the phone? I don't have a smartphone with me, but I remember seeing something like that on my friend's smartphone a few days ago. It wasn't an external app but was something built into the phone, I could access it by going to Settings or something.
Is there a task manager built into the android emulator, or is there any other way I can see such things through the SDK debugger?
Inside the settings, there is a list of currently running processes.
First , Leaving the activity does not mean the process ends, It is just not invisible . When the Os needs more memory ,it will be recovered.
If you want to have a backup process, you can start a back service.
http://developer.android.com/reference/android/app/Service.html
Here is how I end a process (only works on Android 4.0+).
Instead of pressing home, press recent and swipe away the process you want to end. Then press home (or back).
You can also use this to close those nasty apps that prevent you from closing them by not allowing back button to work on their main screens.
This is much quicker than having to go to settings, etc.
The application that I'm developing must look like a launcher. I opened this topic because of I couldn't find the correct answer in whole topics that I looked at in Stack Overflow.
I want the application to disable or control whole buttons to exit this application. I disabled home and back button on Android 2.3 but it doesn't work on Android 4.0 (except for back button).
To conclude, I couldn't and I want to disable only home button on Android 4.0
Can you give an advice except the other answers?
There is no way to intercept the home button on Android, unless you make your app the home screen. This is for security reasons, so that malicious apps cannot take over your device by overriding all the buttons that can exit. The home button is the one sure shot way to be able to leave any app.
In short, no it's not possible, and even if it were, it is a serious disruption in what a user expects out of an app's behavior. You will have to go with making your app into a launcher if you want to achieve this.