0

我已经研究了一个小时,但我无法弄清楚这个问题。activitybooleantrueACTION_UPTouchEvent 中时,我试图启动一个新的。

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>

有任何想法吗?

4

3 回答 3

0

您的主要活动的班级名称是什么?如果它不是 MAINACTIVITY,那你就打错了。

改变

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

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

(或任何你的主要活动被称为)。大小写在 Java 中很重要。

并查看您的清单。(看这里的例子。

你应该改变你的行来阅读

 <action android:name="android.intent.action.MAIN"/>
于 2013-03-20T03:19:13.050 回答
0

改变

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

<action android:name="android.intent.action.MAIN" />
于 2013-03-20T02:54:01.223 回答
0

改变这个

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

Intent MainActivity = new Intent("android.intent.action.MAINACTIVITY");
于 2013-03-20T02:54:06.323 回答