문제

I have a list of all non-system application installed in the device .I am displaying these application name onto the listview . All is fine by now but I want to launch the application on selection of the items of the listview.How can I do so. here is what I have done till now.

  List<PackageInfo> PackList=new ArrayList();
  PackList = getPackageManager().getInstalledPackages(0);
    ArrayList<String> array=new ArrayList<String>();
    for (int i=0; i < PackList.size(); i++)
    {
        PackageInfo PackInfo = PackList.get(i);
        if ( (PackInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 1)
        {
            String AppName =   PackInfo.applicationInfo.loadLabel(getPackageManager()).toString();
            System.out.println(AppName);
            array.add(AppName);

        }
    }


    l=getListView();
    ArrayAdapter<String> adapter= new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 ,array );
    l.setAdapter(adapter);
    l.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
            // TODO Auto-generated method stub

            String str=l.getItemAtPosition(arg2).toString();
            //intent intent=pm.getp

        }

    }); 
도움이 되었습니까?

해결책

Use Package name to start another app- here is simple code-

Intent appStartIntent = getPackageManager().getLaunchIntentForPackage("Your.package.Name");
startActivity(appStartIntent);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top