我在手机上有Google Play,亚马逊,三星等商店。我想让用户选择去哪个市场。如果我使用市场,默认情况下会转到Google Play应用。我想要一个列表出现。我是否必须手动检查哪些已安装并具有自定义选择屏幕?或者我可以调整当前的代码:
startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("market://details?id=" + appName)));
答案 0 :(得分:0)
我有一个例子:
// get app which can open fill
public List<Map<String, Object>> getAppOpeners(Intent intent) {
if (intent == null) {
return null;
}
List<Map<String, Object>> appinfos = new ArrayList<Map<String, Object>>();
ResolveInfo app = null;
List<ResolveInfo> mApps = new ArrayList<ResolveInfo>();
PackageManager pm = mContext.getPackageManager();
mApps = pm.queryIntentActivities(intent,
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT);// get app which can open fill
Iterator<ResolveInfo> it = mApps.iterator();
while (it.hasNext()) {
Map<String, Object> item = new HashMap<String, Object>();
app = it.next();
if (true) {// mContext.getPackageManager().getLaunchIntentForPackage(app.activityInfo.packageName)
// != null
item.put("packname", app.activityInfo.packageName);// packname of app
item.put("appname", app.loadLabel(mContext.getPackageManager()));// name of app
item.put("icon", app.loadIcon(mContext.getPackageManager()));// icon of app
item.put("intent", intent);
appinfos.add(item);
}
}
//appinfos = StringSortUtil.sortString(appinfos, "appname");
return appinfos;
}
代码用于筛选可以通过mimetype打开文件的应用程序。它可能对你有用
我很抱歉我的英语不好