I am trying to develop an android app. So I would like to know how to make the app keep running when I press the back button or home button or lock the screen(just like a music player app).
Currently when I press the back button or home button or lock the screen , the app pauses the activity and resumes when I open the app again. I want the app to keep running in the background until I stop it manually from the app(just like a music player app).
I have an app that will display the logo first, then it will go to the home activity of the app. Just like some other apps, if the app(my app) is not completely closed, even the user re-open the app(my app), the logo should not be displayed again. I mean if the user presses home button of the phone or switches to other apps, the phone will stop the app(my app) and switch back to its home or open other apps, the app(my app) is not closed. So when the user clicks the app's(my app) icon to open the stopped app, the logo should not be displayed but the home activity of the app.
I guess this should be done by using two activities. Then after 4s, it will direct the user from the logo to the home activity of the app. However, if I press home button of the phone or switch to other apps then go back to my app, the logo will be shown again but not the home activity of the app. So how to deal with this problem, or the logo activity can be done in different way?
I have an android application, when user presses home or back key, android application will be minimized.
I want to open this application after pressing back or home key. (like long press in home key and selecting minimized app - I want application do this automatically).
What should I do? Please help me.
I guess what you need is Kiosk Mode.
it can disable Android features that can be used to leave your app. The following features are affected:
The back button
The home button
The recent apps button
The power button
The volume buttons
I'm trying to create an Android app that has a dialer tab at the top of the screen. When user presses the tab, it should display the phone dialer.
I have a requirement that that the back button and HOME key presses should be dropped (user shouldn't be allowed to exit the app).
Which is the best way to display the dialer? Is it essential to create my own dialer for this app?
Or can I somehow run the stock OEM dialer within my activity? If this is possible, I believe the user can just press the back key or HOME button and exit out of my app.
Please suggest an approach.
In iphone when we exit app and start app again by clicking launcher icon the app start from screen which was open last time before exiting app.
We can achieve same in android when we exit app using center or home button on android phone. In android app if app is exited by pressing home button and started again by clicking on launcher icon the app start from activity which was open last time before exiting app.
Is that functionality similar to iphone in terms of keeping app in memory longer? Will that work in android all time because I think android system will remove app from memory after sometime or will it remain in memory longer? Can I depend on this functionality in android and expect it to work all time.
I have a project in android which client has asked me to have iphone like functionality if we exit app and start app again it should open from screen which was opened last time before exiting. Now this is possible in android only if we use centre button. And also if user has exited using centre button and started it again, app should check for user current location and do some other operations. If app is launched and user navigate to any activity is there any way to check if app was exited using back button or centre button so that I can run code if app is exited using center button.
Thanks
We can achieve same in android when we exit app using center or home button on android phone.
The HOME button does not "exit app".
The HOME button brings the home screen to the foreground, just as the CAMERA button (where available) brings the camera application to the foreground, the CALL button (where available) brings the dialer to the foreground, tapping on a Notification may bring something else to the foreground (e.g., SMS client) based on the Notification, etc.
In android app if app is exited by pressing home button and started again by clicking on launcher icon the app start from activity which was open last time before exiting app.
No. If you tap on a launcher icon, and the app's process is still in memory, the existing app instance will be brought to the foreground, returning you to whatever activity you had been on. If you tap on a launcher icon, and the app's process had been terminated to free up RAM for other apps, you launch a fresh copy of the app and bring up whatever the ACTION_MAIN/CATEGORY_LAUNCHER activity was that the user tapped upon.
Will that work in android all time because I think android system will remove app from memory after sometime or will it remain in memory longer?
The length of time that a non-foreground app's process will be in memory is indeterminate and will be based on what is going on with the device, plus the device capabilities (e.g., how much RAM). I suggest you read more about the process lifecycle.
Now this is possible in android only if we use centre button.
It is not possible "if we use centre button" (what Android developers refer to as the HOME button). It may happen automatically, but if the app's process has been terminated, it will not happen automatically.
If app is launched and user navigate to any activity is there any way to check if app was exited using back button or centre button so that I can run code if app is exited using center button.
You should not care whether the "app was exited using back button or centre button".
You should care whether you have your data and how old that data is, refreshing it if it is stale.
Whether the user left your app via HOME, BACK, CAMERA, CALL, a Notification, the recent tasks list, an incoming phone call, by smashing their phone to bits with a rock and replacing it with an exact duplicate, or by any other means, should not matter to you.
To draw an analogy, think of a Web app. In a Web app, you care about whether you have a session cookie and whether that session is stale (e.g., to force a fresh login). Whether the page request came because the user clicked a link within the app, or clicked on a link from a third party site pointing to your app, or refreshed their page, or used a bookmark to get at another page in your app, or double-clicked on a desktop icon that brings up your app, or right-clicked on a link and opened a fresh tab, or anything else, should not matter to you.
Review the Android Activity Lifecycle at http://developer.android.com/reference/android/app/Activity.html. If you do nothing, you have no guarantee of your app starting at the same point it left off, however you have control here. You can, for example, overload the onPause() method to save your state to a file, and onResume() to restore it.