lundi 15 juin 2015

How to get the foregrund activity instance?

I try to get the foreground activity for a long time, and i didn't managed to get it until now.

I don't know if it even possible, but i am dont intersted in my app activity only.

There is no data transfer between my service and the activity which i want to get.

I saw lot of questions of this kind but i got nothing suitable for my needs.

I just need to get an instance, not a ComponentName, not decription of the current foreground activity.

I've tried through ActivityThread, ActivityManager, ActivityManagerService (even though i couldnt get his instance too), and so on.

Field activitiesField = activityThreadClass.getDeclaredField("mActivities");// won't help
activityManager.getrunningTask(rnd);// won't help either

If there is any refelection way, listener or something like that, but not a static field.





Aucun commentaire:

Enregistrer un commentaire