i have implemented a Custom URL Span to open link with the chrome custom tab instead of default browser. The on click method of it is started, but I dont know how to launch the chrome custom launcher.
it looks this way:
public class CustomTabsURLSpan extends URLSpan {
Context context;
public CustomTabsURLSpan(String url) {
super(url);
Log.d("SensibleUrlSpan", "1");
}
public CustomTabsURLSpan(Parcel src) {
super(src);
Log.d("SensibleUrlSpan", "2");
}
@Override
public void onClick(View widget) {
Log.d("SensibleUrlSpan", "3");
String url = getURL();
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(context, Uri.parse(url));
}
}
I get a null reference error when calling this, I think its a problem with the context.
您没有初始化任何context
,因此它始终为null
。
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.