Last active
January 1, 2016 00:09
-
-
Save angeldevil/8064943 to your computer and use it in GitHub Desktop.
Resolve issue that app crashes when clicks a TextView with autoLink be set to email or all but the system has no email client.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void startActivity(Intent intent) { | |
if (intent.toString().indexOf("mailto") != -1) { // Any way to judge that this is to sead an email | |
PackageManager pm = getPackageManager(); | |
// The first Method | |
List<ResolveInfo> activities = pm.queryIntentActivities(intent, 0); | |
if (activities == null || activities.size() == 0) { | |
// Do anything you like, or just return | |
return; | |
} | |
// Another method | |
// ResolveInfo resolveInfo = pm.resolveActivity(intent, 0); | |
// if (resolveInfo == null) | |
// Yet another metod | |
// Intent.createChooser(intent, "Choose email client"); | |
} | |
super.startActivity(intent); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment