开发者

How to start a new application on Android

How can I start a new application on Android? I have done a new applications NewHomeScreen and Hello and on NewHomeScreen I wrote this code.

@Override public void onCreate(Bundle state) {
    super.onCreate(state);
    setContentView(R.layout.main);
    Intent mainIntent = new Intent(this,Hello.class);
    startActivity(mainIntent);
}

However, it does not start Hello application. Debugger says that state has value null but what should it be? I also wrote this to Manifest:

<activity android:name="Hello">
    <intent-filter>
            <action android:name="android开发者_开发技巧.intent.action.HELLO" />
            <category android:name="android.intent.category.HELLO"/>
            <category android:name="android.intent.category.DEFAULT" />
    </intent-filter> 
</activity>


Try getting rid of the intent-filter in your Home activity. You don't need it anyway, if it's not your main screen.


I think you forgot to specify the main Activity in your AndroidManifest.xml file:

 <application android:icon="@drawable/icon">
    <activity android:name="NewHomeScreen" android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.HELLO" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