1

Is it possible to check if the Android application goes to foreground? Maybe anything callback function? Any idea or suggestions is appreciated.

Spring Breaker
  • 8,115
  • 3
  • 34
  • 59
malcoauri
  • 11,046
  • 27
  • 79
  • 125

3 Answers3

1

You can write code for callback activity in onRestart() Method.

shweta_jain
  • 463
  • 1
  • 5
  • 19
1
ActivityManager.getRunningTasks(1).get(0).yourActivity.getPackageName()

This method can get the foreground app package name.

you can use thread listen change.

Ando Masahashi
  • 3,041
  • 2
  • 23
  • 41
0

As per android life cycle onResume and onStart will be called once your activity comes to foreground. For more details Android life cycle

Daud Arfin
  • 2,469
  • 1
  • 17
  • 35