即使 AndroidManifest 发生更改,Phonegap 应用程序也会在切换方向时崩溃
这是我的清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mappp.mobile"
android:versionCode="1"
android:versionName="1.0" >
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:resizeable="true"
android:anyDensity="true"
/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.hardware.camera" />
<uses-permission android:name="android.hardware.camera.autofocus" />
<uses-sdk android:minSdkVersion="13" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:debuggable="true"
android:configChanges="orientation|screenSize|keyboardHidden" >
<activity
android:label="@string/app_name"
android:name=".MAppHDActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.phonegap.DroidGap"
android:label="@string/app_name"
android:configChanges="orientation|screenSize|keyboardHidden" >
<intent-filter>
</intent-filter>
</activity>
</application>
</manifest>
我正在使用 Phonegap 1.3.0 和 jquerymobile。
我的测试设备是配备 HC v3.2 的 Samsung Galaxy Tab 8.9。
我几乎读过每个论坛都有同样的问题。当我旋转屏幕时它仍然失败。
应用程序在调试模式下崩溃后立即出现警告:webcore:无法在第一个布局后获取 veiwWidth。
Here's my Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mappp.mobile"
android:versionCode="1"
android:versionName="1.0" >
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:resizeable="true"
android:anyDensity="true"
/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.hardware.camera" />
<uses-permission android:name="android.hardware.camera.autofocus" />
<uses-sdk android:minSdkVersion="13" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:debuggable="true"
android:configChanges="orientation|screenSize|keyboardHidden" >
<activity
android:label="@string/app_name"
android:name=".MAppHDActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.phonegap.DroidGap"
android:label="@string/app_name"
android:configChanges="orientation|screenSize|keyboardHidden" >
<intent-filter>
</intent-filter>
</activity>
</application>
</manifest>
I'm using Phonegap 1.3.0 and jquerymobile.
My test device is a Samsung Galaxy Tab 8.9 with HC v3.2.
I've read ALMOST every forum with the same issue. It still fails when i rotate the screen.
There's a warning right after the app crashes in debug mode: webcore: Can't get the veiwWidth after the first layout.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在您的情况下,属性
android:configChanges="orientation|screenSize|keyboardHidden"
应转到第一个
标记,而不是。
标签。对于遇到类似问题的其他人,只需将
screenSize
添加到android:configChanges="orientation|keyboardHidden"
或将android:minSdkVersion
属性更改为 12或更低。有关此行为的更详细说明,请访问:http://groups.google.com /group/phonegap/msg/c771fffc4dd9daaf
In your case the attribute
android:configChanges="orientation|screenSize|keyboardHidden"
should go to the first<activity>
tag and not the<application>
tag.For the other people having similar issues simply add
screenSize
toandroid:configChanges="orientation|keyboardHidden"
or change theandroid:minSdkVersion
attribute to 12 or lower.A more detailed explanation of this behavior can be found here: http://groups.google.com/group/phonegap/msg/c771fffc4dd9daaf
这是我的解决方案
将“screenSize”添加到每个 Activity 标签中的 android:configChanges(在 AnroidManifest.xml 中)。
就像这样:
它解决了我的问题。
Here's my solution
Add "screenSize" to the android:configChanges in each Activity tag (within the AnroidManifest.xml).
Like this:
It solved my problem.