Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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-formatting issue due to this: dat=mailto:[email protected] (has extras) ....but I am not sure I have any errors in emails.

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW
dat=mailto:[email protected] (has extras) }
        at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1512)
        at android.app.Instrumentation.execStartActivity(Instrumentation.java:1384)
        at android.app.Activity.startActivityForResult(Activity.java:3190)
        at android.app.Activity.startActivity(Activity.java:3297)
        at android.text.style.URLSpan.onClick(URLSpan.java:62)
        at android.text.method.LinkMovementMethod.onTouchEvent(LinkMovementMethod.java:212)
        at android.widget.TextView.onTouchEvent(TextView.java:8344)
        at android.view.View.dispatchTouchEvent(View.java:5542)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
        at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
        at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1912)
        at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1371)
        at android.app.Activity.dispatchTouchEvent(Activity.java:2364)
        at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1860)
        at android.view.View.dispatchPointerEvent(View.java:5722)
        at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:2897)
        at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2473)
        at android.view.ViewRootImpl.processInputEvents(ViewRootImpl.java:845)
        at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2482)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4424)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
        at dalvik.system.NativeStart.main(Native Method)

Thank you!

Here is the manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mypackage"
    android:versionCode="123"
    android:versionName="1.2.3" >

    <supports-screens  android:largeScreens="true"   android:normalScreens="true"  android:smallScreens="true"/> 

    <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="16"/>

    <uses-permission android:name="android.permission.INTERNET" />


    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />


    <permission android:name="com.problemio.permission.C2D_MESSAGE" 
        android:protectionLevel="signature" />
    <uses-permission android:name="com.problemio.permission.C2D_MESSAGE" />


    <!-- App receives GCM messages. -->
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> 
    <!-- GCM requires a Google account. -->
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <!-- Keeps the processor from sleeping when a message is received. -->
    <uses-permission android:name="android.permission.WAKE_LOCK" /> 


    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" 
        android:theme="@style/CustomTheme" 
        android:name="MyApplication"
                >

        <!--  For Google Cloud Messaging -->
        <receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" >
          <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
                <category android:name="com.problemio" />
          </intent-filter>
        </receiver>   

        <service android:name=".GCMIntentService" />
        <!--  End of Google Cloud Messaging -->






        <activity
            android:name=".ProblemioActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name=".AddProblemActivity"
            android:configChanges="orientation|keyboardHidden"
            android:label="@string/add_problem" />

        <activity
            android:name=".LoginActivity"
            android:label="@string/login" />        

        <activity
            android:name=".MyProblemsActivity"
            android:label="@string/your_problems" /> 

        <activity
            android:name=".CreateProfileActivity"
            android:configChanges="orientation|keyboardHidden"
            android:label="@string/create_account" />         

        <activity
            android:name=".ProblemActivity"
            android:label="@string/problem_page_header" />   


        <activity
            android:name=".WePromoteActivity"
            android:label="@string/we_promote" /> 

<!--  
        <activity
            android:name=".SuggestSolutionActivity"
            android:label="@string/suggest_solution_header" />  

        <activity
            android:name=".SuggestedSolutionActivity"
            android:label="@string/suggested_solution_header" />          

        <activity
            android:name=".ViewSolutionsActivity"
            android:label="@string/view_solutions_header" />        
