0

I am trying to use Chrome Custom Tabs in my app. I want to open the Chrome Custom Tab when the user clicks any link inside the body (TextView) of the note. But when I click the note to view it, the app stops and shows this log:

--------- beginning of crash
06-22 19:59:43.592 12971-12971/com.twitter.i_droidi.notah E/AndroidRuntime: FATAL EXCEPTION: main
                                                                            Process: com.twitter.i_droidi.notah, PID: 12971
                                                                            java.lang.RuntimeException: Unable to start activity ComponentInfo{com.twitter.i_droidi.notah/com.twitter.i_droidi.notah.ViewNote}: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat= (has extras) }
                                                                                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                                                                                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                                                at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                at android.os.Looper.loop(Looper.java:148)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                             Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat= (has extras) }
                                                                                at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1798)
                                                                                at android.app.Instrumentation.execStartActivity(Instrumentation.java:1512)
                                                                                at android.app.Activity.startActivityForResult(Activity.java:3917)
                                                                                at android.app.Activity.startActivityForResult(Activity.java:3877)
                                                                                at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:842)
                                                                                at android.app.Activity.startActivity(Activity.java:4200)
                                                                                at android.support.v4.app.ActivityCompatJB.startActivity(ActivityCompatJB.java:26)
                                                                                at android.support.v4.app.ActivityCompat.startActivity(ActivityCompat.java:133)
                                                                                at android.support.customtabs.CustomTabsIntent.launchUrl(CustomTabsIntent.java:200)
                                                                                at com.twitter.i_droidi.notah.ViewNote.onCreate(ViewNote.java:61)
                                                                                at android.app.Activity.performCreate(Activity.java:6237)
                                                                                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                                                                                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                                                                                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                                                at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                                                at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                at android.os.Looper.loop(Looper.java:148) 
                                                                                at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                                at java.lang.reflect.Method.invoke(Native Method) 
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

* ViewNote.java:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.view_note);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        ...
        ...
        ...

        CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
        builder.setShowTitle(true);
        CustomTabsIntent customTabsIntent = builder.build();
        customTabsIntent.launchUrl(this, Uri.parse(viewBody.getUrls().toString()));
    }

* UPDATE:

* AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.twitter.i_droidi.notah">

    <uses-sdk tools:overrideLibrary="android.support.customtabs" />

    <application
        android:name=".MyRealm"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".CreateNote"
            android:label="@string/title_activity_create_note"
            android:parentActivityName=".MainActivity"
            android:theme="@style/AppTheme.NoActionBar">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.twitter.i_droidi.notah.MainActivity" />
        </activity>
        <activity
            android:name=".ViewNote"
            android:label="@string/title_activity_view_note"
            android:parentActivityName=".MainActivity"
            android:theme="@style/AppTheme.NoActionBar">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.twitter.i_droidi.notah.MainActivity" />
        </activity>
        <activity
            android:name=".EditNote"
            android:label="@string/title_activity_edit_note"
            android:parentActivityName=".ViewNote"
            android:theme="@style/AppTheme.NoActionBar">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.twitter.i_droidi.notah.ViewNote" />
        </activity>
    </application>

</manifest>
Androider
  • 159
  • 11
  • `android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat= (has extras) }` suggests that `viewBody.getUrls().toString()` is perhaps the empty string. – CommonsWare Jun 22 '16 at 20:42
  • @CommonsWare I wrote: `customTabsIntent.launchUrl(this, Uri.parse("https://www.google.com");` but it shows the same problem. – Androider Jun 22 '16 at 20:49
  • 1
    Do you have Chrome installed? There is a very similar question that discusses basically the same issue - http://stackoverflow.com/questions/34823420/chrome-custom-tabs-throwing-an-error-when-chrome-is-not-installed-no-activity – Doron Yakovlev Golani Jun 22 '16 at 20:52
  • @DoronYakovlev-Golani Yes, it's installed on my phone. The app crashes when I enter the activity, not pressing the link! – Androider Jun 22 '16 at 21:05
  • Is there anyone here to help me?! – Androider Jun 30 '16 at 02:02
  • I too had similar bug until I found this thread: http://stackoverflow.com/questions/5882656/no-activity-found-to-handle-intent-android-intent-action-view – Shivam Srivastava May 16 '17 at 21:09

0 Answers0