我正在使用phonegap创建一个Android应用。我的应用程序是一个简单的游戏,我在其中生成随机数以进行数学运算。当您回答正确时,分数会上升,如果输了,您现在就将名称和分数保存到localStorage中。问题是我无法在android中查看它。你们能帮我吗? 下面是我用于在浏览器中查看的代码。
MAMAppConfigManager configManager = MAMComponents.get(MAMAppConfigManager.class);
String identity = "<user-name>@mobileinfy.onmicrosoft.com";
//
MAMAppConfig appConfig = configManager.getAppConfig(identity); //<= this line returning null.
Log.i("App Config Data = ",(appConfig == null ? "null" : appConfig.getFullData().toString()));
String valueToUse = null;
if (appConfig.hasConflict("endpointURL")) // <=So getting Exception at this line NullPointerException
{
List<String> values = appConfig.getAllStringsForKey("ServerUrl");
for (String value : values) {
valueToUse = value;
}
} else {
valueToUse = appConfig.getStringForKey("endpointURL ", MAMAppConfig.StringQueryType.Any);
}
Log.i("Found value " , valueToUse);
答案 0 :(得分:0)
localStorage是一个对象,因此您可以执行以下操作:
const mongoose = require("mongoose");
const { mongoUrl } = require("../config.js");
const MyModel = require("../models/MyModel");
async function run() {
mongoose.set("useCreateIndex", true);
await mongoose.connect(mongoUrl, { useNewUrlParser: true });
const r = [/* */]; // <-- Something with 500k objects
const total = r.length;
// Set empty array of bulk write operations
let bulkWriteOps = [];
for (let i in r) {
const e = r[i];
e.REF = e.REF.trim();
/* As every update operation is different because it depends on the iteration
variable, you have to push each element individually */
bulkWriteOps.push({
updateOne: {
'filter': { REF: e.REF },
'update': e,
'upsert': true
// As you are not using the result of the update, you don't need the new: true flag
}
})
if (i % 500 === 0) {
console.log((i / total) * 100 + "%");
}
}
}
if (bulkWriteOps.length) await MyModel.bulkWrite(bulkWriteOps)
run();
它可以在我自己的带有cordova应用程序的android设备上工作。
如果这对您不起作用,则必须使用chrome远程开发工具手动检查问题所在。
https://developers.google.com/web/tools/chrome-devtools/remote-debugging/
答案 1 :(得分:0)
没关系的家伙。只是我的旧手机听不懂代码。我尝试借用我的朋友电话,这可以正常工作。