2017-01-11 1 views
0

은 내가 onRecive 방법은 내가 가지고 WakefulBroadcastReceiver을 생성, 알람 응용 프로그램을 만들려고 :안드로이드 STICKY 서비스

내 알람 서비스는 이것이다
public void onReceive(Context context, Intent intent) 
    { 
     System.out.println("onRecive Alarm broadcast"); 

     Intent service = new Intent(context, AlarmService.class); 
     startWakefulService(context, service); 
    } 

동안 : 내가하지 않으면

@Override 
    public int onStartCommand(Intent intent, int flags, int startId) 
    { 
     super.onStartCommand(intent, flags, startId); 

     Calendar calendar = Calendar.getInstance(); 
     long millisec = calendar.getTimeInMillis(); 
     sendNotification("Messaggio della notifica"); 

     System.out.println("onHandleIntent: " + getDate(millisec,"dd/MM/yyyy HH:mm:ss")); 


     AlarmBroadcastReceiver.completeWakefulIntent(intent); 

     return START_STICKY; 
    } 

내 앱을 모두 예상대로 작동시키지 마십시오. 그러나 앱을 닫으면 서비스가 해고되지 않습니다. 어디서 오류가 있습니까? 내 매니페스트에 는 내가 추가 한 : 당신이 알람 응용 프로그램을 만들고 싶어하고 알림 사용자가 다음 응용 프로그램을 종료 후에도 지정된 시간 이후에 표시 할 경우

<uses-permission android:name="android.permission.WAKE_LOCK" /> 
+0

가 정확히 무엇을 의미합니까 "응용 프로그램을 닫습니다"? –

+0

멀티 태스킹에서 제거되었습니다 (멀티 태스킹에서 빈을 클릭하면 huawei rom에 있음) – kikko088

답변