-->        
        <activity
            android:name=".TopicActivity"
            android:label="@string/topic_header" 
            android:configChanges="keyboardHidden|orientation"
            android:windowSoftInputMode="stateHidden"/>         

        <activity
            android:name=".ForgotPasswordActivity"
            android:configChanges="orientation|keyboardHidden"
            android:label="@string/forgot_password_heading" />         

        <activity
            android:name=".AskQuestionActivity"
            android:configChanges="orientation|keyboardHidden"
            android:label="@string/ask_question_heading" />         

        <activity
            android:name=".QuestionActivity"
            android:label="@string/question_header" 
            android:configChanges="keyboardHidden|orientation"
            android:windowSoftInputMode="stateHidden"/>     


        <activity
            android:name=".MyQuestionsActivity"
            android:label="@string/see_my_questions_header" />        



        <activity
            android:name=".LearnActivity"
            android:label="@string/learn_header" />         

        <activity
            android:name=".ExtraHelpActivity"
            android:configChanges="orientation|keyboardHidden"
            android:label="@string/extra_help_header" />          

        <activity
            android:name=".content.AdvertisingActivity"
            android:label="@string/advertising_header" />           

        <activity
            android:name=".content.ProductStrategyActivity"
            android:label="@string/product_strategy_header" />         

        <activity
            android:name=".content.BusinessModelsActivity"
            android:label="@string/business_models_header" />           

        <activity
            android:name=".content.StageTacticsActivity"
            android:label="@string/stage_tactics_header" />         

        <activity
            android:name=".content.InvestorsActivity"
            android:label="@string/funding_header" />         


        <activity
            android:name=".content.TargetMarketActivity"
            android:label="@string/target_market_header" />           

        <activity
            android:name=".SettingsActivity"
            android:label="@string/settings_header" />         

        <activity
            android:name=".content.BusinessIdeasActivity"
            android:label="@string/business_ideas" /> 

        <activity
            android:name=".content.MarketIdeaValidationActivity"
            android:label="@string/market_idea_validation" />         



        <activity
            android:name=".content.UnitEconomicsActivity"
            android:label="@string/unit_economics" />  

        <activity
            android:name=".content.PremiumWebAdvertisingActivity"
            android:label="@string/premium_web_marketing" />          

        <activity
            android:name=".content.PsychologyActivity"
            android:label="@string/business_psychology" />  

        <activity
            android:name=".NumberOfBusinessesActivity"
            android:label="@string/num_of_businesses" />          

        <activity
            android:name=".TimelineActivity"
            android:label="@string/timeline" />          

        <activity
            android:name=".content.PitchBusinessActivity"
            android:label="@string/pitch" />   

        <activity
            android:name=".content.TopMistakesActivity"
            android:label="@string/top_mistakes" />        

        <activity
            android:name=".content.MarktingAndConversionActivity"
            android:label="@string/marketing_and_conversion" />           

        <activity
            android:name=".content.HelpInstructionsActivity"
            android:label="@string/help_instructions" />          


        <activity
            android:name=".content.WebSetupActivity"
            android:label="@string/web_setup_page" />          


        <activity
            android:name=".UpdateProfileActivity"
            android:configChanges="orientation|keyboardHidden"
            android:label="@string/update_profile" />           





        <activity
            android:name=".FeedbackActivity"
            android:label="@string/feedback" 
            android:configChanges="keyboardHidden|orientation"
            android:windowSoftInputMode="stateHidden"/> 


        <activity
            android:name=".BaseActivity" />

        <activity
            android:name=".BaseListActivity"/> 

        <activity
            android:name=".EditBusinessActivity"
            android:configChanges="orientation|keyboardHidden"
            android:label="@string/edit_business" />   

        <activity
            android:name=".TopicEditActivity"
            android:configChanges="orientation|keyboardHidden"
            android:label="@string/topic_edit" />        

        <activity
            android:name=".InviteFriendsActivity"
            android:configChanges="orientation|keyboardHidden"
            android:label="@string/invite_friends" />

        <activity
            android:name=".EnterInviteCodeActivity"
            android:configChanges="orientation|keyboardHidden"
            android:label="@string/enter_invite_code" />        

        <activity
            android:name=".CommunityActivity"
            android:configChanges="orientation|keyboardHidden"
            android:label="@string/community_page" />   

        <activity
            android:name=".CommunitySignupActivity"
            android:label="@string/community_signup" />           

        <activity
            android:name=".PlanExamplesActivity"
            android:label="@string/plan_examples" />

        <activity
            android:name=".Settings"
            android:label="@string/plan_examples" />        


        <activity
            android:name=".GiveBackActivity"
            android:label="@string/give_back" /> 

        <activity
            android:name=".MotivationActivity"
            android:label="@string/motivation_page" />         


        <activity
            android:name=".AdsActivity"
            android:label="@string/ads_activity" />         

        <activity
            android:name=".content.WebsiteServiceActivity"
            android:label="@string/website_service_activity" />         

        <activity
            android:name=".MoreArticlesActivity"
            android:label="@string/more_articles" />           

