2014-01-20 49 views
0

我正試圖打開後跟主要活動的啓動活動。但我在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 } 

活動碼 - 主要活動

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); 
}  
} 

活動代碼 - 漢字活動

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); 
} 

} 

這裏是清單

<?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> 

回答

0

變化

Intent openStartingPoint = new Intent("com.cyoa.necroprelude.CHARACTER"); 

Intent openStartingPoint = new Intent(this, CHARACTER.class); 
String CUSTOM_ACTION = "android.intent.action.CHARACTER"; 
openStartingPoint.setAction(CUSTOM_ACTION); 
+0

意圖確實出現了現在的工作的感謝! – user2465356

+0

@ user2465356,請立即嘗試更新的代碼。 – Prem

0

當創建打開另一個屏幕確保它看起來像下面

Intent intent = new Intent(thisScreen.this, newScreen.class); 
startActivity(intent); 
+0

爲您做了改變嗎? – Pythagoras