我想在ACTION_BATTERY_LOW..时创建一个简单的通知。当电池电量不足的弹出窗口出现时,我想要在状态栏中启动一个通知。我试过这样:在 onCreate
this.registerReceiver(this.batteryLowNotifi, new IntentFilter(Intent.ACTION_BATTERY_LOW));
接着:
private void checkPref(){ 
        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(
                                TutorialNotification.this);
                notificationBuilder.setContentTitle("Title");
                notificationBuilder.setContentText("Context");
                notificationBuilder.setTicker("TickerText");
                notificationBuilder.setWhen(System.currentTimeMillis());
                notificationBuilder.setSmallIcon(R.drawable.ic_stat_icon);
                Intent notificationIntent = new Intent(this, TutorialNotification.class);
                PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
                                notificationIntent, 0);
                notificationBuilder.setContentIntent(contentIntent);
                notificationBuilder.setDefaults(Notification.DEFAULT_SOUND
                                | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE);
                mNotificationManager.notify(SIMPLE_NOTIFICATION_ID,
                                notificationBuilder.build());
    }   
    private BroadcastReceiver batteryInfoReceiver = new BroadcastReceiver() {
        public void onReceive(Context context, Intent intent) { 
          checkPref(intent);
      }
    }
但什么也没有发生。有什么帮助吗?谢谢