Catch all throwable from startActivity()
This commit is contained in:
1 parent
4b1c516b3e
commit
8af786e687
4 files changed
+23
-10
No files matched your search
@@ -22,8 +22,9 @@ import android.content.res.TypedArray;
|
||||
import android.preference.Preference;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
|
||||
import android.widget.Toast;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.util.ExceptionUtils;
|
||||
|
||||
public class ActivityPreference extends Preference {
|
||||
|
||||
@@ -68,6 +69,11 @@ public class ActivityPreference extends Preference {
|
||||
Context context = getContext();
|
||||
Intent intent = new Intent(context, mActivityClazz);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent);
|
||||
try {
|
||||
context.startActivity(intent);
|
||||
} catch (Throwable e) {
|
||||
ExceptionUtils.throwIfFatal(e);
|
||||
Toast.makeText(context, R.string.error_cant_find_activity, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user