I have created an app which starts a service which is constantly looking to what the current activity is. It display the names of all the activities in my app properly, but any other apps are com.android.launcher2.Launcher. I was wondering if it was actually possible to see what the current actiivty is.
Asked
Active
Viewed 112 times
1 Answers
-1
public class Services extends Service{
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningAppProcessInfo> runningAppProcessInfo = am.getRunningAppProcesses();
for(;;)
{
for(RunningAppProcessInfo info : runningAppProcessInfo)
{
Log.d("APP", info.processName);
}
}
}
}

Akshay Paliwal
- 3,718
- 2
- 39
- 43