I have an android application , when user press home button ,android application minimize . I want to open this application 5 seconds after minimize. what should I do?
Here is the code i wrote for you
@Override
public void onPause(){
super.onPause();
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
Intent intent = new Intent( this, MainActivity.class );
PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 123, intent, 0);
alarmManager.set( AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+5000,pendingIntent);
}
If you want exactly 5 seconds in devices after KitKat use alarmManager.setExact