PhoneGap/Android中的屏幕方向

PhoneGap/Android中的屏幕方向,android,cordova,orientation,Android,Cordova,Orientation,我目前正在PhoneGap中开发一个小演示,以测试一些功能。我想使用能够从JavaScript动态改变我的屏幕方向,我已经更新了插件以在Cordova中使用它 我现在的问题是,只要我想改变屏幕方向,它就会崩溃。即使我试着做一些简单的事情,比如setRequestedOrientationActivityInfo.SCREEN\u ORIENTATION\u scape;在我的onCreate方法中没有使用PhoneGap,我的应用程序只是使用以下调试日志退出到启动器: 08-20 08:57:1

我目前正在PhoneGap中开发一个小演示,以测试一些功能。我想使用能够从JavaScript动态改变我的屏幕方向,我已经更新了插件以在Cordova中使用它

我现在的问题是,只要我想改变屏幕方向,它就会崩溃。即使我试着做一些简单的事情,比如setRequestedOrientationActivityInfo.SCREEN\u ORIENTATION\u scape;在我的onCreate方法中没有使用PhoneGap,我的应用程序只是使用以下调试日志退出到启动器:

08-20 08:57:17.083: D/DroidGap(21383): DroidGap.onCreate()
08-20 08:57:17.193: D/CordovaWebView(21383): Origin to allow: http://127.0.0.1*
08-20 08:57:17.193: I/CordovaLog(21383): Found log level DEBUG
08-20 08:57:17.193: I/CordovaLog(21383): Changing log level to DEBUG(3)
08-20 08:57:17.193: I/CordovaLog(21383): Found preference for fullscreen=true
08-20 08:57:17.193: D/CordovaLog(21383): Found preference for fullscreen=true
08-20 08:57:17.193: I/CordovaLog(21383): Found preference for useBrowserHistory=false
08-20 08:57:17.193: D/CordovaLog(21383): Found preference for useBrowserHistory=false
08-20 08:57:17.223: D/DroidGap(21383): DroidGap.init()
08-20 08:57:17.223: D/CordovaWebView(21383): >>> loadUrl(file:///android_asset/www/index.html)
08-20 08:57:17.223: D/PluginManager(21383): init()
08-20 08:57:17.233: D/CordovaWebView(21383): >>> loadUrlNow()
08-20 08:57:17.243: D/CordovaWebView(21383): >>> loadUrlNow()
08-20 08:57:17.243: D/DroidGap(21383): onDestroy()
08-20 08:57:17.243: D/CordovaWebView(21383): >>> loadUrlNow()
08-20 08:57:17.243: D/CordovaWebView(21383): >>> loadUrlNow()
08-20 08:57:17.263: D/DroidGap(21383): DroidGap.onCreate()
08-20 08:57:17.263: D/CordovaWebView(21383): Origin to allow: http://127.0.0.1*
08-20 08:57:17.263: I/CordovaLog(21383): Found log level DEBUG
08-20 08:57:17.263: I/CordovaLog(21383): Changing log level to DEBUG(3)
08-20 08:57:17.263: I/CordovaLog(21383): Found preference for fullscreen=true
08-20 08:57:17.263: D/CordovaLog(21383): Found preference for fullscreen=true
08-20 08:57:17.263: I/CordovaLog(21383): Found preference for useBrowserHistory=false
08-20 08:57:17.263: D/CordovaLog(21383): Found preference for useBrowserHistory=false
08-20 08:57:17.273: D/DroidGap(21383): DroidGap.init()
08-20 08:57:17.273: D/CordovaWebView(21383): >>> loadUrl(file:///android_asset/www/index.html)
08-20 08:57:17.273: D/PluginManager(21383): init()
08-20 08:57:17.293: D/CordovaWebView(21383): >>> loadUrlNow()
08-20 08:57:17.313: D/DroidGap(21383): onMessage(onPageStarted,file:///android_asset/www/index.html)
08-20 08:57:17.313: D/SoftKeyboardDetect(21383): Ignore this event
08-20 08:57:17.373: D/SoftKeyboardDetect(21383): Ignore this event
08-20 08:57:17.483: D/Cordova(21383): onPageFinished(file:///android_asset/www/index.html)
08-20 08:57:17.483: D/CordovaWebView(21383): >>> loadUrlNow()
08-20 08:57:17.483: D/DroidGap(21383): onMessage(onNativeReady,null)
08-20 08:57:17.483: D/DroidGap(21383): onMessage(onPageFinished,file:///android_asset/www/index.html)
08-20 08:57:17.483: D/DroidGap(21383): onMessage(onPageStarted,about:blank)
08-20 08:57:17.503: D/dalvikvm(21383): GC_CONCURRENT freed 326K, 9% free 7566K/8263K, paused 8ms+2ms, total 33ms
08-20 08:57:17.513: D/Cordova(21383): onPageFinished(about:blank)
08-20 08:57:17.513: D/DroidGap(21383): onMessage(onPageFinished,about:blank)
08-20 08:57:17.513: D/DroidGap(21383): onMessage(exit,null)
08-20 08:57:17.563: D/DroidGap(21383): onMessage(onPageStarted,file:///android_asset/www/index.html)
08-20 08:57:17.563: D/CordovaWebView(21383): >>> loadUrlNow()
08-20 08:57:18.023: D/Cordova(21383): onPageFinished(file:///android_asset/www/index.html)
08-20 08:57:18.023: D/CordovaWebView(21383): >>> loadUrlNow()
08-20 08:57:18.023: D/DroidGap(21383): onMessage(onNativeReady,null)
08-20 08:57:18.023: D/DroidGap(21383): onMessage(onPageFinished,file:///android_asset/www/index.html)
08-20 08:57:18.053: E/SQLiteLog(21383): (14) cannot open file at line 30174 of [00bb9c9ce4]
08-20 08:57:18.053: E/SQLiteLog(21383): (14) os_unix.c:30174: (2) open(/CachedGeoposition.db) - 
08-20 08:57:18.053: D/WebKit(21383): ERROR: 
08-20 08:57:18.053: D/WebKit(21383): SQLite database failed to load from /CachedGeoposition.db
08-20 08:57:18.053: D/WebKit(21383): Cause - unable to open database file
08-20 08:57:18.053: D/WebKit(21383): external/webkit/Source/WebCore/platform/sql/SQLiteDatabase.cpp(71) : bool WebCore::SQLiteDatabase::open(const WTF::String&, bool)
08-20 08:57:18.143: D/DroidGap(21383): onMessage(networkconnection,wifi)
08-20 08:57:18.183: D/DroidGap(21383): onMessage(spinner,stop)
08-20 08:57:18.223: W/IInputConnectionWrapper(21383): showStatusIcon on inactive InputConnection
08-20 08:57:18.263: D/DroidGap(21383): onDestroy()
08-20 08:57:18.263: D/CordovaWebView(21383): >>> loadUrlNow()
08-20 08:57:18.263: D/CordovaWebView(21383): >>> loadUrlNow()
08-20 08:57:18.283: D/DroidGap(21383): onMessage(onPageStarted,about:blank)
08-20 08:57:18.303: D/Cordova(21383): onPageFinished(about:blank)
08-20 08:57:18.303: D/DroidGap(21383): onMessage(onPageFinished,about:blank)
08-20 08:57:18.303: D/DroidGap(21383): onMessage(exit,null)
08-20 08:57:19.483: D/DroidGap(21383): onMessage(spinner,stop)
08-20 08:57:19.513: D/DroidGap(21383): onMessage(spinner,stop)
08-20 08:57:20.023: D/DroidGap(21383): onMessage(spinner,stop)
看起来只要我调用setRequestedOrientation,就像这样:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    super.loadUrl("file:///android_asset/www/index.html");
}

我的应用程序调用onDestroy并返回到启动器。我只是不理解Android的概念吗?任何人都有线索吗?

您应该在第一个出现的android清单中添加隐藏在android清单中的android:configChanges=orientation | Keyboard。我也遇到了同样的问题,它也使我的应用程序崩溃。

你应该在第一个出现的android清单中添加android:configChanges=orientation | keyboard。我也遇到了同样的问题,它也使我的应用程序崩溃。

请在此处查看接受的答案:请在此处查看接受的答案:为什么要回答一个一个月前的问题,而我已经找到了解决方案。请看我的评论。因为有问题的实际答案很好,而不仅仅是一个链接。为什么讨厌别人回答你的问题?为什么你要回答一个已经一个月了,而我已经找到了解决办法的问题。请看我的评论。因为有问题的实际答案很好,而不仅仅是一个链接。为什么讨厌别人回答你的问题?