수신자가 Android 6.0 Marshmallow
으로 작동하지 않습니다.Android 6.0 브로드 캐스트 수신기가 수신되지 않습니다. BOOT_COMPLETE
, 아래 참조 : 응용 프로그램이 열려 있다면
adb shell am broadcast -a android.intent.action.BOOT_COMPLETED
이 을받은 앱 말 : 작업을!
그러나 응용 프로그램이 열려 있지 않으면 아무 것도 반환하지 않았습니다.
내 코드는 여기에 있습니다.
의 AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.berate.rebootreceiverfromb3r0">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" android:protectionLevel="signature|development"></uses-permission>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="com.example.berate.rebootreceiverfromb3r0.Yakala_Receiver">
<intent-filter>
<category android:name="android.intent.category.DEFAULT"></category>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
</application>
</manifest>
Receiver.Java;
public class Yakala_Receiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context,"i got it ",Toast.LENGTH_SHORT).show();
}
}
편집 : 흥미로운 정보가 있습니다. 내 코드는 samsung (Android 6.0) 기기에서 작동합니다. 하지만 내 (안드로이드 6.0) 장치 나에게
수신자 태그에 android : enabled = "true"android : exported = "true"를 추가하십시오. – user5195185
http://stackoverflow.com/questions/12274997/why-broadcastreceiver-works-even-when-app-is-in-background 체크 아웃 – nuriselcuk
왜 android : protectionLevel을 지정 하시겠습니까? 이것은 권한을 사용할 때가 아니라 권한을 만들 때입니다. – JoxTraex