Je suis coincé avec un problème intéressant: j'ai une activité de type lanceur avec Theme.NoDisplay
(aucune interface utilisateur) qui devrait lancer des activités différentes selon certaines conditions et même si je suis En appelant le startActivity()
, il ne lancera aucun d'entre eux si l'application a été démarrée via l'icône du lanceur (elle démarre LauncherActivity
mais meurt ensuite sans erreur/exception).Impossible de démarrer une activité différente de celle du lanceur Activité
CEPENDANT
Si je commence LauncherActivity
par la BAD ou ajouter un délai à startActivity()
il semble fonctionner très bien.
Voici un extrait de code.
public class LauncherActivity extends Activity {
private Handler handler = new Handler();
private SharedPreferences preferences;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
preferences = getSharedPreferences(App.getContext().getString(R.string.preferences_name), MODE_PRIVATE);
int pesel = preferences.getInt(App.getContext().getString(R.string.pref_pesel), 0);
String password = preferences.getString(App.getContext().getString(R.string.pref_password), "");
Intent intent;
if (pesel != 0 && !password.isEmpty()) {
// TODO: server-side password check
intent = new Intent(this, MainActivity.class);
} else {
intent = new Intent(this, RegisterActivity.class);
}
Intent startIntent = getIntent();
intent.setAction(startIntent.getAction());
intent.setFlags(startIntent.getFlags());
if (startIntent.getExtras() != null)
intent.putExtras(startIntent.getExtras());
final Intent readyIntent = intent;
/*
THIS DOENS"T WORK (WORKS IF STARTED VIA ADB THOUGH)
*/
startActivity(readyIntent);
/*
THIS HOWEVER DOES WORK (ALWAYS)
*/
handler.postDelayed(new Runnable() {
@Override
public void run() {
startActivity(readyIntent);
}
}, 5000);
finish();
}
}
Montrez-nous votre manifeste? – t0mm13b