简体   繁体   中英

how to create android intent filter without hyperlink

I have tried setting intent filter as http://myapp.com which works well if there is a hyperlink link of this type. Another is myapp:// and I have only managed to get this to work by redirecting from a webpage. Eg. Localhost/redirect.jsp which redirects to myapp://etc

How and where else can I use myapp://etc ? Specifically in messaging app such as whatsapp, line, etc. In android, myapp://etc are not clickable.

use this:

TextView v = new TextView(this);
v.setTextSize(24);
v.setMovementMethod(LinkMovementMethod.getInstance());

SpannableStringBuilder ssb = new SpannableStringBuilder();
ssb.append("this is my ");
int start = ssb.length();
ssb.append("app");
int end = ssb.length();
ssb.append(" just use it!");

URLSpan span = new URLSpan("myapp://some.host");
ssb.setSpan(span, start, end, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
v.setText(ssb);

setContentView(v);

or use one of Linkify.addLinks() method to add your myapp://etc links

actifity declaration in the manifest:

<activity android:name=".MyAppActivity">
    <intent-filter>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <data android:scheme="myapp"/>
    </intent-filter>
</activity>

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM