No Activity found to handle Intent action.VIEW when clicking email link

后端 未结 3 1351
情深已故
情深已故 2021-02-07 16:02

I got this new crash exception after the newest app update. It seems to not point anywhere. Would anyone be able to tell what the issue is? It looks like a possible email-forma

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-07 16:17

    By the way no email client can occur if no email account is set up on the device so technically this can occur on real devices as well. Here is the code for disabling the AutoLink if not available as suggested by novettam:

    protected boolean checkIntent(Intent intent)
    {
        PackageManager packageManager = getPackageManager();
        List apps = packageManager.queryIntentActivities(intent, 0);
        return apps.size() > 0 && !( apps.get(0).activityInfo.name.equals(activity.getClass().getName()) && apps.size() == 1) ;
    }
    
    
    protected Intent createDummyEmailIntent()
    {
        final Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
                "mailto", "abc@gmail.com", null));
        emailIntent.putExtra(Intent.EXTRA_SUBJECT, "EXTRA_SUBJECT");
        return emailIntent;
    }
    
    protected Intent createDummyWebIntent()
    {
        final Intent webIntent = new Intent(Intent.ACTION_VIEW).setData(Uri.parse("http://www.google.co.uk"));
        return webIntent;
    }
    
    protected Intent createDummyPhoneIntent(){
        String uri = "tel:" + "0131 666 7777".trim() ;
        final Intent phoneIntent = new Intent(Intent.ACTION_DIAL);
        phoneIntent.setData(Uri.parse(uri));
        return phoneIntent;
    }
    //Checking
    if ( !checkIntent(intent) ) {
                textview.setAutoLinkMask(0);
    }
    //be sure that you call setText after this 
    

提交回复
热议问题