com.facebook.react.ReactActivity Java Examples

The following examples show how to use com.facebook.react.ReactActivity. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GPSStateModule.java    From react-native-gps-state with MIT License 6 votes vote down vote up
@ReactMethod
public void requestAuthorization() {
    if (_NativeIsDeviceMOrAbove()) {
        String[] permissions = {Manifest.permission.ACCESS_FINE_LOCATION};
        Activity activity = getCurrentActivity();
        int requestCode = REQUEST_CODE_AUTHORIZATION;

        if (activity instanceof ReactActivity) {
            ((ReactActivity) activity).requestPermissions(permissions, requestCode, listener);

        } else if (activity instanceof PermissionAwareActivity) {
            ((PermissionAwareActivity) activity).requestPermissions(permissions, requestCode, listener);

        } else {
            ActivityCompat.requestPermissions(activity, permissions, requestCode);
        }
    }
}
 
Example #2
Source File: CustomWebViewModule.java    From react-native-webview-android-file-upload with MIT License 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.M)
private void requestPermissions() {
    if (getCurrentActivity() instanceof ReactActivity) {
        ((ReactActivity) getCurrentActivity()).requestPermissions(new String[]{ Manifest.permission.CAMERA}, REQUEST_CAMERA, listener);
    }
    else {
        ((PermissionAwareActivity) getCurrentActivity()).requestPermissions(new String[]{ Manifest.permission.CAMERA}, REQUEST_CAMERA, listener);
    }
}
 
Example #3
Source File: RNBranchModule.java    From react-native-branch with MIT License 5 votes vote down vote up
public static void initSession(Uri uri, ReactActivity reactActivity) {
  Branch branch = Branch.getInstance();
  branch.initSession(new Branch.BranchReferralInitListener(){
      private ReactActivity mActivity = null;

      @Override
      public void onInitFinished(JSONObject referringParams, BranchError error) {
          Log.d(REACT_CLASS, "onInitFinished");
          JSONObject result = new JSONObject();
          try{
              result.put("params", referringParams != null ? referringParams : JSONObject.NULL);
              result.put("error", error != null ? error.getMessage() : JSONObject.NULL);                
          } catch(JSONException ex) {
              try { 
                  result.put("error", "Failed to convert result to JSONObject: " + ex.getMessage());
              } catch(JSONException k) {}
          }
          initSessionResult = result;
          LocalBroadcastManager.getInstance(mActivity).sendBroadcast(new Intent(NATIVE_INIT_SESSION_FINISHED_EVENT));
      }

      private Branch.BranchReferralInitListener init(ReactActivity activity) {
          mActivity = activity;
          return this;
      }
  }.init(reactActivity), uri, reactActivity);
}