I am trying to open a splash activity followed by main activity. But i am getting the following error in logcat.
01-20 16:46:45.568: E/AndroidRuntime(29579): FATAL EXCEPTION: main
01-20 16:46:45.568: E/AndroidRuntime(29579): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cyoa.necroprelude/com.cyoa.necroprelude.MainActivity}: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.cyoa.necroprelude.CHARACTER }
Activity code - Main Activity
package com.cyoa.necroprelude;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class MainActivity extends Activity {
Intent openStartingPoint;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
run();
}
private void run() {
Intent openStartingPoint = new Intent("com.cyoa.necroprelude.CHARACTER");
startActivity(openStartingPoint);
}
}
Activity code - Character Activity
package com.cyoa.necroprelude;
import android.app.Activity;
import android.os.Bundle;
public class Character extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.character);
}
}
here is the manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cyoa.necroprelude"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.cyoa.necroprelude.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.cyoa.necroprelude.Character"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.CHARACTER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Change
Intent openStartingPoint = new Intent("com.cyoa.necroprelude.CHARACTER");
to
Intent openStartingPoint = new Intent(this, CHARACTER.class);
String CUSTOM_ACTION = "android.intent.action.CHARACTER";
openStartingPoint.setAction(CUSTOM_ACTION);
When creating an intent that opens another screen make sure it looks something like the following
Intent intent = new Intent(thisScreen.this, newScreen.class);
startActivity(intent);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.