3

私は自分のアプリケーションにSimonの答え( AndroidでPhoneGapを使用して事前定義された番号を自動的に呼び出すplugin)に基づいて実装しました。

しかし、通話を終了すると、アプリケーションが再起動します。何ができるでしょうか?

これは私のコードです

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);
    }
}


}

Android のドキュメントを検索しましたが、質問に対する回答が見つかりませんでした。

どんな助けでも大歓迎です:)

4

0 に答える 0