Created
October 12, 2019 16:59
-
-
Save bicknest/5e7860ed37ab9277f26a4c851b802f5d to your computer and use it in GitHub Desktop.
React-Native Bridge #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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