android:无法启动活动组件信息

android:无法启动活动组件信息,android,android-intent,android-activity,Android,Android Intent,Android Activity,当我开始打算进行下一项活动时。我得到了上面的错误。我无法转到下一个活动(请参阅下面的SecondActivity.java) 我的主要活动是: package com.example.testflashfile; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import android.app.Activity; import android.cont

当我开始打算进行下一项活动时。我得到了上面的错误。我无法转到下一个活动(请参阅下面的SecondActivity.java)

我的主要活动是:

package com.example.testflashfile;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;
import android.view.MotionEvent;


public class MainActivity extends Activity
{
    Button nextButton;
    Button playButton;
    private static final int SWIPE_MIN_DISTANCE = 120;
    private static final int SWIPE_MAX_OFF_PATH = 250;
    private static final int SWIPE_THRESHOLD_VELOCITY = 200;

    GestureDetector gestureDetector;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
        setContentView(R.layout.activity_main);

        gestureDetector = new GestureDetector(this.getApplicationContext(),new MyGestureDetector());
        View mainview = (View) findViewById(R.id.mainView);

        // Set the touch listener for the main view to be our custom gesture listener
        mainview.setOnTouchListener(new View.OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
                if (gestureDetector.onTouchEvent(event)) {
                    return true;
                }
                return false;
            }
        });


        playButton=(Button)findViewById(R.id.play);
        playButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent startAnimation=new Intent(MainActivity.this,PlayAnimationActivity.class);
                startAnimation.putExtra("SWF_NAME","a");
                startActivity(startAnimation);
            }
        });


        TextView helloTxt = (TextView)findViewById(R.id.displaytext);
        helloTxt.setText(readTxt());
        nextButton=(Button)findViewById(R.id.next);
        nextButton.setOnClickListener(new OnClickListener() {


            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent intent=new Intent(MainActivity.this,SecondActivity.class);
                startActivity(intent);

            }
        });


    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }


    private String readTxt(){

        InputStream inputStream = getResources().openRawResource(R.raw.textone);

        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

        int i;
        try {
            i = inputStream.read();
            while (i != -1)
            {
                byteArrayOutputStream.write(i);
                i = inputStream.read();
            }

            inputStream.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return byteArrayOutputStream.toString();
    } 



    class MyGestureDetector extends SimpleOnGestureListener 
    {


        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {


            if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) {
                return false;
            }

            // right to left swipe
            if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {

                Intent i= new Intent(MainActivity.this,SecondActivity.class);
                startActivity(i);

                //  left to right  swipe
            }  else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {


                Intent i= new Intent(MainActivity.this,FifthActivity.class);
                startActivity(i);

            }

            return false;
        }


        @Override
        public boolean onDown(MotionEvent e) {
            return true;
        }



    }

}
第二项活动如下:

package com.example.testflashfile;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.GestureDetector;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;



public class SecondActivity extends Activity {

    Button nextButton2;
    Button backButton2;
    Button playButton2;
    private static final int SWIPE_MIN_DISTANCE = 120;
    private static final int SWIPE_MAX_OFF_PATH = 250;
    private static final int SWIPE_THRESHOLD_VELOCITY = 200;
    GestureDetector gestureDetector; 

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
        setContentView(R.layout.second);

        gestureDetector = new GestureDetector(this.getApplicationContext(),new MyGestureDetector());
        View mainview = (View) findViewById(R.id.mainView);

