4
我想從Activity
開始BroadcastReceiver
。我怎樣才能做到這一點?從活動開始BroadCastReceiver
我想從Activity
開始BroadcastReceiver
。我怎樣才能做到這一點?從活動開始BroadCastReceiver
定義你的廣播接收器:
private final BroadcastReceiver receiver
= new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// Do something
}
};
填寫您的接收器中的onResume:
@Override
protected void onResume() {
super.onResume();
IntentFilter filter = new IntentFilter();
filter.addAction("SOME_ACTION");
registerReceiver(receiver, filter);
}
註銷接收器的onPause:
@Override
protected void onPause() {
super.onPause();
unregisterReceiver(receiver);
}
我應該付出的許可清單文件? – shyam 2012-04-25 05:04:06