-1

1: My activity is running

2: Another app is open automatically and other app activity shown in foreground.

3: In my activity is called onPause() and onStop(). Now my activity is not in foreground but continue working threads in the background.

In this situation, if the user clicks the back button, the unknown app closes and in my app onRestart() is called.

What I need is a piece of code that allows me to programmatically call onRestart() from my background thread like user close unknown app.

Does not work for me a solution that call onCreate() in my activity.

enter image description here

user3782779
  • 1,669
  • 3
  • 22
  • 36
  • duplicate answer is here: http://stackoverflow.com/questions/1111980/how-to-handle-screen-orientation-change-when-progress-dialog-and-background-thre – eyespyus Nov 19 '14 at 17:51

1 Answers1

0

Your activity should not have threads working in the background. And it shouldn't try to "force" onRestart while another activity is active (for example, if the user takes a phone call, they probably don't want your app popping up in the middle of the call).

What you probably need to do is use a Service to get the background threads to do their job "in the background" while your activity is not active.

You should take a look at this post about services:

http://www.vogella.com/tutorials/AndroidServices/article.html

Also if you launch your app while other apps are active, Google Play may consider it a violation policy to interfere with the operation of other apps.

Jim
  • 10,172
  • 1
  • 27
  • 36
  • My app is an app that needs to be in kiosk mode. Locks all buttons by standard methods, but in a very particular device traditional methods not work because the device injects virtual buttons and the user can go for example to task manager and close the app. The only way to do that is what I ask. So, this is posible to do somehow or is impossible? – user3782779 Nov 19 '14 at 18:02