我知道如何把任何应用程序放在前台,但我现在将任何应用程序放在后台。即,我想要的每个应用程序。 我在谷歌搜索了很多,但我还没有找到解决方案。 你有什么想法如何? 我试图显示主页,但它不工作:把任何应用程序在Android中的背景
Intent i = new Intent(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_HOME);
startActivity(i);
非常感谢你提前。
这里是我的所有代码(它是一个测试代码),我启动地图应用程序,我只是后想,在研究背景puting它:
List<ResolveInfo> pkgAppsList = retreivedAllApplicationsInstalled();
ActivityManager actMngr = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
List<RunningAppProcessInfo> runningAppProcesses = actMngr.getRunningAppProcesses();
for (RunningAppProcessInfo pi : runningAppProcesses) {
String[] testPklist = pi.pkgList;
if(pi.importance == RunningAppProcessInfo.IMPORTANCE_BACKGROUND){
for(String tp : testPklist){
if(tp.equals("com.google.android.apps.maps")){
//launch map application
Intent i = new Intent(Intent.ACTION_MAIN);
PackageManager manager = getPackageManager();
i = manager.getLaunchIntentForPackage("com.google.android.apps.maps");
i.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(i);
}
}
}
}
//try to put back all applications on displaying home
Intent back = new Intent(Intent.ACTION_MAIN);
back.addCategory(Intent.CATEGORY_HOME);
startActivity(back);
AFAIK ,这应该能够提供主屏幕。当您执行上述代码时,LogCat会显示什么? – CommonsWare 2012-07-27 00:28:20
当我执行这部分代码时,Logcat不会说话 – user1106464 2012-07-27 00:45:46