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>
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>
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());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.