Safeguard against “a matching Activity may not exist” in android settings

非 Y 不嫁゛ 提交于 2019-12-05 06:21:16

If I read this correctly for instance a runtime exception (NPE) is thrown

No, that's some other problem. The Intent clearly worked, as the crash is coming from Settings itself, not the app that called startActivity().

I would love to use something more specific though like ActivityNotFoundException - but is it enough ?

It should be.

If you are concerned about that, or would rather be proactive, rather than just calling startActivity(), first use PackageManager and resolveActivity(). If that returns null, there is no activity that matches the Intent, and you should try something else.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!