本文整理汇总了Java中org.apache.cordova.api.PluginResult.setKeepCallback方法的典型用法代码示例。如果您正苦于以下问题:Java PluginResult.setKeepCallback方法的具体用法?Java PluginResult.setKeepCallback怎么用?Java PluginResult.setKeepCallback使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cordova.api.PluginResult
的用法示例。
在下文中一共展示了PluginResult.setKeepCallback方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.apache.cordova.api.PluginResult; //导入方法依赖的package包/类
/**
* Executes the request and returns PluginResult.
*
* @param action The action to execute.
* @param args JSONArry of arguments for the plugin.
* @param callbackContext The callback id used when calling back into JavaScript.
* @return A PluginResult object with a status and message.
*/
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
this.callbackContext = callbackContext;
this.targetHeight = 0;
this.targetWidth = 0;
this.mQuality = 80;
JSONObject options = args.optJSONObject(0);
if (options != null)
{
this.targetHeight = options.getInt("targetHeight");
this.targetWidth = options.getInt("targetWidth");
this.mQuality = options.getInt("quality");
}
this.getImage();
PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT);
r.setKeepCallback(true);
callbackContext.sendPluginResult(r);
return true;
}
示例2: fail
import org.apache.cordova.api.PluginResult; //导入方法依赖的package包/类
private void fail(int paramInt, String paramString)
{
JSONObject localJSONObject = new JSONObject();
try
{
localJSONObject.put("code", paramInt);
localJSONObject.put("message", paramString);
PluginResult localPluginResult = new PluginResult(PluginResult.Status.ERROR, localJSONObject);
localPluginResult.setKeepCallback(true);
this.callbackContext.sendPluginResult(localPluginResult);
return;
}
catch (JSONException localJSONException)
{
while (true)
localJSONException.printStackTrace();
}
}
示例3: execute
import org.apache.cordova.api.PluginResult; //导入方法依赖的package包/类
public boolean execute(String paramString, JSONArray paramJSONArray, CallbackContext paramCallbackContext)
{
if (paramString.equals("start"))
{
this.callbackContext = paramCallbackContext;
if (this.status != RUNNING)
start();
}
while (true)
{
PluginResult localPluginResult = new PluginResult(PluginResult.Status.NO_RESULT, "");
localPluginResult.setKeepCallback(true);
paramCallbackContext.sendPluginResult(localPluginResult);
return true;
if (!paramString.equals("stop"))
break;
if (this.status != RUNNING)
continue;
stop();
}
return false;
}
示例4: onSignInFailed
import org.apache.cordova.api.PluginResult; //导入方法依赖的package包/类
@Override
public void onSignInFailed(String reason){
JSONObject json = new JSONObject();
try{
json.put("type", GMS_SIGNIN);
json.put("signin", false);
json.put("message", reason);
}catch(JSONException ex){
Log.e(TAG, "signin failed exception: "+ex.getMessage());
return;
}
Log.d(TAG, "signin failed");
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, json);
pluginResult.setKeepCallback(true);
connectionCB.sendPluginResult(pluginResult);
}
示例5: execute
import org.apache.cordova.api.PluginResult; //导入方法依赖的package包/类
/**
* Executes the request and returns PluginResult.
*
* @param action
* The action to execute.
* @param args
* JSONArry of arguments for the plugin.
* @param callbackId
* The callback id used when calling back into JavaScript.
* @return A PluginResult object with a status and message.
*/
public PluginResult execute(String action, JSONArray args, String callbackId)
{
this.callbackId = callbackId;
try
{
this.targetHeight = 0;
this.targetWidth = 0;
this.mQuality = 80;
JSONObject options = args.optJSONObject(0);
if (options != null)
{
this.targetHeight = options.getInt("targetHeight");
this.targetWidth = options.getInt("targetWidth");
this.mQuality = options.getInt("quality");
}
this.getImage();
PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT);
r.setKeepCallback(true);
return r;
}
catch (JSONException e)
{
e.printStackTrace();
return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
}
}
示例6: execute
import org.apache.cordova.api.PluginResult; //导入方法依赖的package包/类
/**
* Executes the request and returns PluginResult.
*
* @param action The action to execute.
* @param args JSONArry of arguments for the plugin.
* @param callbackContext The callback id used when calling back into JavaScript.
* @return A PluginResult object with a status and message.
*/
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
this.callbackContext = callbackContext;
if (action.equals("takePicture")) {
this.targetHeight = 0;
this.targetWidth = 0;
this.mQuality = 80;
this.mQuality = args.getInt(0);
this.targetWidth = args.getInt(3);
this.targetHeight = args.getInt(4);
// If the user specifies a 0 or smaller width/height
// make it -1 so later comparisons succeed
if (this.targetWidth < 1) {
this.targetWidth = -1;
}
if (this.targetHeight < 1) {
this.targetHeight = -1;
}
this.takePicture();
PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT);
r.setKeepCallback(true);
callbackContext.sendPluginResult(r);
return true;
}
return false;
}
示例7: sendUpdate
import org.apache.cordova.api.PluginResult; //导入方法依赖的package包/类
/**
* Create a new plugin result and send it back to JavaScript
*
* @param obj a JSONObject contain event payload information
*/
private void sendUpdate(JSONObject obj, boolean keepCallback) {
if (this.browserCallbackId != null) {
PluginResult result = new PluginResult(PluginResult.Status.OK, obj);
result.setKeepCallback(keepCallback);
this.success(result, this.browserCallbackId);
}
}
示例8: sendUpdate
import org.apache.cordova.api.PluginResult; //导入方法依赖的package包/类
private void sendUpdate(String paramString)
{
if (this.connectionCallbackContext != null)
{
PluginResult localPluginResult = new PluginResult(PluginResult.Status.OK, paramString);
localPluginResult.setKeepCallback(true);
this.connectionCallbackContext.sendPluginResult(localPluginResult);
}
this.webView.postMessage("networkconnection", paramString);
}
示例9: execute
import org.apache.cordova.api.PluginResult; //导入方法依赖的package包/类
public boolean execute(String paramString, JSONArray paramJSONArray, CallbackContext paramCallbackContext)
{
if (paramString.equals("getConnectionInfo"))
{
this.connectionCallbackContext = paramCallbackContext;
NetworkInfo localNetworkInfo = this.sockMan.getActiveNetworkInfo();
PluginResult localPluginResult = new PluginResult(PluginResult.Status.OK, getConnectionInfo(localNetworkInfo));
localPluginResult.setKeepCallback(true);
paramCallbackContext.sendPluginResult(localPluginResult);
return true;
}
return false;
}
示例10: execute
import org.apache.cordova.api.PluginResult; //导入方法依赖的package包/类
public boolean execute(String paramString, JSONArray paramJSONArray, CallbackContext paramCallbackContext)
throws JSONException
{
this.callbackContext = paramCallbackContext;
if (paramString.equals("takePicture"))
{
this.saveToPhotoAlbum = false;
this.targetHeight = 0;
this.targetWidth = 0;
this.encodingType = 0;
this.mediaType = 0;
this.mQuality = 80;
this.mQuality = paramJSONArray.getInt(0);
int i = paramJSONArray.getInt(1);
int j = paramJSONArray.getInt(2);
this.targetWidth = paramJSONArray.getInt(3);
this.targetHeight = paramJSONArray.getInt(4);
this.encodingType = paramJSONArray.getInt(5);
this.mediaType = paramJSONArray.getInt(6);
this.correctOrientation = paramJSONArray.getBoolean(8);
this.saveToPhotoAlbum = paramJSONArray.getBoolean(9);
if (this.targetWidth < 1)
this.targetWidth = -1;
if (this.targetHeight < 1)
this.targetHeight = -1;
if (j == 1)
takePicture(i, this.encodingType);
while (true)
{
PluginResult localPluginResult = new PluginResult(PluginResult.Status.NO_RESULT);
localPluginResult.setKeepCallback(true);
paramCallbackContext.sendPluginResult(localPluginResult);
return true;
if ((j != 0) && (j != 2))
continue;
getImage(j, i);
}
}
return false;
}
示例11: sendUpdate
import org.apache.cordova.api.PluginResult; //导入方法依赖的package包/类
private void sendUpdate(JSONObject paramJSONObject, boolean paramBoolean)
{
if (this.batteryCallbackContext != null)
{
PluginResult localPluginResult = new PluginResult(PluginResult.Status.OK, paramJSONObject);
localPluginResult.setKeepCallback(paramBoolean);
this.batteryCallbackContext.sendPluginResult(localPluginResult);
}
}
示例12: execute
import org.apache.cordova.api.PluginResult; //导入方法依赖的package包/类
public boolean execute(String paramString, JSONArray paramJSONArray, CallbackContext paramCallbackContext)
{
if (paramString.equals("start"))
{
if (this.batteryCallbackContext != null)
{
paramCallbackContext.error("Battery listener already running.");
return true;
}
this.batteryCallbackContext = paramCallbackContext;
IntentFilter localIntentFilter = new IntentFilter();
localIntentFilter.addAction("android.intent.action.BATTERY_CHANGED");
if (this.receiver == null)
{
this.receiver = new BroadcastReceiver()
{
public void onReceive(Context paramContext, Intent paramIntent)
{
BatteryListener.this.updateBatteryInfo(paramIntent);
}
};
this.cordova.getActivity().registerReceiver(this.receiver, localIntentFilter);
}
PluginResult localPluginResult = new PluginResult(PluginResult.Status.NO_RESULT);
localPluginResult.setKeepCallback(true);
paramCallbackContext.sendPluginResult(localPluginResult);
return true;
}
if (paramString.equals("stop"))
{
removeBatteryListener();
sendUpdate(new JSONObject(), false);
this.batteryCallbackContext = null;
paramCallbackContext.success();
return true;
}
return false;
}
示例13: sendUpdate
import org.apache.cordova.api.PluginResult; //导入方法依赖的package包/类
private void sendUpdate(JSONObject paramJSONObject, boolean paramBoolean)
{
if (this.browserCallbackId != null)
{
Log.d("ChildBrowser", this.browserCallbackId);
PluginResult localPluginResult = new PluginResult(PluginResult.Status.OK, paramJSONObject);
localPluginResult.setKeepCallback(paramBoolean);
success(localPluginResult, this.browserCallbackId);
}
}
示例14: execute
import org.apache.cordova.api.PluginResult; //导入方法依赖的package包/类
/**
* Executes the request and returns PluginResult.
*
* @param action The action to execute.
* @param args JSONArray of arguments for the plugin.
* @param callbackId The callback id used when calling back into JavaScript.
* @return A PluginResult object with a status and message.
*/
public PluginResult execute(String action, JSONArray args, String callbackId) {
this.callback = callbackId;
if (action.equals(ENCODE)) {
JSONObject obj = args.optJSONObject(0);
if (obj != null) {
String type = obj.optString(TYPE);
String data = obj.optString(DATA);
// If the type is null then force the type to text
if (type == null) {
type = TEXT_TYPE;
}
if (data == null) {
return new PluginResult(PluginResult.Status.ERROR, "User did not specify data to encode");
}
encode(type, data);
} else {
return new PluginResult(PluginResult.Status.ERROR, "User did not specify data to encode");
}
}
else if (action.equals(SCAN)) {
scan();
} else {
return new PluginResult(PluginResult.Status.INVALID_ACTION);
}
PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT);
r.setKeepCallback(true);
return r;
}
示例15: fail
import org.apache.cordova.api.PluginResult; //导入方法依赖的package包/类
private void fail(int code, String message) {
// Error object
JSONObject errorObj = new JSONObject();
try {
errorObj.put("code", code);
errorObj.put("message", message);
} catch (JSONException e) {
e.printStackTrace();
}
PluginResult err = new PluginResult(PluginResult.Status.ERROR, errorObj);
err.setKeepCallback(true);
callbackContext.sendPluginResult(err);
}