2017-12-01 13 views
0

앱이 백그라운드로 이동하면 팝업 알림 대화 상자가 나타납니다. 요점은 애플리케이션이 백그라운드로 전환 될 때마다 팝업 알림을 받고 작업을 마친 것처럼 사용자에게 경고합니다. .앱이 배경에있을 때 대화 상자가 나타나지 않습니다.

public void alertIfStopNotPressed(){ 
    if(active){ 
     this.runOnUiThread(new Runnable() { 
      public void run() { 
       callDialog(); 
      } 

     }); 
    } 
} 

public void callDialog(){ 
    AlertDialog.Builder dlg = new AlertDialog.Builder(this) 
      .setTitle("UPOZORENJE!") 
      .setMessage("Pritisnite STOP ukoliko ste završili sastanak") 
      .setPositiveButton("U redu", 
        new DialogInterface.OnClickListener() { 
         public void onClick(DialogInterface dialog, int which) { 
          dialog.dismiss(); 
         } 
        }); 

    dlg.create().show(); 

} 

이 ... 나사 부분

if (clicked == false) { 

     if (thread == null) { 
      //thread for checking if operator has pushed stop button 
      thread = new Thread() { 


       @Override 
       public void run() { 

        try { 

          sleep(1500000); 
          alertIfStopNotPressed(); 
         } 


        } catch (InterruptedException e) { 
         e.printStackTrace(); 
        } 
       } 

      }; 
      thread.start(); 
      clicked = true; 
     } 

답변

0

앱이 전경에 활동이있는 경우 대화 상자 만 나타납니다.

대화 상자 대신 활동을 시작하고 대화 상자 모양을 제공 할 수 있습니다.

여기에서 수행 방법을 확인할 수 있습니다. Android Activity as a dialog