代碼如下:
// 實例化過濾器並設置要過濾的廣播
String filter = Intent.ACTION_TIME_CHANGED;// "android.provider.Telephony.SMS_RECEIVED"
IntentFilter intentFilter = new IntentFilter(filter );
// 注冊廣播
registerReceiver(timeBroadcast, intentFilter);
timeBroadcast = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
// show();
Log.e(TAG, "broadcast time....");
}
};
如果改成
String filter = "android.provider.Telephony.SMS_RECEIVED";
可以收到短信的廣播,求指導!
先定義再注冊,你寫反了。