點擊通知欄沒反應,無法進入應用——啟動其他application的組件遇到的小問題 - SecurityException


Exception description:

__________________________________________________________________________________

05-29 15:47:17.936: E/AndroidRuntime(10458): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.smalant.demo.actionbar.test/com.smalant.demo.actionbar.test.MainActivity}: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.VIEW cmp=com.smalant.demo.actionbar/.OtherActivity } from ProcessRecord{418dd770 10458:com.smalant.demo.actionbar.test/10128} (pid=10458, uid=10128) not exported from uid 10127

______________________________________________________________________________________

解決辦法:

U have to add android:exported="true" in the manifest file in the activity you are trying to start

From the link given above

android:exported
Whether or not the activity can be launched by components of other applications — "true" if it can be, and "false" if not. If "false", the activity can be launched only by components of the same application or applications with the same user ID.

The default value depends on whether the activity contains intent filters. The absence of any filters means that the activity can be invoked only by specifying its exact class name. This implies that the activity is intended only for application-internal use (since others would not know the class name). So in this case, the default value is "false". On the other hand, the presence of at least one filter implies that the activity is intended for external use, so the default value is "true".

This attribute is not the only way to limit an activity's exposure to other applications. You can also use a permission to limit the external entities that can invoke the activity (see the permission attribute).


注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
粤ICP备14056181号  © 2014-2020 ITdaan.com