        // Set the touch listener for the main view to be our custom gesture listener
        mainview.setOnTouchListener(new View.OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
                if (gestureDetector.onTouchEvent(event)) {
                    return true;
                }
                return false;
            }
        });


        TextView helloTxt = (TextView)findViewById(R.id.displaytexttwo);
        helloTxt.setText(readTxt());
        nextButton2=(Button)findViewById(R.id.nexttwo);
        nextButton2.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent intent=new Intent(SecondActivity.this,ThirdActivity.class);
                startActivity(intent);

            }
        });

        playButton2=(Button)findViewById(R.id.play);
        playButton2.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent startAnimation=new Intent(SecondActivity.this,PlayAnimationActivity.class);
                startAnimation.putExtra("SWF_NAME","b");
                startActivity(startAnimation);
            }
        });

        backButton2=(Button)findViewById(R.id.backtwo);
        backButton2.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent intent=new Intent(SecondActivity.this,MainActivity.class);
                startActivity(intent);

            }
        });


    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }



    private String readTxt(){

        InputStream inputStream = getResources().openRawResource(R.raw.texttwo);

        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

        int i;
        try {
            i = inputStream.read();
            while (i != -1)
            {
                byteArrayOutputStream.write(i);
                i = inputStream.read();
            }
            inputStream.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return byteArrayOutputStream.toString();
    }


    class MyGestureDetector extends SimpleOnGestureListener 
    {


        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {


            if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) {
                return false;
            }

            // right to left swipe
            if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {

                Intent i= new Intent(SecondActivity.this,ThirdActivity.class);
                startActivity(i);

                //  left to right  swipe
            }  else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {


                Intent i= new Intent(SecondActivity.this,MainActivity.class);
                startActivity(i);

            }

            return false;
        }


        @Override
        public boolean onDown(MotionEvent e) {
            return true;
        }



    }
}
我不明白这里哪里出了问题。我已经检查了与此错误相关的堆栈溢出的类似线程。但解释并不那么清楚。欢迎提供任何帮助/建议。提前感谢您抽出时间阅读这么长的帖子

原木类别为:

