Reputation: 12189
Is it possible to check if the Android application goes to foreground? Maybe anything callback function? Any idea or suggestions is appreciated.
Upvotes: 1
Views: 133
Reputation: 11
ActivityManager.getRunningTasks(1).get(0).yourActivity.getPackageName()
This method can get the foreground app package name.
you can use thread listen change.
Upvotes: 1
Reputation: 2499
As per android life cycle onResume
and onStart
will be called once your activity comes to foreground. For more details Android life cycle
Upvotes: 0
Reputation: 453
You can write code for callback activity in onRestart()
Method.
Upvotes: 1