phoneGap 本机应用程序中的 Android 手机旋转问题
我对 Java android 开发很陌生。所以我的应用程序有问题。
我正在使用phoneGap开源和Jquery移动框架构建一个Android应用程序。 正常工作时看起来不错。
但问题是......当我在运行应用程序后尝试旋转手机时,应用程序意外关闭。
这不仅适用于我的手机,它也发生在每部 Android 手机上。
我真的很想删除应用程序上的屏幕旋转。
希望你能理解
请帮助我......
I'm quite new in Java android development. So I have an issue with my app.
I was build a android app with phoneGap opensource and Jquery mobile framework.
That's looking good normally working.
But the issue is.... when I'm trying to rotate the phone after running the app, then unexpectedly the app is closing.
It's not only for my phone it's happening on every android phone.
I really want to remove the screen rotation on the app.
Hope you understand
Help me please....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
我可能遇到了同样的问题 - 旋转时崩溃。我认为我没有直接从教程中复制 AndroidManifest.xml。我没有添加
到第一个活动中。请参阅我的前后对比:
之后(工作):
之前(旋转时崩溃):
不确定您是否真的想修复屏幕或阻止其崩溃,但如果您想修复纵向或横向,您可以执行以下操作:
I had probably the same issue - crash on rotate. I dont think I had the AndroidManifest.xml copied right from the tutorial. I didnt add
to the 1st activity. See my after and before:
After (working):
Before (crash on rotate):
Not sure if you really want to fix the screen or stop it crashing but if you want to fix portrait or landscape you can do this:
您必须在主页中使用以下 js。
这对我有用,无需在 manifest.xml 中执行任何操作
You have to use the following js in your main page.
That works for me without doing anything in the manifest.xml
我也有同样的问题。我正在使用
android:minSdkVersion="8"
和android:targetSdkVersion="16"
开发 PhoneGap 应用程序。当我尝试将screenSize
添加到android:configChanges
时,它说screenSize
不存在。然后我减少了 targetSdkVersion ,一切都开始完美运行。这是我的清单文件I had the same problem. I was developing PhoneGap application with
android:minSdkVersion="8"
andandroid:targetSdkVersion="16"
. When I tried to addscreenSize
toandroid:configChanges
it says thatscreenSize
does not exist. Then I reduced thetargetSdkVersion
and everything starts working perfectly. This is my manifest file我认为你的问题与任何特定框架无关;您很可能引用了一些无效的实例。请记住,方向更改会导致系统经历以下过程:保存实例状态、暂停、停止、销毁,然后使用保存的状态创建活动的新实例。因此,例如,如果您保存对某个实例的引用,那么在方向更改后,该引用将不再有效(可能为空)。
您应该尝试修复它,请查看此参考。但是,如果您确实不想允许屏幕方向更改,请将以下属性添加到清单文件中的主要活动中:
I think your problem has nothing to do with any specific framework; most likely you reference some invalid instance. Bear in mind that an orientation change causes the system to go through the process of saving instance state, pausing, stopping, destroying, and then creating a new instance of the activity with the saved state. So if you - for example, save a reference to some instance, then after an orientation change the reference is not valid any more (probably null).
You should try to fix it, check this reference. But if you really don't want to allow screen orientation changes, then add following property to your main activity in the manifest file:
如果您正在针对 Android API 13 或更高版本进行开发,则需要将 screenSize 添加到 android:configChanges 以防止崩溃。像这样:
在这里找到这个:
https://groups.google.com/forum/?fromgroups#!msg/phonegap/HYUfLJF1oH0/r9rZTfz_cccJ
If you are developing for Android API 13 or higher you need to add screenSize to android:configChanges in order to prevent a crash. Like this:
Found this here:
https://groups.google.com/forum/?fromgroups#!msg/phonegap/HYUfLJF1oH0/r9rZTfz_cccJ
我遇到了同样的问题。当我从纵向切换到横向或从横向切换到纵向时,该应用程序死机了。没有理由。
我检查了
android:configChanges="orientation|keyboardHidden"
并添加了屏幕尺寸,但没有更改。我做了很多改变。我最终取消了该行并重写了它,它成功了。
我认为该行存在 Eclipse 编辑器未发现且不可见的问题。原始行是从phonegap 安装中复制/粘贴的。
I ran though the same problem. The app died when I moved from portrait to landscape or landscape to portrait. No reason.
I checked the
android:configChanges="orientation|keyboardHidden"
and added the screensize but no change.I made so many changes. I finally cancelled the line and rewrote it and it worked.
I think the line had a problem not seen by the Eclipse editor and not visible. The original line was a copy/paste from the phonegap installation.
我遇到了同样的问题。但我的 android:configChanges 设置正确。最后我发现我需要将miniSdkVersion从15更改为7。
I met the same problem. But my android:configChanges was set correctly. In the end I found that I need to change the miniSdkVersion from 15 to 7.