03-11 10:03:18.599: D/dalvikvm(336): GC_EXTERNAL_ALLOC freed 66K, 52% free 2585K/5379K, external 2032K/2137K, paused 92ms
03-11 10:03:18.729: D/AndroidRuntime(336): Shutting down VM
03-11 10:03:18.729: W/dalvikvm(336): threadid=1: thread exiting with uncaught exception (group=0x40015560)
03-11 10:03:18.749: E/AndroidRuntime(336): FATAL EXCEPTION: main
03-11 10:03:18.749: E/AndroidRuntime(336): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testflashfile/com.example.testflashfile.SecondActivity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
03-11 10:03:18.749: E/AndroidRuntime(336):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
03-11 10:03:18.749: E/AndroidRuntime(336):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
03-11 10:03:18.749: E/AndroidRuntime(336):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-11 10:03:18.749: E/AndroidRuntime(336):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
03-11 10:03:18.749: E/AndroidRuntime(336):  at android.os.Handler.dispatchMessage(Handler.java:99)
03-11 10:03:18.749: E/AndroidRuntime(336):  at android.os.Looper.loop(Looper.java:123)
03-11 10:03:18.749: E/AndroidRuntime(336):  at android.app.ActivityThread.main(ActivityThread.java:3683)
03-11 10:03:18.749: E/AndroidRuntime(336):  at java.lang.reflect.Method.invokeNative(Native Method)
03-11 10:03:18.749: E/AndroidRuntime(336):  at java.lang.reflect.Method.invoke(Method.java:507)
03-11 10:03:18.749: E/AndroidRuntime(336):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-11 10:03:18.749: E/AndroidRuntime(336):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-11 10:03:18.749: E/AndroidRuntime(336):  at dalvik.system.NativeStart.main(Native Method)
03-11 10:03:18.749: E/AndroidRuntime(336): Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
03-11 10:03:18.749: E/AndroidRuntime(336):  at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:181)
03-11 10:03:18.749: E/AndroidRuntime(336):  at android.app.Activity.requestWindowFeature(Activity.java:2729)
03-11 10:03:18.749: E/AndroidRuntime(336):  at com.example.testflashfile.SecondActivity.onCreate(SecondActivity.java:35)
03-11 10:03:18.749: E/AndroidRuntime(336):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-11 10:03:18.749: E/AndroidRuntime(336):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
03-11 10:03:18.749: E/AndroidRuntime(336):  ... 11 more
03-11 10:03:21.539: I/Process(336): Sending signal. PID: 336 SIG: 9
03-11 12:37:51.179: D/dalvikvm(382): GC_EXTERNAL_ALLOC freed 67K, 53% free 2581K/5379K, external 2032K/2137K, paused 199ms
03-11 12:37:51.478: D/AndroidRuntime(382): Shutting down VM
03-11 12:37:51.479: W/dalvikvm(382): threadid=1: thread exiting with uncaught exception (group=0x40015560)
03-11 12:37:51.722: E/AndroidRuntime(382): FATAL EXCEPTION: main
03-11 12:37:51.722: E/AndroidRuntime(382): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testflashfile/com.example.testflashfile.SecondActivity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
03-11 12:37:51.722: E/AndroidRuntime(382):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
03-11 12:37:51.722: E/AndroidRuntime(382):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
03-11 12:37:51.722: E/AndroidRuntime(382):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-11 12:37:51.722: E/AndroidRuntime(382):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
03-11 12:37:51.722: E/AndroidRuntime(382):  at android.os.Handler.dispatchMessage(Handler.java:99)
03-11 12:37:51.722: E/AndroidRuntime(382):  at android.os.Looper.loop(Looper.java:123)
03-11 12:37:51.722: E/AndroidRuntime(382):  at android.app.ActivityThread.main(ActivityThread.java:3683)
03-11 12:37:51.722: E/AndroidRuntime(382):  at java.lang.reflect.Method.invokeNative(Native Method)
03-11 12:37:51.722: E/AndroidRuntime(382):  at java.lang.reflect.Method.invoke(Method.java:507)
03-11 12:37:51.722: E/AndroidRuntime(382):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-11 12:37:51.722: E/AndroidRuntime(382):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-11 12:37:51.722: E/AndroidRuntime(382):  at dalvik.system.NativeStart.main(Native Method)
03-11 12:37:51.722: E/AndroidRuntime(382): Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
03-11 12:37:51.722: E/AndroidRuntime(382):  at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:181)
03-11 12:37:51.722: E/AndroidRuntime(382):  at android.app.Activity.requestWindowFeature(Activity.java:2729)
03-11 12:37:51.722: E/AndroidRuntime(382):  at com.example.testflashfile.SecondActivity.onCreate(SecondActivity.java:35)
03-11 12:37:51.722: E/AndroidRuntime(382):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-11 12:37:51.722: E/AndroidRuntime(382):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
03-11 12:37:51.722: E/AndroidRuntime(382):  ... 11 more
03-11 12:37:57.159: I/Process(382): Sending signal. PID: 382 SIG: 9
03-11 12:40:41.579: W/ActivityThread(418): Application com.example.testflashfile is waiting for the debugger on port 8100...
03-11 12:40:41.649: I/System.out(418): Sending WAIT chunk
03-11 12:40:42.381: I/dalvikvm(418): Debugger is active
03-11 12:40:42.499: I/System.out(418): Debugger has connected
03-11 12:40:42.499: I/System.out(418): waiting for debugger to settle...
03-11 12:40:42.703: I/System.out(418): waiting for debugger to settle...
03-11 12:40:43.011: I/System.out(418): waiting for debugger to settle...
03-11 12:40:43.209: I/System.out(418): waiting for debugger to settle...
03-11 12:40:43.419: I/System.out(418): waiting for debugger to settle...
03-11 12:40:43.619: I/System.out(418): waiting for debugger to settle...
03-11 12:40:43.869: I/System.out(418): waiting for debugger to settle...
03-11 12:40:44.070: I/System.out(418): waiting for debugger to settle...
03-11 12:40:44.269: I/System.out(418): waiting for debugger to settle...
03-11 12:40:44.469: I/System.out(418): waiting for debugger to settle...
03-11 12:40:44.720: I/System.out(418): waiting for debugger to settle...
03-11 12:40:44.925: I/System.out(418): waiting for debugger to settle...
03-11 12:40:45.140: I/System.out(418): waiting for debugger to settle...
03-11 12:40:45.339: I/System.out(418): waiting for debugger to settle...
03-11 12:40:45.559: I/System.out(418): waiting for debugger to settle...
03-11 12:40:45.793: I/System.out(418): waiting for debugger to settle...
03-11 12:40:46.031: I/System.out(418): waiting for debugger to settle...
03-11 12:40:46.261: I/System.out(418): waiting for debugger to settle...
03-11 12:40:46.468: I/System.out(418): waiting for debugger to settle...
03-11 12:40:46.669: I/System.out(418): waiting for debugger to settle...
03-11 12:40:46.875: I/System.out(418): waiting for debugger to settle...
03-11 12:40:47.109: I/System.out(418): debugger has settled (1505)
03-11 12:49:24.089: D/dalvikvm(418): GC_EXTERNAL_ALLOC freed 68K, 52% free 2583K/5379K, external 2032K/2137K, paused 212ms
03-11 12:51:01.819: D/AndroidRuntime(418): Shutting down VM
03-11 12:51:01.839: W/dalvikvm(418): threadid=1: thread exiting with uncaught exception (group=0x40015560)
03-11 12:51:07.499: E/AndroidRuntime(418): FATAL EXCEPTION: main
03-11 12:51:07.499: E/AndroidRuntime(418): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testflashfile/com.example.testflashfile.SecondActivity}: java.lang.NullPointerException
03-11 12:51:07.499: E/AndroidRuntime(418):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
03-11 12:51:07.499: E/AndroidRuntime(418):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
03-11 12:51:07.499: E/AndroidRuntime(418):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-11 12:51:07.499: E/AndroidRuntime(418):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
03-11 12:51:07.499: E/AndroidRuntime(418):  at android.os.Handler.dispatchMessage(Handler.java:99)
03-11 12:51:07.499: E/AndroidRuntime(418):  at android.os.Looper.loop(Looper.java:123)
03-11 12:51:07.499: E/AndroidRuntime(418):  at android.app.ActivityThread.main(ActivityThread.java:3683)
03-11 12:51:07.499: E/AndroidRuntime(418):  at java.lang.reflect.Method.invokeNative(Native Method)
03-11 12:51:07.499: E/AndroidRuntime(418):  at java.lang.reflect.Method.invoke(Method.java:507)
03-11 12:51:07.499: E/AndroidRuntime(418):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-11 12:51:07.499: E/AndroidRuntime(418):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-11 12:51:07.499: E/AndroidRuntime(418):  at dalvik.system.NativeStart.main(Native Method)
03-11 12:51:07.499: E/AndroidRuntime(418): Caused by: java.lang.NullPointerException
03-11 12:51:07.499: E/AndroidRuntime(418):  at com.example.testflashfile.SecondActivity.onCreate(SecondActivity.java:69)
03-11 12:51:07.499: E/AndroidRuntime(418):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-11 12:51:07.499: E/AndroidRuntime(418):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
03-11 12:51:07.499: E/AndroidRuntime(418):  ... 11 more
03-11 12:56:07.749: I/Process(418): Sending signal. PID: 418 SIG: 9
03-11 14:17:47.570: D/dalvikvm(457): GC_EXTERNAL_ALLOC freed 68K, 53% free 2581K/5379K, external 2032K/2137K, paused 116ms
03-11 14:17:47.699: D/AndroidRuntime(457): Shutting down VM
03-11 14:17:47.699: W/dalvikvm(457): threadid=1: thread exiting with uncaught exception (group=0x40015560)
03-11 14:17:47.729: E/AndroidRuntime(457): FATAL EXCEPTION: main
03-11 14:17:47.729: E/AndroidRuntime(457): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testflashfile/com.example.testflashfile.SecondActivity}: java.lang.NullPointerException
03-11 14:17:47.729: E/AndroidRuntime(457):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
03-11 14:17:47.729: E/AndroidRuntime(457):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
03-11 14:17:47.729: E/AndroidRuntime(457):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-11 14:17:47.729: E/AndroidRuntime(457):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
03-11 14:17:47.729: E/AndroidRuntime(457):  at android.os.Handler.dispatchMessage(Handler.java:99)
03-11 14:17:47.729: E/AndroidRuntime(457):  at android.os.Looper.loop(Looper.java:123)
03-11 14:17:47.729: E/AndroidRuntime(457):  at android.app.ActivityThread.main(ActivityThread.java:3683)
03-11 14:17:47.729: E/AndroidRuntime(457):  at java.lang.reflect.Method.invokeNative(Native Method)
03-11 14:17:47.729: E/AndroidRuntime(457):  at java.lang.reflect.Method.invoke(Method.java:507)
03-11 14:17:47.729: E/AndroidRuntime(457):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-11 14:17:47.729: E/AndroidRuntime(457):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-11 14:17:47.729: E/AndroidRuntime(457):  at dalvik.system.NativeStart.main(Native Method)
03-11 14:17:47.729: E/AndroidRuntime(457): Caused by: java.lang.NullPointerException
03-11 14:17:47.729: E/AndroidRuntime(457):  at com.example.testflashfile.SecondActivity.onCreate(SecondActivity.java:44)
03-11 14:17:47.729: E/AndroidRuntime(457):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-11 14:17:47.729: E/AndroidRuntime(457):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
03-11 14:17:47.729: E/AndroidRuntime(457):  ... 11 more
舱单是:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.testflashfile"
    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"
        android:hardwareAccelerated="true" 
        android:debuggable="true">
        <activity
            android:screenOrientation="portrait"
            android:name="com.example.testflashfile.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.example.testflashfile.SecondActivity"
            android:screenOrientation="portrait"></activity>
         <activity android:name="com.example.testflashfile.ThirdActivity"
             android:screenOrientation="portrait"></activity>
          <activity android:name="com.example.testflashfile.FourthActivity"
              android:screenOrientation="portrait"></activity>
          <activity android:name="com.example.testflashfile.FifthActivity"
              android:screenOrientation="portrait"></activity>

