gpt4 book ai didi

Android 2.3.6 + Phonegap + localStorage

转载 作者:行者123 更新时间:2023-11-29 18:08:01 25 4
gpt4 key购买 nike

我正在使用 phonegap 和 jQuery mobile 开发移动应用。

我收到来自 QA 的报告,在 Samsung Galaxy Y (android 2.3.6) 上 - localStorage 为空,因此导致应用程序崩溃。

据我所知,android 2.0+ 版本应该支持 localStorage,我什至在 DroidGap 类中添加了以下代码:

super.appView.getSettings().setAllowFileAccess(true);        
super.appView.getSettings().setDatabaseEnabled(true);
super.appView.getSettings().setDatabasePath("/data/data/" + appView.getContext().getPackageName() + "/databases/");
super.appView.getSettings().setDomStorageEnabled(true);

所以我很难理解为什么这个特定设备似乎不支持 localStorage。有人告诉我,它甚至可以在具有相同 Android 版本的其他设备上正常运行!

是否有任何我不知道的设置或其他事情可能导致 localStorage 为空??

最佳答案

您可以从 android SDK 安装文件夹的平台工具文件夹运行 logcat,在我的机器上这是:C:\Program Files (x86)\Android\android-sdk\platform-tools

只需从命令提示符运行 adb logcat。您会收到很多消息。

我创建了一个测试应用程序并在 Galaxy Y 上运行它,该应用程序的 onDeviceReady 函数中包含以下代码。使用 logcat 显示不支持的消息

if (typeof window.localStorage == 'object')
{
// localStorage is supported
console.log('**HelloGap: localStorage is supported');
}
else
{
// localStorage is not supported
console.log('**HelloGap: localStorage is NOT supported');
}

您可以过滤来自 logcat 的消息,但我无法让它工作,所以我只是将输出重定向到一个文本文件并在其中搜索 **HelloGap

关于Android 2.3.6 + Phonegap + localStorage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12355604/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com