Direct call on Android will restart the app

I have implemented plugin

based on Simon's answer ( Automatically assign a phone number on Android using PhoneGap ) in my own app.

But when I end the call, the application restarts, any idea what I can do?

This is my code

package com.phonegap.plugin;


import org.apache.cordova.api.Plugin;
import org.apache.cordova.api.PluginResult;
import org.json.JSONArray;
import org.json.JSONException;

import android.content.Intent;
import android.net.Uri;

/**
 * This class echoes a string called from JavaScript.
 */
public class DirectCall extends Plugin {

@Override
public PluginResult execute(String action, JSONArray args, String callbackId) {
    PluginResult.Status status = PluginResult.Status.OK;
    String result = "";

    try {
        if (action.equals("call")) {
            String number = "tel:" + args.getString(0);
            Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse(number)); 
            this.cordova.getActivity().startActivity(callIntent);
        }
        else {
            status = PluginResult.Status.INVALID_ACTION;
        }
        return new PluginResult(status, result);
    } catch (JSONException e) {
        return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
    }
}


}

      

I'm looking for Android documentation, but I couldn't find an answer to my question.

Any help would be appreciated :)

+3
android plugins cordova call


source to share


No one has answered this question yet

See similar questions:

2
Call a predefined number automatically on Android using PhoneGap

or similar:

3606
Close / hide Android soft keyboard
3295
Why is the Android emulator so slow? How can we speed up the development of an Android emulator?
3288
Correct use cases for Android UserManager.isUserAGoat ()?
2609
Is there a unique identifier for an Android device?
2510
How to persist android activity state by persisting instance state?
2097
Is there a way to run Python on Android?
1844
What is "Context" on Android?
1296
Reloading activity on android rotation
1
Getting an exception on application startup
0
Is there any other way to call a number in android without using native call?



All Articles
Loading...
X
Show
Funny
Dev
Pics