Java 类com.facebook.react.ReactActivity 实例源码

项目:react-native-branch    文件:RNBranchModule.java   
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);
}