2015-09-02 85 views
0

我有一個斜槓屏幕開始菜單,並從我的菜單我試圖打開一個新的活動,雖然我得到一個錯誤,當我這樣做,應用程序崩潰。「沒有發現處理意圖的活動」,但意圖過濾器設置

我的清單

<activity 
     android:name=".menu" 
     android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="android.intent.action.MENU" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <category android:name="android.intent.category.HOME" /> 
     </intent-filter> 
    </activity> 

    <activity 
     android:name=".settings" 
     android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="android.intent.action.SETTINGS" /> 
     </intent-filter> 
    </activity> 

然後我呼籲我的菜單代碼:

Intent settingsIntent = new Intent("android.intent.action.SETTINGS"); 
startActivity(settingsIntent); 

我試圖改變的意圖名字,但它並不能幫助。

登錄章:

E/AndroidRuntime﹕ FATAL EXCEPTION: Thread-1288 
    android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SETTINGS } 
      at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1632) 
      at android.app.Instrumentation.execStartActivity(Instrumentation.java:1424) 
      at android.app.Activity.startActivityForResult(Activity.java:3390) 
      at android.app.Activity.startActivityForResult(Activity.java:3351) 
      at android.app.Activity.startActivity(Activity.java:3587) 
      at android.app.Activity.startActivity(Activity.java:3555) 
      at com.learningapp.splash$1.run(menu.java:30) 

編輯: 調用類直接工作:

startActivity(new Intent(currentClass.this, settings.class)); 
+0

爲什麼您使用的是行動,而不是類(含包名,可以用一個點來使用應用程序包中省略)? – 323go

+0

你確定你的活動在這種情況下調用「設置」嗎? –

+0

@ 323go你的意思是這樣的: 新的意圖(String.valueOf(about.class)) 我很新的東西。 – Slamit

回答

0

如果你想剛開始設置的活動,你應該使用這個

startActivity(new Intent(YourCurrentActivity.this, settings.class)); 
+0

好吧,它確實與班級來電。感謝那。雖然正確的行是:startActivity(new Intent(currentClass.this,settings.class)); – Slamit

+0

如果你從活動開始活動,那麼你就不需要寫'currentClass.this'。它用於活動外部鏈接的內部類。 – kolombo

+0

誰來評論這個答案? @ 323go是你嗎?也許你是Marcos Vasconcelos?作者只是不知道如何開始活動。如果你不理解沒有徽章的人,並且斥責「1」 - 不要觸摸投票按鈕,因爲這個人看到這個「-1」,他認爲這是錯誤的答案。 – kolombo

-1

你的活動可能不叫'設置'。

在AndroidManifest.xml中,你應該把叫不出名的name屬性

+0

我有一個settings.xlm在我的R.layout和一個settings.java。和清單中的「設置」。只是雙重檢查。 – Slamit

+0

是你投我的答案嗎?如果是你,請爲此投票,因爲它的正確答案和它正是作者想要的。 – kolombo

+0

沒有我ddnt,我不憤怒downvote –

相關問題