Search in sources :

Example 81 with JSObject

use of com.getcapacitor.JSObject in project capacitor-plugins by ionic-team.

the class AppLauncherPlugin method canOpenUrl.

@PluginMethod
public void canOpenUrl(PluginCall call) {
    String url = call.getString("url");
    if (url == null) {
        call.reject("Must supply a url");
        return;
    }
    Context ctx = this.getActivity().getApplicationContext();
    final PackageManager pm = ctx.getPackageManager();
    JSObject ret = new JSObject();
    try {
        pm.getPackageInfo(url, PackageManager.GET_ACTIVITIES);
        ret.put("value", true);
        call.resolve(ret);
        return;
    } catch (PackageManager.NameNotFoundException e) {
        Logger.error(getLogTag(), "Package name '" + url + "' not found!", null);
    }
    ret.put("value", false);
    call.resolve(ret);
}
Also used : Context(android.content.Context) PackageManager(android.content.pm.PackageManager) JSObject(com.getcapacitor.JSObject) PluginMethod(com.getcapacitor.PluginMethod)

Example 82 with JSObject

use of com.getcapacitor.JSObject in project capacitor-plugins by ionic-team.

the class DevicePlugin method getInfo.

@PluginMethod
public void getInfo(PluginCall call) {
    JSObject r = new JSObject();
    r.put("memUsed", implementation.getMemUsed());
    r.put("diskFree", implementation.getDiskFree());
    r.put("diskTotal", implementation.getDiskTotal());
    r.put("realDiskFree", implementation.getRealDiskFree());
    r.put("realDiskTotal", implementation.getRealDiskTotal());
    r.put("model", android.os.Build.MODEL);
    r.put("operatingSystem", "android");
    r.put("osVersion", android.os.Build.VERSION.RELEASE);
    r.put("platform", implementation.getPlatform());
    r.put("manufacturer", android.os.Build.MANUFACTURER);
    r.put("isVirtual", implementation.isVirtual());
    r.put("name", implementation.getName());
    r.put("webViewVersion", implementation.getWebViewVersion());
    call.resolve(r);
}
Also used : JSObject(com.getcapacitor.JSObject) PluginMethod(com.getcapacitor.PluginMethod)

Example 83 with JSObject

use of com.getcapacitor.JSObject in project capacitor-plugins by ionic-team.

the class AppPlugin method getState.

@PluginMethod
public void getState(PluginCall call) {
    JSObject data = new JSObject();
    data.put("isActive", this.bridge.getApp().isActive());
    call.resolve(data);
}
Also used : JSObject(com.getcapacitor.JSObject) PluginMethod(com.getcapacitor.PluginMethod)

Example 84 with JSObject

use of com.getcapacitor.JSObject in project capacitor-plugins by ionic-team.

the class AppPlugin method getLaunchUrl.

@PluginMethod
public void getLaunchUrl(PluginCall call) {
    Uri launchUri = bridge.getIntentUri();
    if (launchUri != null) {
        JSObject d = new JSObject();
        d.put("url", launchUri.toString());
        call.resolve(d);
    } else {
        call.resolve();
    }
}
Also used : JSObject(com.getcapacitor.JSObject) Uri(android.net.Uri) PluginMethod(com.getcapacitor.PluginMethod)

Example 85 with JSObject

use of com.getcapacitor.JSObject in project capacitor-radar by radarlabs.

the class RadarPlugin method jsObjectForJSONObject.

private static JSObject jsObjectForJSONObject(JSONObject jsonObj) {
    try {
        if (jsonObj == null) {
            return null;
        }
        JSObject obj = new JSObject();
        Iterator<String> keys = jsonObj.keys();
        while (keys.hasNext()) {
            String key = keys.next();
            if (jsonObj.opt(key) != null) {
                obj.put(key, jsonObj.get(key));
            }
        }
        return obj;
    } catch (JSONException j) {
        return null;
    }
}
Also used : JSObject(com.getcapacitor.JSObject) JSONException(org.json.JSONException)

Aggregations

JSObject (com.getcapacitor.JSObject)169 PluginMethod (com.getcapacitor.PluginMethod)93 JSONException (org.json.JSONException)28 JSONObject (org.json.JSONObject)20 MyRunnable (com.jeep.plugin.capacitor.capacitorvideoplayer.Notifications.MyRunnable)16 JSArray (com.getcapacitor.JSArray)14 Radar (io.radar.sdk.Radar)12 Uri (android.net.Uri)11 Location (android.location.Location)9 JSONArray (org.json.JSONArray)7 ArrayList (java.util.ArrayList)6 NotNull (org.jetbrains.annotations.NotNull)6 Nullable (org.jetbrains.annotations.Nullable)6 ParseException (java.text.ParseException)5 Intent (android.content.Intent)4 FirebaseUser (com.google.firebase.auth.FirebaseUser)4 Gson (com.google.gson.Gson)4 Date (java.util.Date)4 HashMap (java.util.HashMap)4 Test (org.junit.Test)4