How to make the choice of an installed application store?

I have Google Play, Amazon, Samsung, etc. on the phone. I want to give the user a choice of which market to go to. If I use the market, it will go to the Google Play app by default. I want a list of them to appear. Do I need to manually check which ones are installed and have a custom selection screen? Or I can configure the current code:

startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("market://details?id=" + appName))); 
+4
source share
1 answer

I have an example:

// 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;
}

Codes are used to screen applications that can open a file using mimetype. Perhaps this is useful for you.

I'm sorry for my bad english

0
source

All Articles