<activity android:name="com.example.testflashfile.PlayAnimationActivity"
               android:screenOrientation="portrait"></activity>

    </application>

</manifest>

删除
清单中第二个活动的标签中的'screenOrientation=“Picture'。在调用请求…方法之前,您已经设置了活动的方向属性。

大家好,我的问题解决了。但我似乎无法确定我的代码到底哪里错了。但我想向大家介绍一下我的工作原理(可能有比这更好的解决方案。请随时编辑此帖子)

以下是我现在的主要活动:

package com.example.testflashfile;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;
import android.view.MotionEvent;
import com.example.testflashfile.GlobalVariables;


public class MainActivity extends Activity
{
    Button nextButton;
    Button playButton;
    Button backButton;


    GestureDetector gestureDetector;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
        setContentView(R.layout.activity_main);

        TextView helloTxt = (TextView)findViewById(R.id.displaytext);
        helloTxt.setText(readTxt());


        gestureDetector = new GestureDetector(this.getApplicationContext(),new MyGestureDetector());
        View mainview = (View) findViewById(R.id.mainView);

        // Set the touch listener for the main view to be our custom gesture listener
        mainview.setOnTouchListener(new View.OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
                if (gestureDetector.onTouchEvent(event)) {
                    return true;
                }
                return false;
            }
        });


        playButton=(Button)findViewById(R.id.play);
        playButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent startAnimation=new Intent(MainActivity.this,PlayAnimationActivity.class);
                startAnimation.putExtra("SWF_NAME","a");
                startActivity(startAnimation);
            }
        });



        nextButton=(Button)findViewById(R.id.next);
        nextButton.setOnClickListener(new OnClickListener() {


            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent intent=new Intent(MainActivity.this,SecondActivity.class);
                startActivity(intent);

            }
        });

        backButton=(Button)findViewById(R.id.back);
        backButton.setOnClickListener(new OnClickListener() {


            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent intent=new Intent(MainActivity.this,FifthActivity.class);
                startActivity(intent);

            }
        });


    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }


    private String readTxt(){

        InputStream inputStream = getResources().openRawResource(R.raw.textone);

        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

        int i;
        try {
            i = inputStream.read();
            while (i != -1)
            {
                byteArrayOutputStream.write(i);
                i = inputStream.read();
            }

            inputStream.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return byteArrayOutputStream.toString();
    } 



    public class MyGestureDetector extends SimpleOnGestureListener
    {


        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {


            if (Math.abs(e1.getY() - e2.getY()) > GlobalVariables.SWIPE_MAX_OFF_PATH) {
                return false;
            }

            // right to left swipe
            if(e1.getX() - e2.getX() > GlobalVariables.SWIPE_MIN_DISTANCE && Math.abs(velocityX) > GlobalVariables.SWIPE_THRESHOLD_VELOCITY) {

                Intent i= new Intent(MainActivity.this,SecondActivity.class);
                startActivity(i);

                //  left to right  swipe
            }  else if (e2.getX() - e1.getX() > GlobalVariables.SWIPE_MIN_DISTANCE && Math.abs(velocityX) > GlobalVariables.SWIPE_THRESHOLD_VELOCITY) {


                Intent i= new Intent(MainActivity.this,FifthActivity.class);
                startActivity(i);

            }

            return false;
        }


        @Override
        public boolean onDown(MotionEvent e) {
            return true;
        }



    }

}
以下是第二项活动:

