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