我知道如何把任何應用程序放在前臺,但我現在將任何應用程序放在後臺。即,我想要的每個應用程序。 我在谷歌搜索了很多,但我還沒有找到解決方案。 你有什麼想法如何? 我試圖顯示主頁,但它不工作:把任何應用程序在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