Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chanphiromsok/bb55db47505e129ef261e75dce6c7811 to your computer and use it in GitHub Desktop.
Save chanphiromsok/bb55db47505e129ef261e75dce6c7811 to your computer and use it in GitHub Desktop.
React-Native Bridge #1
import android.provider.Settings;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import android.util.Log;
import android.net.Uri;
public class AndroidOpenSettings extends ReactContextBaseJavaModule {
private ReactContext reactContext;
public AndroidOpenSettings(ReactApplicationContext reactContext) {
super(reactContext);
this.reactContext = reactContext;
}
@Override
public String getName() {
return "RNAndroidOpenSettings";
}
@ReactMethod
public void locationSourceSettings() {
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
if (intent.resolveActivity(reactContext.getPackageManager()) != null)
}
@ReactMethod
public void appDetailsSettings() {
String packageName = reactContext.getPackageName();
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.parse("package:" + packageName));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
if (intent.resolveActivity(reactContext.getPackageManager()) != null)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment