android.uid.system sendBroadcast失效的问题

如果是系统应用
android:sharedUserId="android.uid.system"
报这个错
 Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1188 android.content.ContextWrapper.sendBroadcast:

解决

添加如下权限
<uses-permission android:name="com.android.permission.MY_PERMISSON"/>
<permission android:name = "com.android.permission.MY_PERMISSONT"
    android:protectionLevel="signature"/>

 

        <receiver android:name=".volReceiver"
            android:enabled="true"
            android:exported="false"
            android:permission="com.android.permission.MY_PERMISSON"
            >
            <intent-filter>
                <action android:name="com.xx.gesturedirection" />
            </intent-filter>
        </receiver>

 

发送代码
                Intent intent = new Intent();
                intent.setAction("com.xx.gesturedirection");
                intent.putExtra("xx", "xx");
                intent.setPackage("包名");
                mCtx.sendBroadcast(intent, "com.android.permission.MY_PERMISSION");

 







posted @ 2024-08-01 15:14  balder_m  阅读(153)  评论(0编辑  收藏  举报