Question

Je sais comment mettre une application au premier plan mais je voudrais maintenant mettre une application à l'arrière-plan.C'est-à-dire que chaque application que je veux. J'ai beaucoup cherché sur Google mais je n'ai pas trouvé de solution. Avez-vous une idée de la façon dont? J'ai essayé d'afficher la maison mais cela ne fonctionne pas:

Intent i = new Intent(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_HOME);
startActivity(i);

Merci beaucoup à l'avance.

Voici mon tout code (c'est un code de test), je lance une application de carte et je veux juste après, le mettre en arrière-cadre:

    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);

Était-ce utile?

La solution

Autres conseils

Je pense que je comprends le problème dans mon code: Je gère une activité "carte", qui exécute et ensuite mon code ci-dessous (à mettre en arrière-plan) n'est jamais lancé .......

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top