<!--         
        <service android:name="BillingService" />

        <receiver android:name="BillingReceiver">
            <intent-filter>
                <action android:name="com.android.vending.billing.IN_APP_NOTIFY" />
                <action android:name="com.android.vending.billing.RESPONSE_CODE" />
                <action android:name="com.android.vending.billing.PURCHASE_STATE_CHANGED" />
            </intent-filter>
        </receiver>        
 -->

        <activity android:name="com.tapjoy.TJCOffersWebView" android:configChanges="keyboardHidden|orientation" />
        <activity android:name="com.tapjoy.TapjoyFullScreenAdWebView" android:configChanges="keyboardHidden|orientation" />
        <activity android:name="com.tapjoy.TapjoyDailyRewardAdWebView" android:configChanges="keyboardHidden|orientation" />
        <activity android:name="com.tapjoy.TapjoyVideoView" android:configChanges="keyboardHidden|orientation" />

        </application>

</manifest>

Could something like this be a problem:

<TextView
    android:id="@+id/contact_email"    
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop ="15dp" 
    android:autoLink="email"
    android:text="[email protected]"

    />
like image 717
Genadinik Avatar asked Dec 30 '12 10:12

Genadinik


People also ask

How do I open a URL with intent?

To open a URL/website you do the following: String url = "http://www.example.com"; Intent i = new Intent(Intent. ACTION_VIEW); i.

What is intent Action view?

An intent allows you to start an activity in another app by describing a simple action you'd like to perform (such as "view a map" or "take a picture") in an Intent object.

Could not open URL Whatsapp app ': No activity found to handle intent?

You see no activity found to handle intent when you attempt to launch an intent either to open a link or to access an app component. It's an error message that is caused because the device is not an official android, Google Play is not supported, or it's a rooted device.

What is intent Flag_activity_new_task?

The flags you can use to modify the default behavior are: FLAG_ACTIVITY_NEW_TASK. Start the activity in a new task. If a task is already running for the activity you are now starting, that task is brought to the foreground with its last state restored and the activity receives the new intent in onNewIntent() .


2 Answers

I ran into this problem as well, the thing is that when you define:

android:autoLink="email"
android:text="[email protected]"

or any other type of autolink in a TextView, android handles everything for you.

In the emulator email is not setup by default, so there is no app to handle the intent, and this makes your app crash if you click an autolinked email address. If you open the mail app and follow the instructions to set it up, then when you click the email address it will work.

I don't know what you can do to work around this issue. I guess it might not be safe to assume the user has mail setup or at least one app capable of handling that intent. I also guess that the app shouldn't be crashing... I think this is an issue with android as in this case you have no way of handling the exception.

If you look at the source of URLSpan (If autolink is set, TextView uses android.text.util.Linkify.addLinks(..) which creates instances of URLSpan to create links): http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.1.2_r1/android/text/style/URLSpan.java#URLSpan

public void onClick(View widget) {
    Uri uri = Uri.parse(getURL());
    Context context = widget.getContext();
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
    context.startActivity(intent);
}

They could either handle the exception or use PackageManager to determine if the Intent would succeed before calling startActivity() (like they recommend: http://developer.android.com/training/basics/intents/sending.html#Verify) or use a chooser.

Although the Android platform guarantees that certain intents will resolve to one of the built-in apps (such as the Phone, Email, or Calendar app), you should always include a verification step before invoking an intent.

Caution: If you invoke an intent and there is no app available on the device that can handle the intent, your app will crash.

So my question would be: is there any guarantee that an email intent will always resolve on a real device?

ok... on the same section they also mention:

Note: You should perform this check when your activity first starts in case you need to disable the feature that uses the intent before the user attempts to use it. If you know of a specific app that can handle the intent, you can also provide a link for the user to download the app (see how to link to your product on Google Play).

One can always check if the intent resolves to any activity at the start of the application, set a flag and every time the layout containing such TextView is inflated we find it and disable auto link for email, etc. (and this is when I ponder killing an unicorn over coding that)

like image 163
novettam Avatar answered Oct 19 '22 08:10

novettam


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<ResolveInfo> 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", "[email protected]", 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 
like image 26
user3866289 Avatar answered Oct 19 '22 08:10

user3866289