@UnityCallable
  public static void Init(final String params_str) {
    Log.v(TAG, "Init(" + params_str + ")");
    UnityParams unity_params =
        UnityParams.parse(params_str, "couldn't parse init params: " + params_str);
    final String appID;
    if (unity_params.hasString("appId")) {
      appID = unity_params.getString("appId");
    } else {
      appID = Utility.getMetadataApplicationId(getUnityActivity());
    }

    FacebookSdk.setApplicationId(appID);
    FacebookSdk.sdkInitialize(
        FB.getUnityActivity(),
        new FacebookSdk.InitializeCallback() {
          @Override
          public void onInitialized() {
            final UnityMessage unityMessage = new UnityMessage("OnInitComplete");
            // If we have a cached access token send it back as well
            AccessToken token = AccessToken.getCurrentAccessToken();
            if (token != null) {
              FBLogin.addLoginParametersToMessage(unityMessage, token, null);
            } else {
              unityMessage.put("key_hash", FB.getKeyHash());
            }

            FB.ActivateApp(appID);

            unityMessage.send();
          }
        });
  }
 private FacebookAccountConnection(Activity activity) {
   changeCurrentState(StatusFacebookConn.DISCONNECTED);
   Log.i(TAGINFO, "Initializing/Disconnected");
   activityWeakReference = new WeakReference<>(activity);
   FacebookSdk.sdkInitialize(activity);
   FacebookSdk.setApplicationId(APIID);
 }
Exemple #3
0
  public static String getMetadataApplicationId(Context context) {
    Validate.notNull(context, "context");

    FacebookSdk.sdkInitialize(context);

    return FacebookSdk.getApplicationId();
  }
  /**
   * Constuctor. Intitializes the SDK and debug logs the app KeyHash that must be set up with the
   * facebook backend to allow login from the app.
   *
   * @param context the context.
   */
  public FacebookSignInProvider(final Context context) {

    if (!FacebookSdk.isInitialized()) {
      Log.d(LOG_TAG, "Initializing Facebook SDK...");
      FacebookSdk.sdkInitialize(context);
      Utils.logKeyHash(context);
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(getApplicationContext());

    setContentView(R.layout.activity_main);
    nameText = (TextView) findViewById(R.id.text_name);
    dataList = (ListView) findViewById(R.id.list_data);
    contentButton = (Button) findViewById(R.id.content_button);
    fbbutton = (LoginButton) findViewById(R.id.login_button);

    fbbutton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            onFblogin();
          }
        });
    if (AccessToken.getCurrentAccessToken() != null) {
      contentButton.setVisibility(View.VISIBLE);
      contentButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              access_token = AccessToken.getCurrentAccessToken();
              getFacebookData();
            }
          });
    }
  }
  @Override
  public void onCreate() {
    super.onCreate();
    // Register your parse models here
    ParseObject.registerSubclass(Address.class);
    ParseObject.registerSubclass(Gym.class);
    ParseObject.registerSubclass(Message.class);
    ParseObject.registerSubclass(SimpleUser.class);
    ParseObject.registerSubclass(Trainer.class);
    ParseObject.registerSubclass(Review.class);
    ParseObject.registerSubclass(TrainerSlots.class);
    ParseObject.registerSubclass(BlockedSlots.class);
    Parse.enableLocalDatastore(this);
    Parse.initialize(this, APPLICATION_ID, CLIENT_KEY);

    ParsePush.subscribeInBackground(
        "",
        new SaveCallback() {
          @Override
          public void done(ParseException e) {
            if (e == null) {
              Log.d("com.parse.push", "successfully subscribed to the broadcast channel.");
              PushService.setDefaultPushCallback(
                  getBaseContext(),
                  ChatActivity.class); // change the class where u want to go after clicking on noti
              ParseInstallation.getCurrentInstallation().saveInBackground();
            } else {
              Log.e("com.parse.push", "failed to subscribe for push", e);
            }
          }
        });

    FacebookSdk.sdkInitialize(getApplicationContext());
  }
 @Override
 public void onCreate() {
   super.onCreate();
   FacebookSdk.sdkInitialize(getApplicationContext());
   configImageLoader();
   configParse();
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);
    // Mint.initAndStartSession(SplashScreenActivity.this, "0b8079db");
    FacebookSdk.sdkInitialize(getApplicationContext());
    imgLogo = (ImageView) findViewById(R.id.imgLogo);

    final float scale = getResources().getDisplayMetrics().density;
    wH_logo = (int) (200 * scale + 0.5f);

    gps = new ConfigInternetAndGPS(getApplicationContext());

    // Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.dheket);
    // url = String.format(getResources().getString(R.string.link_cekUserLogin));

    new Handler()
        .postDelayed(
            new Runnable() {
              @Override
              public void run() {
                showAlertGPS();
                /*Intent intentRedirectionGPSSettings = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                intentRedirectionGPSSettings.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                startActivityForResult(intentRedirectionGPSSettings, 0);*/
              }
            },
            SPLASH_TIME_OUT);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(getApplicationContext());
    // Updated Facebook SDK from 3.7 to 4.1

    boolean showSplash =
        getSharedPreferences("PREFERENCE", MODE_PRIVATE).getBoolean("isFirstRun", true);
    checkFirstRun();
    if (showSplash) {
      Intent intent = new Intent(getApplicationContext(), SplashActivity.class);
      startActivity(intent);
    }
    ;
    setContentView(R.layout.activity_map);
    buildGoogleApiClient();
    // Log.w("TAG", "Play services configured: " + Boolean.toString(isPlayServicesConfigured()));
    try {
      MapsInitializer.initialize(this);
    } catch (Exception e) {
      Toast.makeText(
              this,
              "Ensure that Google Play Services is properly installed and updated, or this app will continue to crash.",
              Toast.LENGTH_LONG)
          .show();
    }
    setUpMapIfNeeded();
    getActionBar().setDisplayHomeAsUpEnabled(false); // necessary to declare false
    mMap.moveCamera(
        CameraUpdateFactory.newLatLngZoom(
            new LatLng(39.952595, -75.163736),
            13)); // Town Center Philadelphia, zoom = 13. Bigger # = more zoomed in
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(getApplicationContext());
    Firebase.setAndroidContext(this);
    setContentView(R.layout.activity_main);
    ref = new Firebase("https://amber-fire-4138.firebaseio.com");

    callbackManager = CallbackManager.Factory.create();
    setContentView(R.layout.activity_main);
    loginButton = (LoginButton) findViewById(R.id.login_button);
    loginButton.registerCallback(
        callbackManager,
        new FacebookCallback<LoginResult>() {
          @Override
          public void onSuccess(LoginResult loginResult) {
            onFacebookAccessTokenChange(loginResult.getAccessToken());
            // App code
          }

          @Override
          public void onCancel() {
            // App code
          }

          @Override
          public void onError(FacebookException exception) {
            // App code
          }
        });
  }
