如何知道启动哪个包?

时间:2012-01-16 07:28:23

标签: android

我从市场上下载了“应用程序保护”应用程序。 它允许我保护用密码打开任何应用程序。

即。我用应用程序保护保护了'ConnectionLost'应用程序。

现在我打开'ConnectionLost'应用程序。我发现下面登录Logcat。

第1行开始:来自pid 5746的Intent {act = android.intent.action.MAIN cat = [android.intent.category.LAUNCHER] flg = 0x10200000 cmp = com.android.connectionlost / .ConnectionLost}

第2行从pid 5494开始:意图{flg = 0x10000000 cmp = com.ruimaninfo.approtect / .ui.ScreenLocker}

这意味着首先启动我的应用程序,然后在“应用程序保护”之后启动它自己的活动。

所以我的问题是

'应用程序保护(市场下层)'如何知道推出了哪个软件包? 作为程序员,我们怎么知道同样的事情呢?

谢谢。

1 个答案:

答案 0 :(得分:0)

您可以找到活动管理器启动的软件包

ActivityManager am = (ActivityManager) getSystemService(Activity.ACTIVITY_SERVICE);
String packageName = am.getRunningTasks(1).get(0).topActivity.getPackageName();
String ClassName = am.getRunningTasks(1).get(0).topActivity.getClassName();

You can make one background service which has a timer task of 100 seconds 
and put this code in timertask which prints log at every 100 seconds that which package is launching
相关问题