我知道這個問題有很多問題,但是他們都沒有解決我的問題。我做了一個包含50個問題片段的測驗應用程序。在最後一個問題(問題50片段)中,我將分數活動稱爲顯示分數。在此活動中,我創建了一個「再次播放」按鈕,該按鈕再次調用主要活動來開始遊戲。但每次我點擊「再次播放」按鈕,我的應用程序崩潰。找不到處理Intent的活動
logcat的錯誤:04-03 15:34:43.638 26316-26316/com.example.moresche.englishqigame E/AndroidRuntime: FATAL EXCEPTION: main android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.example.moresche.englishqigame.MainActivity }
scoreActivity.java
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_score);
Typeface mTypeface = Typeface.createFromAsset(getAssets(),"chlo.TTF");
TextView myTextview = (TextView)findViewById(R.id.txtla);
myTextview.setTypeface(mTypeface);
Typeface m2Typeface = Typeface.createFromAsset(getAssets(),"chlo.TTF");
TextView m2yTextview = (TextView)findViewById(R.id.txtla1);
m2yTextview.setTypeface(m2Typeface);
initControls();
}
public void initControls() {
TextView final_score = (TextView) findViewById(R.id.textView103);
TextView final_scoreqi = (TextView) findViewById(R.id.textView104);
TextView lvlqi = (TextView) findViewById(R.id.textViewzzz);
Button btnxd = (Button)findViewById(R.id.btnx);
final SharedPreferences app_preferences = PreferenceManager.getDefaultSharedPreferences(this);
...
btnxd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
app_preferences.edit().clear().commit();
Intent intent1 = new Intent ("com.example.moresche.englishqigame.MainActivity");
startActivity(intent1);
}
});
清單文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.moresche.englishqigame">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".scoreActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="com.example.moresche.englishqigame.scoreActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
非常感謝,它的工作原理! –