Exemple #11
0
  @Override
  public void onCreate() {
    super.onCreate();
    mInstance = this;

    AnalyticsTrackers.initialize(this);
    AnalyticsTrackers.getInstance().get(AnalyticsTrackers.Target.APP);

    /*facebook*/
    FacebookSdk.sdkInitialize(getApplicationContext());
    try {
      PackageInfo info =
          getPackageManager()
              .getPackageInfo(
                  "com.jukesolutions.olahdana", // replace with your unique package name
                  PackageManager.GET_SIGNATURES);
      for (Signature signature : info.signatures) {
        MessageDigest md = MessageDigest.getInstance("SHA");
        md.update(signature.toByteArray());
        Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
      }
    } catch (PackageManager.NameNotFoundException e) {

    } catch (NoSuchAlgorithmException e) {

    }
  }
Exemple #12
0
 private void checkToolTipSettings() {
   switch (toolTipMode) {
     case AUTOMATIC:
       // kick off an async request
       final String appId = Utility.getMetadataApplicationId(getContext());
       FacebookSdk.getExecutor()
           .execute(
               new Runnable() {
                 @Override
                 public void run() {
                   final FetchedAppSettings settings = Utility.queryAppSettings(appId, false);
                   getActivity()
                       .runOnUiThread(
                           new Runnable() {
                             @Override
                             public void run() {
                               showToolTipPerSettings(settings);
                             }
                           });
                 }
               });
       break;
     case DISPLAY_ALWAYS:
       String toolTipString = getResources().getString(R.string.com_facebook_tooltip_default);
       displayToolTip(toolTipString);
       break;
     case NEVER_DISPLAY:
       break;
   }
 }
