getLaunchIntentForPackage 对于应用程序为 null

getLaunchIntentForPackage is null for apps

  1. 我正在警报网格视图中构建已安装的应用程序。我正在 selecting 一些最喜欢的应用程序,然后添加到另一个网格视图中,如果 我 select 来自新 gridview 应用程序的任何应用程序其获取 Intent 值 (getLaunchIntentForPackage) 为空。

    quick_links_alert.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                List<String> mArrayProducts = clad.getCheckedItems();
                final QuickLinksGridViewAdaptor selected_apps = new QuickLinksGridViewAdaptor(HomeActivity.this, mArrayProducts);
                gv_shortcut.setAdapter(selected_apps);
                Toast.makeText(getApplicationContext(),"Selected Items-->:"+mArrayProducts,Toast.LENGTH_LONG).show();
                PackageManager pm = HomeActivity.this.getPackageManager();
                Intent quick_intent = new Intent(Intent.ACTION_MAIN, null);
                final List<ResolveInfo> list = pm.queryIntentActivities(quick_intent, PackageManager.PERMISSION_GRANTED);
                gv_shortcut.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                        final String packageName = list.get(position).activityInfo.packageName;
                        Intent PackageManagerIntent = getPackageManager().getLaunchIntentForPackage(packageName);
                        if (PackageManagerIntent != null) {
                            startActivity(PackageManagerIntent);
                        }
                        else {
                            Toast.makeText(getApplicationContext(),"NULL",Toast.LENGTH_LONG).show();
                        }
                    }
                });
            }
    In my grid view 8 applications are available.If I click any application its PackageManagerIntent is getting null and 1 and 3 position application its always open google search engine and player application is opening.
    

我已经解决了问题:

String s = mArrayProducts.get(position).getPackageName();
Intent PackageManagerIntent = getPackageManager().getLaunchIntentForPackage(s); NULL
startActivity(PackageManagerIntent);