问题:
Is it possible to catch this exception when using mailto: in TextView's text?
Fatal Exception: android.content.ActivityNotFoundException No Activity found to handle I...
可以将文章内容翻译成中文,广告屏蔽插件会导致该功能失效:
问题:
Is it possible to catch this exception when using mailto:
in TextView's
text?
Fatal Exception: android.content.ActivityNotFoundException No Activity found to handle Intent { act=android.intent.action.VIEW dat=mailto:xxxxxxx@xxxxx.xxx (has extras) } android.widget.TextView.onTouchEvent
<string name="about_text"><![CDATA[
Support: <a href="mailto:test@gmail.com">test@gmail.com</a>
]]></string>
回答1:
you can handle this error while try to execute it like this:
try {
startActivity(intent);
} catch (ActivityNotFoundException e) {
Toast.makeText(mContext, "your error message" , Toast.LENGTH_SHORT).show();
}
回答2:
You can still use this to catch the exception, regardless of how it gets thrown, whether through startActivity
or otherwise..
try {
// Your Code Here
} catch (ActivityNotFoundException e) {
Toast.makeText(this, "Mail client not found", Toast.LENGTH_LONG).show();
}