Exemple #13
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(getActivity().getApplicationContext());
    callbackManager = CallbackManager.Factory.create();
    dbhandler = new databaseHandler(getActivity().getApplicationContext(), "SQLite", null, 1);
    database = dbhandler.getWritableDatabase();

    accessTokenTracker =
        new AccessTokenTracker() {
          @Override
          protected void onCurrentAccessTokenChanged(AccessToken oldToken, AccessToken newToken) {}
        };

    profileTracker =
        new ProfileTracker() {
          @Override
          protected void onCurrentProfileChanged(Profile oldProfile, Profile newProfile) {
            if (newProfile != null) {
              name = newProfile.getName();
              displayMessage(name);
            }
          }
        };

    accessTokenTracker.startTracking();
    profileTracker.startTracking();
  }
Exemple #14
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(getApplicationContext());
    setContentView(R.layout.activity_login);

    SignInButton button = (SignInButton) findViewById(R.id.google_login);
    button.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            pickUserAccount();
          }
        });

    callbackManager = CallbackManager.Factory.create();
    fbButton = (LoginButton) findViewById(R.id.facebook_login);

    fbButton.registerCallback(
        callbackManager,
        new FacebookCallback<LoginResult>() {
          @Override
          public void onSuccess(LoginResult loginResult) {
            Log.d("LoginActivity", loginResult.getAccessToken().getToken());
            mBoundService.sendJOIN("fb", loginResult.getAccessToken().getToken());
          }

          @Override
          public void onCancel() {}

          @Override
          public void onError(FacebookException error) {}
        });
  }
 private Attachment(UUID uuid, Bitmap bitmap, Uri uri) {
   String attachmentUrl;
   boolean z = true;
   this.callId = uuid;
   this.bitmap = bitmap;
   this.originalUri = uri;
   if (uri != null) {
     String scheme = uri.getScheme();
     if ("content".equalsIgnoreCase(scheme)) {
       this.isContentUri = true;
       if (uri.getAuthority() == null || uri.getAuthority().startsWith("media")) {
         z = false;
       }
       this.shouldCreateFile = z;
     } else if ("file".equalsIgnoreCase(uri.getScheme())) {
       this.shouldCreateFile = true;
     } else if (!Utility.isWebUri(uri)) {
       throw new FacebookException("Unsupported scheme for media Uri : " + scheme);
     }
   } else if (bitmap != null) {
     this.shouldCreateFile = true;
   } else {
     throw new FacebookException("Cannot share media without a bitmap or Uri set");
   }
   this.attachmentName = !this.shouldCreateFile ? null : UUID.randomUUID().toString();
   if (this.shouldCreateFile) {
     attachmentUrl =
         FacebookContentProvider.getAttachmentUrl(
             FacebookSdk.getApplicationId(), uuid, this.attachmentName);
   } else {
     attachmentUrl = this.originalUri.toString();
   }
   this.attachmentUrl = attachmentUrl;
 }
