잠시 후 부팅 할 때 내 앱을 시작하고 싶습니다.1 분을 기다린 후 부팅시 Android 시작 앱
부팅 할 때 내 앱을 성공적으로 시작합니다. 하지만 앱을 시작하기 전에 잠시 기다려주세요.
내가 시도한 두 가지 해결책이 있습니다 (아래 그림 참조). 둘 다 응용 프로그램을 시작하지만 "응용 프로그램이 응답하지 않습니다"(ANR) 대화 상자를 표시합니다.
두 솔루션의 시간을 모두 40000 밀리 초로 수정하면 ANR이 표시되지 않습니다.
이유를 아는 사람이 있습니까? ANR 프롬프트없이 1 분으로 시간을 내려면 어떻게해야합니까?
정말 고마워요! 당신은 당신은 내가 의도가 실행됩니다 백그라운드 스레드를 시작하고
public class StartAtBoot extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
/* SOLUTION 1:
* final Context con = context; Handler handler = new Handler();
* handler.postDelayed(new Runnable() { public void run() { Intent i =
* new Intent(con, MainActivity.class);
* i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); con.startActivity(i); } },
* 60000);
*/
// SOLUTION 2:
Runnable runnable = new Runnable(){
@override
public void run(){
Thread.sleep(60000);
Intent i = new Intent(context, MainActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
(new Thread(runnable)).start();
}
}
뭔가를 시도 할 수 있습니다 핸들러에게
int duration = 1000; // milliseconds
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent i = new Intent(context, MainActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
}
}, duration);
알람을 사용해보십시오. 그리고 부트를 모두 처리하는 것을 건너 뜁니다. – hannunehg