Hello ionic people,
this is my first question
Actually im new in ionic/cordova and i have a question (if it is a stupid one, pls be gentle haha).
I’m trying to let my JavaScript communicate with the android classes but unfortunately it wont
My JS code:
ionic.Platform.ready(function(){
// will execute when device is ready, or immediately if the device is already ready.
$scope.updateFirstRun = function(){
cordova.exec($scope.nativeCommunicateSuccess, $scope.nativeCommunicateError, “ComuPlugin”, “callNativeMethod”, );
}
$scope.nativeCommunicateError = function(){ alert("nope"); }
$scope.nativeCommunicateSuccess = function(){ alert("success"); }
});
After that i created the android class:
package com.testapp.comu;
import org.apache.cordova.CordovaWebView;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaPlugin;
import org.json.JSONArray;
import org.json.JSONException;
import android.util.Log;
import com.ionicframework.testapp801635.MainActivity;
public class Comu extends CordovaPlugin
{
private static final String TAG = “Comu”;
private CallbackContext callbackContext = null; private MainActivity activity = null;
@Override public void initialize(CordovaInterface cordova, CordovaWebView webView) { super.initialize(cordova, webView);
// Set the Activity. this.activity = (MainActivity) cordova.getActivity(); }
@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException
{
this.callbackContext = callbackContext;
Log.d(TAG, callbackContext.getCallbackId() + ": " + action);
return true; }
And finally i updated my config.xml like this:
<feature name="ComuPlugin">
<param name="android-package" value="com.testapp.comu" />
</feature>
But still i get the follow error message “class not found” and Logcat tells me that the function plugin “ComuPlugin” is not found.
Does anyone know’s where my problem is?
Thanks in advance