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,233
  • 3
  • 36
  • 60
malcoauri
  • 11,904
  • 28
  • 82
  • 137

3 Answers3

1

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

shweta_jain
  • 453
  • 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,112
  • 2
  • 24
  • 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,499
  • 1
  • 18
  • 37