2

I'm trying to open a certain set of activities inside my application and for that I have added a custom uri scheme in my AndroidManifest file.

The problem here is when I use these link inside a TextView I get the following exception:

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=numbers://imnumbers.com/buynumber (has extras) }

While from a WebView (links clicked inside a WebView) everything works fine. I've searched the web extensively for a solution to no avail.

This is how I parse html for TextView:

textView.setText(Html.fromHtml(message.getContent()));
textView.content.setMovementMethod(LinkMovementMethod.getInstance());

I've tried this answer but it just doesn't work. Nothing happens when I click on links.

UPDATE: The custom uri scheme is defined as follows:

    <activity
        android:name=".simcard.NewBuySimCardActivity"
        android:label="@string/title_activity_new_buy_sim_card">
        <intent-filter>
            <action android:name="android.intent.action.VIEW"/>

            <category android:name="android.intent.category.DEFAULT"/>
            <category android:name="android.intent.category.BROWSABLE"/>

            <data
                android:host="imnumbers.com"
                android:pathPrefix="/buynumber/"
                android:scheme="numbers"/>
        </intent-filter>
    </activity>
Community
  • 1
  • 1
2hamed
  • 8,719
  • 13
  • 69
  • 112

2 Answers2

2

I finally managed to fix it. The problem was with the trailing slashes \. Removing them solved the issue.

<activity
    android:name=".simcard.NewBuySimCardActivity"
    android:label="@string/title_activity_new_buy_sim_card">
    <intent-filter>
        <action android:name="android.intent.action.VIEW"/>

        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>

        <data
            android:host="imnumbers.com"
            android:pathPrefix="/buynumber"
            android:scheme="numbers"/>
    </intent-filter>
</activity>
2hamed
  • 8,719
  • 13
  • 69
  • 112
1

You said you tried the answer here. Android TextView with Clickable Links: how to capture clicks?

Have you tried the answer together with setMovementMethod? tv.setMovementMethod(LinkMovementMethod.getInstance());

Community
  • 1
  • 1
Derek Fung
  • 8,171
  • 1
  • 25
  • 28
  • Thanks your solution actually worked but unfortunately the same exception occurs. Seems the problem is with intent filters or the intent data! – 2hamed Aug 30 '15 at 07:24
  • @HamedMomeni just use custom `ClickableSpan` the docs are here: http://developer.android.com/reference/android/text/style/ClickableSpan.html – pskink Aug 30 '15 at 09:31