No Activity found to handle Intent

后端 未结 6 1435
攒了一身酷
攒了一身酷 2020-12-01 17:35

i am attempting to launch an intent to open a link to the android market.

android manifest portion looks like this:



        
6条回答
  •  隐瞒了意图╮
    2020-12-01 18:12

    Better solution would be to try to open uri in Google Play app, but if there is no such app (no Activity to handle this intent) - you can just try to open uri in browser like in this example:

    public static void rateApp(Context context) {
        try {
            context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + context.getPackageName())));
        } catch (android.content.ActivityNotFoundException anfe) {
            viewInBrowser(context, "https://play.google.com/store/apps/details?id=" + context.getPackageName());
        }
    }
    
    public static void viewInBrowser(Context context, String url) {
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        if (null != intent.resolveActivity(context.getPackageManager())) {
            context.startActivity(intent);
        }
    }
    

提交回复
热议问题