Not start MainActivity with android 2.3

后端 未结 2 1970
自闭症患者
自闭症患者 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: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) {
    
                        }
    

提交回复
热议问题