Fix to crash when clicking text link without view activity
A generated quick link to telephone number gets clicked and crashes if corresponding activity doesn't exist in device. It attempts to open up an activity to view content which will in turn generate an uncaught ActivityNotFoundException. Solved by catching exception when launching activity for the specified content. Change-Id: I47364519f1eceb5b978b29382107deae1891c7da
This commit is contained in:
committed by
Takeshi Aimi
parent
f71f5e8957
commit
7bd9b7f73d
@@ -16,6 +16,7 @@
|
||||
|
||||
package android.text.style;
|
||||
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
@@ -23,6 +24,7 @@ import android.os.Parcel;
|
||||
import android.provider.Browser;
|
||||
import android.text.ParcelableSpan;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
public class URLSpan extends ClickableSpan implements ParcelableSpan {
|
||||
@@ -59,6 +61,10 @@ public class URLSpan extends ClickableSpan implements ParcelableSpan {
|
||||
Context context = widget.getContext();
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
|
||||
context.startActivity(intent);
|
||||
try {
|
||||
context.startActivity(intent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Log.w("URLSpan", "Actvity was not found for intent, " + intent.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user