Ich versuche, ein Cordova-Plugin für abgehende abgehenden Anruf erstellen und rufen Sie die Nummer aufgerufen.Cordova ausgehende Anrufe Nummer Plugin
Aber wenn ich die App starte, gibt es mir einen Fehler zurück, es geht in errorCallback Funktion.
Java-Code:
public class OutgoingCall extends CordovaPlugin {
private Context context;
@Override
public boolean execute(String action, JSONArray args, CallbackContext
callbackContext) throws JSONException {
Context ctx = this.context;
String number = args.getString(0);
return true;
}
}
class OutgoingCallReceiver extends BroadcastReceiver {
private CallbackContext callbackContext;
public void setCallbackContext(CallbackContext callbackContext) {
this.callbackContext = callbackContext;
}
@Override
public void onReceive(Context context, Intent intent) {
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
if (state == null) {
String phoneNumber =intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
Log.e("Number=", phoneNumber);
JSONObject jso = new JSONObject();
try {
jso.put("phoneNumber", phoneNumber);
} catch (JSONException e) {
phoneNumber = "Errore 2!";
}
PluginResult result = new PluginResult(PluginResult.Status.OK,phoneNumber);
result.setKeepCallback(true);
callbackContext.sendPluginResult(result);
}
}
}
JS-Code:
var OutgoingCall = {
onReceive: function(successCallback, errorCallback) {
errorCallback = errorCallback || this.errorCallback;
cordova.exec(successCallback, errorCallback, 'OutgoingCall','onReceive', []);
},
errorCallback: function() {
console.log("WARNING: OutgoingCall errorCallback not implemented");
}
};
module.exports = OutgoingCall;
Ich habe in plugin.xml hinzugefügt
<config-file parent="/*" target="res/xml/config.xml">
<feature name="OutgoingCall">
<param name="android-package"value="org.outgoingcall.cool.OutgoingCall" />
</feature>
</config-file>
<config-file parent="/*" target="AndroidManifest.xml">
<uses-permissionandroid:name="android.permission.PROCESS_OUTGOING_CALLS"/>
<receiver android:name=".OutgoingCallReciver" >
<intent-filter>
<actionandroid:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>
</receiver>
</config-file>
Ich benutze Plugin in onDeviceReady Funktion aber das Plugin gehen in errorCallback Funktion.
Bitte helfen Sie mir, ich bin verzweifelt!
Mit freundlichen Grüßen.
Dann wechsle ich dieses ? –