2013-03-20 47 views
-1

我已經過了一個小時,我找不出這個問題。我試圖在ACTION_UP TouchEvent內boolean的值爲true時嘗試啓動新的activity當清單正確時,沒有找到處理意圖的活動

public boolean onTouchEvent(MotionEvent event) { 

      int eventaction = event.getAction(); 
      int X = (int)event.getX(); 
      int Y = (int)event.getY(); 
      fingerX = X; 
      fingerY = Y; 

      switch (eventaction) { 

      case MotionEvent.ACTION_DOWN: 
       if (okayButton){ 
        if (fingerX > 323 && fingerX < 423) { 
         largeOkayButton = true; 
        } 
       } 
       break; 

      case MotionEvent.ACTION_MOVE: 
       break; 

      case MotionEvent.ACTION_UP: 
       tutorial = true; 
       if (startActivity){ 
        //create an Intent variable titled openStartingPoint and pass its activity action from the Android Manifest.xml 
        Intent MainActivity = new Intent("com.example.shoottoiletpaper.MAINACTIVITY"); 
        //start a new activity by passing the newly created Intent 

        startActivity(MainActivity); 
       } 
       break; 
      } 
     return true; 
    } 

一切正常,直到它到達啓動activity,當它強行關閉,我得到這個在logcat中:

android.content.ActivityNotFoundException: No Activity found to handle Intent 

這裏是manifest的相關部分:

 <activity 
     android:name="com.example.shoottoiletpaper.MainActivity" 
     android:screenOrientation="landscape" 
     android:configChanges="orientation|keyboard" 
     android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAINACTIVITY" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 

有什麼建議嗎?

回答

0

更改此

Intent MainActivity = new Intent("com.example.shoottoiletpaper.MAINACTIVITY"); 

Intent MainActivity = new Intent("android.intent.action.MAINACTIVITY"); 
+0

非常感謝你,這固定它。有時,它是簡單的事情是最困難的! – user1956807 2013-03-20 23:10:20

0

變化

<action android:name="android.intent.action.MAINACTIVITY" /> 

<action android:name="android.intent.action.MAIN" /> 
0

你的主要活動的課程名是什麼?如果它不是MAINACTIVITY,那麼你會犯一個錯字。

變化

Intent MainActivity = new Intent("com.example.shoottoiletpaper.MAINACTIVITY"); 

Intent MainActivity = new Intent(this,MainActivity.class); 

(或任何你的主要業務是所謂的)。在Java中,案例很重要。

然後看看你的清單。 (請看例子here

你應該改變你的行改爲

<action android:name="android.intent.action.MAIN"/> 
相關問題