【发布时间】:2017-05-04 05:37:53
【问题描述】:
-
我正在警报网格视图中构建已安装的应用程序。我正在选择 一些喜欢的应用程序,然后添加到另一个网格视图中,如果 我从新的 gridview 应用程序中选择任何应用程序,其获取 Intent 值 (getLaunchIntentForPackage) 为 null。
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.
【问题讨论】:
-
我得到选定的应用程序名称越来越完美。我无法理解选定的应用程序没有打开
标签: android gridview launcher package-managers