package com.example.testflashfile;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;



import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.GestureDetector;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;


public class SecondActivity extends Activity
{
    Button nextButton,backButton,playButton;
    GestureDetector gestureDetector;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.second);

        TextView helloTxt = (TextView)findViewById(R.id.displaytexttwo);
        helloTxt.setText(readTxt());


        gestureDetector = new GestureDetector(this.getApplicationContext(),new MyGestureDetector());
        View mainview = (View) findViewById(R.id.mainViewtwo);

        // Set the touch listener for the main view to be our custom gesture listener
        mainview.setOnTouchListener(new View.OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
                if (gestureDetector.onTouchEvent(event)) {
                    return true;
                }
                return false;
            }
        });


        playButton=(Button)findViewById(R.id.playtwo);
        playButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent startAnimation=new Intent(SecondActivity.this,PlayAnimationActivity.class);
                startAnimation.putExtra("SWF_NAME","b");
                startActivity(startAnimation);
            }
        });



        nextButton=(Button)findViewById(R.id.nexttwo);
        nextButton.setOnClickListener(new OnClickListener() {


            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent intent=new Intent(SecondActivity.this,ThirdActivity.class);
                startActivity(intent);

            }
        });

        backButton=(Button)findViewById(R.id.backtwo);
        backButton.setOnClickListener(new OnClickListener() {


            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent intent=new Intent(SecondActivity.this,MainActivity.class);
                startActivity(intent);

            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }


    private String readTxt(){

        InputStream inputStream = getResources().openRawResource(R.raw.texttwo);

        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

        int i;
        try {
            i = inputStream.read();
            while (i != -1)
            {
                byteArrayOutputStream.write(i);
                i = inputStream.read();
            }

            inputStream.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return byteArrayOutputStream.toString();
    } 

    public class MyGestureDetector extends SimpleOnGestureListener
    {


        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {


            if (Math.abs(e1.getY() - e2.getY()) > GlobalVariables.SWIPE_MAX_OFF_PATH) {
                return false;
            }

            // right to left swipe
            if(e1.getX() - e2.getX() > GlobalVariables.SWIPE_MIN_DISTANCE && Math.abs(velocityX) > GlobalVariables.SWIPE_THRESHOLD_VELOCITY) {

                Intent i= new Intent(SecondActivity.this,ThirdActivity.class);
                startActivity(i);

                //  left to right  swipe
            }  else if (e2.getX() - e1.getX() > GlobalVariables.SWIPE_MIN_DISTANCE && Math.abs(velocityX) > GlobalVariables.SWIPE_THRESHOLD_VELOCITY) {


                Intent i= new Intent(SecondActivity.this,MainActivity.class);
                startActivity(i);

            }

            return false;
        }


        @Override
        public boolean onDown(MotionEvent e) {
            return true;
        }

    }
}
我为我的活动创建了一个全局变量类,因为它们在swipe方法中使用相同的变量

包com.example.testflashfile

公共类全局变量{

static final int SWIPE_MIN_DISTANCE = 120;
static final int SWIPE_MAX_OFF_PATH = 250;
static final int SWIPE_THRESHOLD_VELOCITY = 200;
}

这一变化不知怎么解决了我的问题。我仍然不知道如何解决。但这就是成功的原因

我想知道这项工作背后的真正原因是什么。现在代码可以工作了,我正在继续


谢谢大家的帮助和指点。

请发布完整的日志猫输出。这是您在AndroidManifest.xml中标记的第二个活动?请发布日志猫和清单。是的,清单中提到了它。我以前使用过意图。这是我第一次面对这个问题。日志猫和清单已发布@sebastianManifest is我认为这段代码有什么作用?它给了我错误,比如“令牌“void”上的语法错误,@expected”这不是错误。但是我按照你说的做了。它仍然给我同样的错误。