清单:
<receiver android:name=".BatteryFullReceiver" >
<intent-filter>
<action android:name="android.intent.action.BATTERY_OKAY" />
</intent-filter>
</receiver>
广播接收器:
public class BatteryFullReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
// String intentAction = intent.getAction();
// if(Intent.ACTION_BATTERY_OKAY.equalsIgnoreCase(intentAction)){
Toast.makeText (context, "Battery Full", Toast.LENGTH_LONG).show ();
Speaker.tts.speak("Battery full ,you can disconnect the usb now", TextToSpeech.QUEUE_ADD, null);
}
// }
}
我尝试使用电池电量低而且工作正常。但电池正常工作无效。有时我使用那些代码,这就是为什么我使用评论进行检查。但没有什么工作。请帮助!!!
答案 0 :(得分:1)
你拼错了意图行动:
android.intent.action.ACTION_BATTERY_OKAY