open link with chrome custom link

239 views Asked by At

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.

1

There are 1 answers

0
nicobatu On BEST ANSWER

You're not initializing context to anything, so it's always null.