本文整理匯總了Java中org.apache.cordova.PluginResult.setKeepCallback方法的典型用法代碼示例。如果您正苦於以下問題:Java PluginResult.setKeepCallback方法的具體用法?Java PluginResult.setKeepCallback怎麽用?Java PluginResult.setKeepCallback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.cordova.PluginResult
的用法示例。
在下文中一共展示了PluginResult.setKeepCallback方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onActivityResult
import org.apache.cordova.PluginResult; //導入方法依賴的package包/類
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent)
{
super.onActivityResult(requestCode, resultCode, intent);
if (onActivityResultCallbackContext != null && intent != null)
{
intent.putExtra("requestCode", requestCode);
intent.putExtra("resultCode", resultCode);
PluginResult result = new PluginResult(PluginResult.Status.OK, getIntentJson(intent));
result.setKeepCallback(true);
onActivityResultCallbackContext.sendPluginResult(result);
}
else if (onActivityResultCallbackContext != null)
{
Intent canceledIntent = new Intent();
canceledIntent.putExtra("requestCode", requestCode);
canceledIntent.putExtra("resultCode", resultCode);
PluginResult canceledResult = new PluginResult(PluginResult.Status.OK, getIntentJson(canceledIntent));
canceledResult.setKeepCallback(true);
onActivityResultCallbackContext.sendPluginResult(canceledResult);
}
}
示例2: execute
import org.apache.cordova.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 True if the action was valid, false otherwise.
*/
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) {
if (action.equals("getConnectionInfo")) {
this.connectionCallbackContext = callbackContext;
NetworkInfo info = sockMan.getActiveNetworkInfo();
String connectionType = "";
try {
connectionType = this.getConnectionInfo(info).get("type").toString();
} catch (JSONException e) {
LOG.d(LOG_TAG, e.getLocalizedMessage());
}
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, connectionType);
pluginResult.setKeepCallback(true);
callbackContext.sendPluginResult(pluginResult);
return true;
}
return false;
}
示例3: onEventsReceived
import org.apache.cordova.PluginResult; //導入方法依賴的package包/類
@Override
public void onEventsReceived(@NonNull Context context, @NonNull RadarEvent[] events, @NonNull RadarUser user) {
if (RadarCordovaPlugin.eventsCallbackContext == null)
return;
try {
JSONObject obj = new JSONObject();
obj.put("events", RadarCordovaUtils.jsonArrayForEvents(events));
obj.put("user", RadarCordovaUtils.jsonObjectForUser(user));
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, obj);
pluginResult.setKeepCallback(true);
RadarCordovaPlugin.eventsCallbackContext.sendPluginResult(pluginResult);
} catch (JSONException e) {
RadarCordovaPlugin.eventsCallbackContext.sendPluginResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
}
}
示例4: execute
import org.apache.cordova.PluginResult; //導入方法依賴的package包/類
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
this.callbackContext = callbackContext;
if (action.equals("getLocation")) {
myLocation.getLocation(context);
PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT);
r.setKeepCallback(true);
callbackContext.sendPluginResult(r);
return true;
}
return false;
}
示例5: sendUpdate
import org.apache.cordova.PluginResult; //導入方法依賴的package包/類
/**
* Create a new plugin result and send it back to JavaScript
*
* @param obj a JSONObject contain event payload information
* @param status the status code to return to the JavaScript environment
*/
private void sendUpdate(JSONObject obj, boolean keepCallback, PluginResult.Status status) {
if (callbackContext != null) {
PluginResult result = new PluginResult(status, obj);
result.setKeepCallback(keepCallback);
callbackContext.sendPluginResult(result);
if (!keepCallback) {
callbackContext = null;
}
}
}
示例6: sendUpdate
import org.apache.cordova.PluginResult; //導入方法依賴的package包/類
/**
* Create a new plugin result and send it back to JavaScript
*
* @param obj a JSONObject contain event payload information
* @param status the status code to return to the JavaScript environment
*/
private void sendUpdate(JSONObject obj, boolean keepCallback, PluginResult.Status status) {
if (callbackContext != null) {
PluginResult result = new PluginResult(status, obj);
result.setKeepCallback(keepCallback);
callbackContext.sendPluginResult(result);
if (!keepCallback) {
callbackContext = null;
}
}
}
示例7: sendUpdate
import org.apache.cordova.PluginResult; //導入方法依賴的package包/類
/**
* Create a new plugin result and send it back to JavaScript
*
* @param connection the network info to set as navigator.connection
*/
private void sendUpdate(String type) {
if (connectionCallbackContext != null) {
PluginResult result = new PluginResult(PluginResult.Status.OK, type);
result.setKeepCallback(true);
connectionCallbackContext.sendPluginResult(result);
}
webView.postMessage("networkconnection", type);
}
示例8: onReceive
import org.apache.cordova.PluginResult; //導入方法依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (onBroadcastCallbackContext != null)
{
PluginResult result = new PluginResult(PluginResult.Status.OK, getIntentJson(intent));
result.setKeepCallback(true);
onBroadcastCallbackContext.sendPluginResult(result);
}
}
示例9: onServicesDiscovered
import org.apache.cordova.PluginResult; //導入方法依賴的package包/類
@Override
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
super.onServicesDiscovered(gatt, status);
if (status == BluetoothGatt.GATT_SUCCESS) {
PluginResult result = new PluginResult(PluginResult.Status.OK, this.asJSONObject(gatt));
result.setKeepCallback(true);
connectCallback.sendPluginResult(result);
} else {
LOG.e(TAG, "Service discovery failed. status = " + status);
connectCallback.error(this.asJSONObject("Service discovery failed"));
disconnect();
}
}
示例10: sendMessageToDefaultCallback
import org.apache.cordova.PluginResult; //導入方法依賴的package包/類
/**
* Send message to default plugin callback.
* Default callback - is a callback that we receive on initialization (device ready).
* Through it we are broadcasting different events.
* <p/>
* If callback is not set yet - message will be stored until it is initialized.
*
* @param message message to send to web side
* @return true if message was sent; false - otherwise
*/
private boolean sendMessageToDefaultCallback(final PluginResult message) {
if (jsDefaultCallback == null) {
defaultCallbackStoredResults.add(message);
return false;
}
message.setKeepCallback(true);
jsDefaultCallback.sendPluginResult(message);
return true;
}
示例11: fetchUpdate
import org.apache.cordova.PluginResult; //導入方法依賴的package包/類
/**
* Fetch new update from the server.
* We will send request to the JS side, which will call appropriate JS module.
*/
private void fetchUpdate() {
if (defaultCallback == null) {
return;
}
updateRequested = false;
PluginResult result = new PluginResult(PluginResult.Status.OK);
result.setKeepCallback(true);
defaultCallback.sendPluginResult(result);
}
示例12: sendCallback
import org.apache.cordova.PluginResult; //導入方法依賴的package包/類
private static void sendCallback(PluginResult.Status status, String message){
if(!Thread.currentThread().isInterrupted()){
final PluginResult result = new PluginResult(status, message);
result.setKeepCallback(true);
_callbackContext.sendPluginResult(result);
}
}
示例13: keepCallback
import org.apache.cordova.PluginResult; //導入方法依賴的package包/類
public void keepCallback(NaviLatLng point) {
JSONObject json = new JSONObject();
try {
json.put("status", 1);
json.put("lat", point.getLatitude());
json.put("lng", point.getLongitude());
} catch (JSONException ex) {
Log.e("AMapNavigation.keepCallback", ex.getMessage());
}
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, json);
pluginResult.setKeepCallback(true);
callbackContext.sendPluginResult(pluginResult);
}
示例14: onStreamGotten
import org.apache.cordova.PluginResult; //導入方法依賴的package包/類
public void onStreamGotten(String stream) {
Log.d(TAG, "returning stream");
JSONArray data = new JSONArray();
data.put(stream);
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, data);
pluginResult.setKeepCallback(true);
streamCallbackContext.sendPluginResult(pluginResult);
}
示例15: sendBluetoothStateChange
import org.apache.cordova.PluginResult; //導入方法依賴的package包/類
private void sendBluetoothStateChange(int state) {
if (this.stateCallback != null) {
PluginResult result = new PluginResult(PluginResult.Status.OK, this.bluetoothStates.get(state));
result.setKeepCallback(true);
this.stateCallback.sendPluginResult(result);
}
}