2
清單:android.intent.action.BATTERY_OKAY在廣播接收器中不工作,在廣播接收器中做什麼?
<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);
}
// }
}
我試圖用電池低和works.but電池正常不工作。有時我使用這些代碼,這就是爲什麼我使用評論check.but沒有working.please幫助!
我試圖與這兩個android.intent.action.ACTION_BATTERY_OKAY和android.intent.action.BATTERY_OKAY但是Android的完整示例根本沒有發射這個事件。 –