Package Play

来源:互联网 发布:python 设计模式的书 编辑:程序博客网 时间:2024/04/28 07:32

Package Play shows the user all installed packages on the mobile device. 能看到装了那些应用

 This helps the user in the following ways:

Easy way to start exported Activities 能直接启动activity

Shows defined and used permissions 查看权限

Shows activities, services, receivers, providers and instrumentation, their export and permission status  查看组件导出与否、权限等

Switches to Manifest Explorer or the Setting’sapplications view of the application.

               Map<String, PackageInfo> packages = new HashMap<String,PackageInfo>();

               PackageManager pm =getPackageManager();

               List<PackageInfo> l =pm.getInstalledPackages(GET_MINIMAL);

               mPkgs = (ListView)findViewById(R.id.package_list);

 

               for (PackageInfo pi : l)

                       packages.put(pi.packageName,pi);

 

public voidonItemClick(AdapterView<?> arg0, View v, int pos,

                                      longrowId) {

                               Intent i = newIntent();

                               ListView lv =(ListView) arg0;

                               i.setComponent(newComponentName(

                                              "com.isecpartners.android.packageplay",

                                              "com.isecpartners.android.packageplay.ViewPackage"));

                               ArrayList<String>l = new ArrayList<String>();

                               String name =(String) lv.getItemAtPosition(pos);

                               if (null != name&& name.equals("All")) {

                                      l =(ArrayList<String>) mPackageNames.clone();

                                      // removethe "All" dummy entry from the list

                                      l.remove(0);

                               } else

                                      l.add(name);

 

                               i.putExtra("pkgs",l);

 

                               startActivity(i);

                       }

         *Looks at the spinner for the currently selected Activity, then starts it.

         */

        public void startCurrentlySelected() {

               Intent i = newIntent(Intent.ACTION_MAIN);

               i.setComponent(newComponentName(mPkgName, mActivities

                               .getSelectedItem().toString()));

               startActivity(i);

        }

 

               mSystemViewButton.setOnClickListener(newOnClickListener() {

                       public void onClick(Viewv) {

                               Intent i = newIntent(Intent.ACTION_VIEW);

                               i.setClassName("com.android.settings",

                                              "com.android.settings.InstalledAppDetails");

                               i.putExtra("com.android.settings.ApplicationPkgName",mPkgName);

                               startActivity(i);

                       }

               });