Exemple #16
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   // Initialize the SDK of FB and constructing the callbackmanager
   FacebookSdk.sdkInitialize(getActivity().getApplicationContext());
   mCallbackManager = CallbackManager.Factory.create();
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(this);
    setContentView(R.layout.activity_log_in);

    // setViewObject();
    // setListner();

    callbackManager = CallbackManager.Factory.create();
    // LoginButtonはFacebookSDKに含まれたButtonウィジェットの拡張ウィジェット。
    loginButton = (LoginButton) findViewById(R.id.login_btn_facebook);
    // APIから取得したいユーザー情報の種類を指定し、パーミッションを許可する。
    List<String> permissionNeeds =
        Arrays.asList("user_photos", "email", "user_birthday", "public_profile");
    loginButton.setReadPermissions(permissionNeeds);

    loginButton.registerCallback(
        callbackManager,
        new FacebookCallback<LoginResult>() {
          @Override
          public void onSuccess(LoginResult loginResult) {
            System.out.println("");
            GraphRequest request =
                GraphRequest.newMeRequest(
                    loginResult.getAccessToken(),
                    new GraphRequest.GraphJSONObjectCallback() {
                      @Override
                      public void onCompleted(JSONObject object, GraphResponse response) {
                        // API連携に成功し、ログイン状態になったら、下記のようなゲッター関数により、ユーザー情報を取得することが出来る。
                        try {
                          String id = object.getString("id");
                          String name = object.getString("name");
                          String email = object.getString("email");
                          String gender = object.getString("gender");
                          String birthday = object.getString("birthday");
                          System.out.println(name);
                        } catch (JSONException e) {
                          e.printStackTrace();
                        }
                      }
                    });
            Bundle parameters = new Bundle();
            parameters.putString("fields", "id,name,email,gender, birthday");
            request.setParameters(parameters);
            request.executeAsync();
          }

          @Override
          public void onCancel() {
            System.out.println("onCancel");
          }

          @Override
          public void onError(FacebookException exception) {
            Log.v("LoginActivity", exception.toString());
          }
        });
  }
 public void writeSourceApplicationInfoToDisk() {
   SharedPreferences sharedPreferences =
       PreferenceManager.getDefaultSharedPreferences(FacebookSdk.getApplicationContext());
   SharedPreferences.Editor editor = sharedPreferences.edit();
   editor.putString(CALL_APPLICATION_PACKAGE_KEY, this.callingApplicationPackage);
   editor.putBoolean(OPENED_BY_APP_LINK_KEY, this.openedByApplink);
   editor.apply();
 }
 public static void clearSavedSourceApplicationInfoFromDisk() {
   SharedPreferences sharedPreferences =
       PreferenceManager.getDefaultSharedPreferences(FacebookSdk.getApplicationContext());
   SharedPreferences.Editor editor = sharedPreferences.edit();
   editor.remove(CALL_APPLICATION_PACKAGE_KEY);
   editor.remove(OPENED_BY_APP_LINK_KEY);
   editor.apply();
 }
 @Nullable
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   FacebookSdk.sdkInitialize(getContext());
   return inflater.inflate(R.layout.fragment_createuser, container, false);
 }
 @Override
 public void onCreate() {
   super.onCreate();
   app = this;
   Firebase.setAndroidContext(this);
   mFirebaseRef = new Firebase(this.getString(R.string.firebase_url));
   FacebookSdk.sdkInitialize(this);
 }
 @Override
 public void onCreate() {
   super.onCreate();
   Fabric.with(this, new Crashlytics());
   AppApi.createInstance(getApplicationContext());
   FacebookSdk.sdkInitialize(getApplicationContext());
   Fresco.initialize(this);
 }
  private static int getSessionTimeoutInSeconds() {
    FetchedAppSettings settings =
        FetchedAppSettingsManager.getAppSettingsWithoutQuery(FacebookSdk.getApplicationId());
    if (settings == null) {
      return Constants.getDefaultAppEventsSessionTimeoutInSeconds();
    }

    return settings.getSessionTimeoutInSeconds();
  }
  @Override
  boolean tryAuthorize(final LoginClient.Request request) {
    Bundle parameters = new Bundle();
    if (!Utility.isNullOrEmpty(request.getPermissions())) {
      String scope = TextUtils.join(",", request.getPermissions());
      parameters.putString(ServerProtocol.DIALOG_PARAM_SCOPE, scope);
      addLoggingExtra(ServerProtocol.DIALOG_PARAM_SCOPE, scope);
    }

    DefaultAudience audience = request.getDefaultAudience();
    parameters.putString(
        ServerProtocol.DIALOG_PARAM_DEFAULT_AUDIENCE, audience.getNativeProtocolAudience());

    AccessToken previousToken = AccessToken.getCurrentAccessToken();
    String previousTokenString = previousToken != null ? previousToken.getToken() : null;
    if (previousTokenString != null && (previousTokenString.equals(loadCookieToken()))) {
      parameters.putString(ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, previousTokenString);
      // Don't log the actual access token, just its presence or absence.
      addLoggingExtra(
          ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, AppEventsConstants.EVENT_PARAM_VALUE_YES);
    } else {
      // The call to clear cookies will create the first instance of CookieSyncManager if
      // necessary
      Utility.clearFacebookCookies(loginClient.getActivity());
      addLoggingExtra(
          ServerProtocol.DIALOG_PARAM_ACCESS_TOKEN, AppEventsConstants.EVENT_PARAM_VALUE_NO);
    }

    WebDialog.OnCompleteListener listener =
        new WebDialog.OnCompleteListener() {
          @Override
          public void onComplete(Bundle values, FacebookException error) {
            onWebDialogComplete(request, values, error);
          }
        };

    e2e = LoginClient.getE2E();
    addLoggingExtra(ServerProtocol.DIALOG_PARAM_E2E, e2e);

    FragmentActivity fragmentActivity = loginClient.getActivity();
    WebDialog.Builder builder =
        new AuthDialogBuilder(fragmentActivity, request.getApplicationId(), parameters)
            .setE2E(e2e)
            .setIsRerequest(request.isRerequest())
            .setReauthenticate(request.isReauthenticate())
            .setOnCompleteListener(listener)
            .setTheme(FacebookSdk.getWebDialogTheme());
    loginDialog = builder.build();

    FacebookDialogFragment dialogFragment = new FacebookDialogFragment();
    dialogFragment.setRetainInstance(true);
    dialogFragment.setDialog(loginDialog);
    dialogFragment.show(fragmentActivity.getSupportFragmentManager(), FacebookDialogFragment.TAG);

    return true;
  }
