0

BroadcastReciever送信したいシステムアプリがありますIntent(そのシステムアプリを改造しているため、テスト目的で)。

システム アプリのAndroidManifest.xmlは次のようになります。

<application android:label="@string/app_name">
    <receiver android:label="StateReceiver" android:name=".abstractor.StateReceiver" android:enabled="true" android:exported="true">
        <intent-filter>
            <action android:name="com.sec.android.contextaware.HEADSET_PLUG" />
            <action android:name="android.intent.action.LOCALE_CHANGED" />
            <action android:name="android.intent.action.BOOT_COMPLETED" />
            <action android:name="android.bluetooth.headset.profile.action.CONNECTION_STATE_CHANGED" />
            <category android:name="android.intent.category.HOME" />                
        </intent-filter>
    </receiver>
    <provider android:name=".manager.LoggingDataProvider" android:authorities="com.sec.android.contextaware.manager.LoggingDataProvider" />
</application>

テスト アプリを使用して、ターゲット システム アプリが実際にそのインテントを受信できるかどうかを確認します。

Intent intent = new Intent();
intent.setAction("com.sec.android.contextaware.HEADSET_PLUG");

PackageManager pm = getPackageManager();
for (ResolveInfo resolveInfo : pm.queryBroadcastReceivers(bt, 0)) {
    Log.d("APP: ", resolveInfo.toString());
}

システムアプリの情報を取得ResolveInfoして、インテントを受け取ることができるはずです。次に、次のようにインテントをブロードキャストします。

sendBroadcast(intent);

しかし何も起こらず、意図は受け取られません。ターゲット システム アプリのマニフェスト ファイルとコードを完全に制御できます。どういうわけか意図を伝えることは可能ですか?デバイスはルート化されています。

4

1 に答える 1

0

sendStickyBroadcast(intent) を試しましたか? null 受信者を登録すると、最後に送信された受信者を取得できるはずです。それが役立つかどうかはわかりません。ところで、送信先のターゲット システム アプリは何ですか? 許可されていないか、対処方法に問題があるため、そこに到達していません。

com.sec.android.contextaware.HEADSET_PLUG の受信が許可されていないか、アドレス指定が間違っていると推測しています。特に com.sec.android.contextaware.HEADSET_PLUG を再確認してください。

于 2012-07-12T22:32:45.510 に答える