Skip to content Skip to sidebar Skip to footer

How To Prevent Activity From Destroying In Android App?

I use next code to share some text using available clients: Intent share = new Intent(Intent.ACTION_SEND); share.putExtra(Intent.EXTRA_TEXT, 'Here's some text for Twitter.'

Solution 1:

Your app will be in the background, onResume and onPause will both be called, provided that the OS have enough memory to keep the new app and all the old apps.

  • If you have a long running process that you need while the user not looking at it, use a service.

  • If you need the user to return the app in the same state, you need to do the work in onResume and onPause to save the state information and initialize your UI again when the user comes back. If you are really worried that it can get killed (well, it shouldn't lose the bundle I think), you can store them in SharePreferences for your app.

  • If you want to know when the app returns from that specific share intent, use startActivityForResult

Post a Comment for "How To Prevent Activity From Destroying In Android App?"