本文整理汇总了Java中org.apache.cordova.CordovaArgs.optString方法的典型用法代码示例。如果您正苦于以下问题:Java CordovaArgs.optString方法的具体用法?Java CordovaArgs.optString怎么用?Java CordovaArgs.optString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cordova.CordovaArgs
的用法示例。
在下文中一共展示了CordovaArgs.optString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: requestKeepAwake
import org.apache.cordova.CordovaArgs; //导入方法依赖的package包/类
private void requestKeepAwake(final CordovaArgs args) {
final String level = args.optString(0);
cordova.getActivity().runOnUiThread(new Runnable() {
public void run() {
if ("display".equals(level)) {
cordova.getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
} else if ("system".equals(level)) {
if (systemLock == null) {
PowerManager powerManager = (PowerManager) cordova.getActivity().getSystemService(Context.POWER_SERVICE);
systemLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Chrome Power System lock");
systemLock.acquire();
}
}
}
});
}
示例2: consume
import org.apache.cordova.CordovaArgs; //导入方法依赖的package包/类
public void consume(CordovaArgs args, final CallbackContext ctx) {
String productId = args.optString(0);
if (productId == null) {
ctx.sendPluginResult(new PluginResult(Status.ERROR, "Invalid argument"));
return;
}
int quantity = args.optInt(1);
if (quantity < 1) {
quantity = 1;
}
service.consume(productId, quantity, new InAppService.ConsumeCallback() {
@Override
public void onComplete(int consumed, Error error) {
if (error != null) {
ctx.sendPluginResult(new PluginResult(Status.ERROR, errorToJSON(error)));
}
else {
ctx.sendPluginResult(new PluginResult(Status.OK, consumed));
}
}
});
}
示例3: productforId
import org.apache.cordova.CordovaArgs; //导入方法依赖的package包/类
public void productforId(CordovaArgs args, CallbackContext ctx) {
String productId = args.optString(0);
InAppProduct product = null;
if (productId != null) {
product = service.productForId(productId);
}
if (product!= null) {
ctx.sendPluginResult(new PluginResult(Status.OK, product.toJSON()));
}
else {
ctx.sendPluginResult(new PluginResult(Status.OK));
}
}
示例4: isPurchased
import org.apache.cordova.CordovaArgs; //导入方法依赖的package包/类
public void isPurchased(CordovaArgs args, CallbackContext ctx) {
String productId = args.optString(0);
boolean purchased = productId != null ? service.isPurchased(productId) : false;
ctx.sendPluginResult(new PluginResult(Status.OK, purchased));
}
示例5: stockOfProduct
import org.apache.cordova.CordovaArgs; //导入方法依赖的package包/类
public void stockOfProduct(CordovaArgs args, CallbackContext ctx) {
String productId = args.optString(0);
int stock = productId != null ? service.stockOfProduct(productId) : 0;
ctx.sendPluginResult(new PluginResult(Status.OK, stock));
}