What is the package name for “Task Manager” in Android to launch this activity?

我只是一个虾纸丫 提交于 2019-12-23 05:09:13

问题


I want to launch Task Manager using Intent from my application. What is the package name for the Task Manager? I.e.,

startActivity(new Intent("android.intent.action.<task_manager_package_name>"))

回答1:


Use this snippet to get package name of task manager

   apps=getPackageManager().getInstalledPackages(PackageManager.GET_META_DATA|PackageManager.GET_PERMISSIONS|PackageManager.GET_PROVIDERS); // gets all app details on phone

String packagename = new String(); 

  for(int index=0;index<apps.size();index++)
    {
        PackageInfo temp = apps.get(index);     //Iterate through the apps till you get task manager
        if(temp.applicationInfo.loadLabel(getPackageManager()).toString().equals("Task Manager")))
        {

          packagename = temp.packageName; //To get package name
          break;
        }

    } 

Then the string packagename will have the packagename of task manager




回答2:


You can use ActivityManager, read more about that. Check this link



来源:https://stackoverflow.com/questions/20563470/what-is-the-package-name-for-task-manager-in-android-to-launch-this-activity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!