서비스로 배터리 상태를 알아오는앱을 개발중입니다.

수많은 배터리 앱과 동일한 기능인 앱을 개발중입니다.

 

서비스에 브로드캐스트를 등록하여

액티비시에서 시작 버튼으로 서비스를 시작합니다.

처음에 배터리가 변화하면 잘 알려주고 제대로 변하는데

시간이 좀 지나면 서비스에 브로드캐스트가 작동하지 않습니다.

 

처음부터 안되면 그렇다 하겠는데 도중에 그냥 알림이 없어서

토스트로 메시지를 확인해 보면 토스트 메시지도 나타나지 않습니다.

서비스가 일정 시간이 지나면 정지하는지 알고 싶습니다.

 

지금은 서비스에 쓰레드를 돌려서 해결하였는데

꼭 쓰레드를 돌려야만 하는것인지 알고 싶습니다.

 

개인적인 생각으론 브로드캐스트 만으로도 배터리량 변화를 알수 있을것 같은데

제 생각과는 좀 다른게 있네요.

 

감사합니다.

public class BatteryStatusService extends Service {
 

 @Override
 public void onCreate() {
  // TODO Auto-generated method stub
  super.onCreate();

  nManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
 
 }

 public class BattInfoReceiver extends BroadcastReceiver {
  @Override
  public void onReceive(Context context, Intent intent) {
         if(intent.getAction().equals(Intent.ACTION_BATTERY_CHANGED)){
          // battery %
 }

    public void setNotification(String strLevel,int iLevel) {
        // Create a notification
        notification = new Notification(
     R.drawable.level_list,              // An Icon to display
                 "",                            // the text to display in the ticker
                 System.currentTimeMillis()       ); // the time for the notification

}