Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 旋转移动时应用程序停止时出错_Android_Android Manifest_Android Mediaplayer_Playback - Fatal编程技术网

Android 旋转移动时应用程序停止时出错

Android 旋转移动时应用程序停止时出错,android,android-manifest,android-mediaplayer,playback,Android,Android Manifest,Android Mediaplayer,Playback,我是android应用程序的初学者。我创建了我的第一个应用程序,从res目录下的Raw文件夹播放声音。我的代码编写得很好,运行得很好,然后我继续停止播放声音。我这样做了,但当我旋转手机或puss mobile back按钮时,错误应用程序停止了……。我怎样才能解决这个问题 在清单中,执行以下更改 <activity android:name=".EULAActivity" android:theme="@android:style/Theme.Translucent" android:

我是android应用程序的初学者。我创建了我的第一个应用程序,从res目录下的Raw文件夹播放声音。我的代码编写得很好,运行得很好,然后我继续停止播放声音。我这样做了,但当我旋转手机或puss mobile back按钮时,错误应用程序停止了……。我怎样才能解决这个问题


在清单中,执行以下更改

<activity android:name=".EULAActivity"
android:theme="@android:style/Theme.Translucent"
android:configChanges="keyboard|keyboardHidden|orientation" />

android:configChanges is the attribute, you need to use in your application.

android:configChanges是您需要在应用程序中使用的属性。
试试这段代码

在over onCreate()override onBackPressed()之后将其放入类文件中

并将以下属性与活动寄存器一起放入AndroidManifest.xml文件中

android:screenOrientation="portrait"

根据您的要求,如果您需要screenpotrait/scape

变量
mp
必须设置为适当的值(好的地方是
onCreate()
onResume()
),然后才能使用它(就像在
onPause()
中发生的那样)

logcat中是否有错误消息(可能)?请张贴错误日志:)他已经用过了
android:configChanges=“orientation | keyboardHidden”
好的。。。我没有注意到,在这种情况下,无论何时更改方向,都必须有任何例外。按mobile back按钮时发生错误“应用程序停止…”。我需要应用程序在两个方向上工作,而不仅仅是在menifest.xml文件中需要安卓:configChanges=“orientation”
06-27 17:57:59.422: E/Trace(636): error opening trace file: No such file or directory (2)
06-27 17:58:00.452: I/Choreographer(636): Skipped 31 frames!  The application may be doing too much work on its main thread.
06-27 17:58:00.492: D/gralloc_goldfish(636): Emulator without GPU emulation detected.
06-27 17:58:00.992: I/Choreographer(636): Skipped 74 frames!  The application may be doing too much work on its main thread.
06-27 17:58:02.432: D/dalvikvm(636): GC_CONCURRENT freed 115K, 3% free 8346K/8519K, paused 6ms+27ms, total 112ms
06-27 17:58:02.432: D/dalvikvm(636): WAIT_FOR_CONCURRENT_GC blocked 67ms
06-27 17:58:08.902: D/AndroidRuntime(636): Shutting down VM
06-27 17:58:08.902: W/dalvikvm(636): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
06-27 17:58:08.982: E/AndroidRuntime(636): FATAL EXCEPTION: main
06-27 17:58:08.982: E/AndroidRuntime(636): java.lang.RuntimeException: Unable to pause activity {com.ramadan/com.ramadan.Ramadan}: java.lang.NullPointerException
06-27 17:58:08.982: E/AndroidRuntime(636):  at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2838)
06-27 17:58:08.982: E/AndroidRuntime(636):  at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2794)
06-27 17:58:08.982: E/AndroidRuntime(636):  at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:2772)
06-27 17:58:08.982: E/AndroidRuntime(636):  at android.app.ActivityThread.access$800(ActivityThread.java:130)
06-27 17:58:08.982: E/AndroidRuntime(636):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1212)
06-27 17:58:08.982: E/AndroidRuntime(636):  at android.os.Handler.dispatchMessage(Handler.java:99)
06-27 17:58:08.982: E/AndroidRuntime(636):  at android.os.Looper.loop(Looper.java:137)
06-27 17:58:08.982: E/AndroidRuntime(636):  at android.app.ActivityThread.main(ActivityThread.java:4745)
06-27 17:58:08.982: E/AndroidRuntime(636):  at java.lang.reflect.Method.invokeNative(Native Method)
06-27 17:58:08.982: E/AndroidRuntime(636):  at java.lang.reflect.Method.invoke(Method.java:511)
06-27 17:58:08.982: E/AndroidRuntime(636):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
06-27 17:58:08.982: E/AndroidRuntime(636):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
06-27 17:58:08.982: E/AndroidRuntime(636):  at dalvik.system.NativeStart.main(Native Method)
06-27 17:58:08.982: E/AndroidRuntime(636): Caused by: java.lang.NullPointerException
06-27 17:58:08.982: E/AndroidRuntime(636):  at com.ramadan.Ramadan.onPause(Ramadan.java:152)
06-27 17:58:08.982: E/AndroidRuntime(636):  at android.app.Activity.performPause(Activity.java:5106)
06-27 17:58:08.982: E/AndroidRuntime(636):  at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1225)
06-27 17:58:08.982: E/AndroidRuntime(636):  at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2825)
06-27 17:58:08.982: E/AndroidRuntime(636):  ... 12 more
06-27 17:58:11.552: I/Process(636): Sending signal. PID: 636 SIG: 9
<activity android:name=".EULAActivity"
android:theme="@android:style/Theme.Translucent"
android:configChanges="keyboard|keyboardHidden|orientation" />

android:configChanges is the attribute, you need to use in your application.
@Override
public void onBackPressed() {
    // TODO Auto-generated method stub
    super.onBackPressed();
    finish();
}
android:screenOrientation="portrait"