本文整理匯總了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));
}