我有:
列出 procInfos = activityManager.getRunningAppProcesses(); 图标 = pk.getApplicationIcon(procInfos.get(i).processName);
当用户单击它时,我想在前台启动与图标相关的活动。我能怎么做?
我有:
列出 procInfos = activityManager.getRunningAppProcesses(); 图标 = pk.getApplicationIcon(procInfos.get(i).processName);
当用户单击它时,我想在前台启动与图标相关的活动。我能怎么做?
使用ImageButton将您的图标显示为按钮。然后,在 ImageButton onClickListener 的 onClick 方法中,调用:
PackageManager pm = this.getPackageManager();
try
{
Intent it = pm.getLaunchIntentForPackage(application.package.name);
if (null != it)
this.startActivity(it);
}
catch (ActivityNotFoundException e)
{//oops, no such application
}