Not start MainActivity with android 2.3

后端 未结 2 1971
自闭症患者
自闭症患者 2021-01-28 09:14

I want to start my MainActivity, in android 2.3, it will not start, but in Jelly Bean it works. I get no error, nothing happens!

I\'ve noticed when I use putExtra, then

相关标签:
2条回答
  • 2021-01-28 09:28

    Might want to give this a try:

        Intent intent = new Intent("android.intent.action.MAIN");
        intent.addCategory("android.intent.category.LAUNCHER");
        intent.setComponent(new ComponentName("de.application.ui", "de.application.ui.MainActivity"));
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.putExtra("de.application.exit", true);
        startActivity(intent);
    
    0 讨论(0)
  • 2021-01-28 09:46

    I do this to start a main activity:

    Intent intent = IntentCompat.makeRestartActivityTask(cn);
    activity.startActivity(intent);
    
    
            Intent i =  new Intent("android.intent.action.MAIN");
            final ComponentName cn = new ComponentName  ("de.application.ui", "de.application.ui.MainActivity");
    
                            i.setComponent(n);                          
    
                        try {
                            startActivity(i);
                        } 
                        catch (ActivityNotFoundException e) {
    
                        }
    
    0 讨论(0)
提交回复
热议问题