Exemple #25
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_capture);

    CalligraphyConfig.initDefault(
        new CalligraphyConfig.Builder()
            .setDefaultFontPath("fonts/Roboto-RobotoRegular.ttf")
            .setFontAttrId(R.attr.fontPath)
            .build());

    ButterKnife.bind(this);

    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    toolbar.setNavigationIcon(R.drawable.icn_back);
    title.setText("COLLECTIONS");

    FacebookSdk.sdkInitialize(this);
    callbackManager = CallbackManager.Factory.create();
    shareDialog = new ShareDialog(this);
    // this part is optional
    shareDialog.registerCallback(
        callbackManager,
        new FacebookCallback<Sharer.Result>() {
          @Override
          public void onSuccess(Sharer.Result result) {
            if (result.getPostId() != null) {
              Toast.makeText(getBaseContext(), "Success", Toast.LENGTH_SHORT).show();
            } else {
              Toast.makeText(getBaseContext(), "Problem posting story", Toast.LENGTH_SHORT).show();
            }
          }

          @Override
          public void onCancel() {
            Toast.makeText(getBaseContext(), "Cancelled", Toast.LENGTH_SHORT).show();
          }

          @Override
          public void onError(FacebookException e) {
            Toast.makeText(getBaseContext(), "Error sharing", Toast.LENGTH_SHORT).show();
          }
        });

    song_name.setText(getIntent().getStringExtra("title").toUpperCase());
    Picasso.with(getBaseContext())
        .load(getIntent().getStringExtra("image_link"))
        .placeholder(R.drawable.speaker_icn1)
        .into(album_art);
    note.setText(getIntent().getStringExtra("note"));

    playlist.setText(Html.fromHtml("or <u>Add to Playlist</u>"));
  }
 static synchronized File getAttachmentsDirectory() {
   File file;
   synchronized (NativeAppCallAttachmentStore.class) {
     if (attachmentsDirectory == null) {
       attachmentsDirectory =
           new File(FacebookSdk.getApplicationContext().getCacheDir(), ATTACHMENTS_DIR_NAME);
     }
     file = attachmentsDirectory;
   }
   return file;
 }
  private String getAccessToken() {

    FacebookSdk.sdkInitialize(StudentAssistApplication.getAppContext());

    if (AccessToken.getCurrentAccessToken() != null
        && !AccessToken.getCurrentAccessToken().isExpired()) {
      String fbToken = AccessToken.getCurrentAccessToken().getToken();
      return fbToken;
    }

    return "";
  }
  @Override
  public void onCreate() {
    super.onCreate();
    FacebookSdk.sdkInitialize(getApplicationContext());
    Firebase.setAndroidContext(this);
    Firebase.getDefaultConfig().setPersistenceEnabled(true);
    Firebase firebase = new Firebase(Constants.FIREBASE_REF);
    firebase.keepSynced(true);

    if (BuildConfig.DEBUG) {
      Timber.plant(new Timber.DebugTree());
    }
  }
  private void initFacebook() {
    // Initialize the SDK before executing any other operations,
    // especially, if you're using Facebook UI elements.
    FacebookSdk.sdkInitialize(getApplicationContext());
    callbackManager = CallbackManager.Factory.create();
    shareDialog = new ShareDialog(this);

    // You need this method to be used only once to configure
    // your key hash in your App Console at
    // developers.facebook.com/apps
    Utils utils = new Utils(this);
    utils.getFbKeyHash(getApplicationContext().getPackageName());
  }
 @Override
 public void onCreate() {
   super.onCreate();
   Parse.enableLocalDatastore(this);
   ParseObject.registerSubclass(Circle.class);
   ParseObject.registerSubclass(UserCircle.class);
   ParseObject.registerSubclass(Friend.class);
   FacebookSdk.sdkInitialize(getApplicationContext());
   Parse.initialize(
       this,
       "Bugsei9yjtBNjH51JSerSEniB895r1zLA3NwFDUO",
       "ilswrJMAc26LQCRptGaMn5XiH5uVTIHrkfLP82W3");
   ParseFacebookUtils.initialize(this);
 }