how to get package name of application being displayed on screen in a foreground service, android? -
i want package name of application being displayed on screen @ time. using foreground service used method below, gives me mycurrent application's packagename if opens app e.g youtube,camer etc, , mobile's com.huawie.android.launcher if @ home screen.
activitymanager activitymanager = (activitymanager) getsystemservice(context.activity_service); activitymanager.runningtaskinfo foregroundtaskinfo = activitymanager.getrunningtasks(1).get(0); packag= foregroundtaskinfo.topactivity.getpackagename(); log.i("pack",packag);
well, below api-level 21 or loolipop, can whole package activity class, api-22 can't whole application package activity because of security reasons.
as know android not going secure phone, that's why activity name restricted.
Comments
Post a Comment