내 Java 코드 (기본적으로 백그라운드 프로세스)에서 JS로 데이터를 다시 푸시하고자하는 Salesforce 플러그인을 만들려고합니다. 하지만 항상 오류가 발생합니다. 나는 끝에 오류 라인을 표시 한sendJavascript 함수가 Cordova 플러그인 salesforce에서 정의되지 않았습니다.
package com.salesforce.androidsdk.phonegap;
import org.apache.cordova.api.CallbackContext;
import org.apache.cordova.api.CordovaPlugin;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
/**
* This class echoes a string called from JavaScript.
*/
public class Echo extends CordovaPlugin {
private static final String TAG = "CordovaPlugin";
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
Log.i(TAG,"inside execute method--->>>" + action + args + callbackContext);
if (action.trim().equalsIgnoreCase("echo")) {
Log.i(TAG,"args.getString(0)--->>>" + args.getString(0));
String message = args.getString(0);
// Initialise the service variables and start it it up
Context thiscontext = this.cordova.getActivity().getApplicationContext();
Intent callBackgroundService = new Intent(thiscontext, CallBackgroundService.class);
callBackgroundService.putExtra("loadinterval", 800); // Set LED flash interval
thiscontext.startService(callBackgroundService);
this.echo(message, callbackContext);
sendValue("Kaushik", "Ray");
return true;
}
return false;
}
private void echo(String message, CallbackContext callbackContext) {
if (message != null && message.length() > 0) {
callbackContext.success(message);
} else {
callbackContext.error("Expected one non-empty string argument.");
}
}
public void sendValue(String value1, String value2) {
JSONObject data = new JSONObject();
try {
data.put("value1", "Kaushik");
data.put("value2", "Ray");
} catch (JSONException e) {
Log.e("CommTest", e.getMessage());
}
String js = String.format(
"window.plugins.commtest.updateValues('%s');",
data.toString());
error line ------->>> this.sendJavascript(js);
}
}
- 라인 this.sendJavascript
다음 (함수 이름) 플러그인 코드입니다. 나를 사전에이
감사를 해결 Kaushik이
사실 나는 단지 문제를 해결 .. .. !! 도움을 주셔서 감사합니다 .. !! 나는 CallBackgroundService.java라는 코드에서 백그라운드 서비스 클래스를 mentioined로 호출하고 있지만, 안드로이드의 JS에서 다시 JS로 값을 전달할 수는 없다는 의심의 여지가있었습니다. 모든 포인터 plz ... ?? – RayKaushik
당신이 알아 낸 것을 듣고 기쁘게 생각합니다. 다른 문제에 관해서는 일부 코드를 보지 않고서는 정말 잘 모르겠지만 다른 질문을 게시 할 가치가있는 것 같습니다. – MattDavis