2017-09-17 1 views
0

pjsua2 오픈 소스 프로젝트로 안드로이드 응용 프로그램을 가지고 있습니다. 들어오고 나가는 전화가 모두 잘 작동합니다. 그러나 안드로이드가 깊은 잠자기 등록을하지 못하면 작동하지 않습니다. 등록을 위해 서비스를 사용하고 있습니다. 그러나 다시 등록하지 마십시오 ..수면 상태에서도 pjsua2 VoIP 응용 프로그램에 등록을 유지 하시겠습니까?

accCfg.getRegConfig().setRetryIntervalSec(600); 
accCfg.getRegConfig().setFirstRetryIntervalSec(15); 

어떤 도움을 주시면 감사하겠습니다.

답변

1

안드로이드가 깊은 잠에 들어갈 때 안드로이드 OS가 거의 모든 서비스 및 기타 백그라운드 작업을 종료합니다. 그래서 모금 등록을 유지하기 위해 나는

public void setAlarmManagerFroDeepSleep() { 

    int interval = 1000 * 60 * 5; 

    Intent alarmIntent = new Intent(this, AlarmReceiver.class); 
    pendingIntent = PendingIntent.getBroadcast(this, 0, alarmIntent, 0); 
    AlarmManager manager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); 
    /* Repeating on every 5 minutes interval */ 
    manager.setRepeating(AlarmManager.RTC_WAKEUP, interval, 
      interval, pendingIntent); 
} 

것은 여기에 샘플 AlarmReciever 클래스입니다 ... AlarmManager 아주 좋은 option.Sample 예를 들어 그 시간을 다시 등록 min..so 매 5 년 UR 응용 프로그램을 깨어있을 것으로 예상 ..

public class AlarmReceiver extends BroadcastReceiver { 

@Override 
public void onReceive(Context context, Intent intent) { 

    Log.e("Alerm Manager", "I'm running"); 

    if(Connectivity.isConnected(context)) { 
     try { 
      //make re-register here.... 
     } catch (Exception e) { 
      e.printStackTrace(); 
     } 
    } 
    } 
} 
관련 문제