@ReactMethod
public void startService(Promise promise) {
String result = "Success";
Activity activity = getCurrentActivity();
if (activity != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.canDrawOverlays(getReactApplicationContext())) {
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:" + getCurrentActivity().getPackageName()));
getCurrentActivity().startActivityForResult(intent, MainActivity.DRAW_OVER_OTHER_APP_PERMISSION_REQUEST_CODE);
}
}
try {
Intent intent = new Intent(FloatingWidgetService.FLOATING_WIDGET_ID);
intent.setClass(this.getReactApplicationContext(), FloatingWidgetService.class);
getReactApplicationContext().startService(intent);
FloatingWidgetService.setUri(uri);
} catch (Exception e) {
promise.reject(e);
return;
}
promise.resolve(result);
}