0
何とか私のACTION_POWER_CONNECTEDとACTION_POWER_DISCONNECTEDは充電器からネクサス6を抜き差しすると起動しませんでした。Android:イベントACTION_POWER_CONNECTEDとACTION_POWER_DISCONNECTEDがBroadcastReceiverに送信されていません
たManifest.xml:
<application
android:name="com.xxx.xxx.xxx"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme.NoActionBar">
<receiver android:name=".PowerReceiver">
<intent-filter>
<action android:name="android.intent.action.ACTION_POWER_CONNECTED"/>
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED"/>
</intent-filter>
</receiver>
PowerReceiver.java
public class PowerReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "PowerReceiver fired", Toast.LENGTH_SHORT).show();
}
}
ありがとうございました!