Java Code Examples for com.facebook.FacebookSdk#sdkInitialize()
The following examples show how to use
com.facebook.FacebookSdk#sdkInitialize() .
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: Login.java From UberClone with MIT License | 7 votes |
private void setupFacebookStuff() { // This should normally be on your application class FacebookSdk.sdkInitialize(getApplicationContext()); mLoginManager = LoginManager.getInstance(); mFacebookCallbackManager = CallbackManager.Factory.create(); LoginManager.getInstance().registerCallback(mFacebookCallbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { //login firebaseHelper.registerByFacebookAccount(); } @Override public void onCancel() { Toast.makeText(Login.this,"The login was canceled",Toast.LENGTH_SHORT).show(); } @Override public void onError(FacebookException error) { Toast.makeText(Login.this,"There was an error in the login",Toast.LENGTH_SHORT).show(); } }); }
Example 2
Source File: FirstLaunchAnalytics.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
public Completable sendAppStart(android.app.Application application, SharedPreferences sharedPreferences, IdsRepository idsRepository) { FacebookSdk.sdkInitialize(application); AppEventsLogger.activateApp(application); AppEventsLogger.newLogger(application); return idsRepository.getUniqueIdentifier() .doOnSuccess(AppEventsLogger::setUserID) .toObservable() .doOnNext(__ -> setupRakamFirstLaunchSuperProperty( SecurePreferences.isFirstRun(sharedPreferences))) .doOnNext(__ -> sendPlayProtectEvent()) .doOnNext(__ -> setupDimensions(application)) .filter(__ -> SecurePreferences.isFirstRun(sharedPreferences)) .doOnNext( __ -> sendFirstLaunchEvent(utmSource, utmMedium, utmCampaign, utmContent, entryPoint)) .toCompletable() .subscribeOn(Schedulers.io()); }
Example 3
Source File: ApplicationModule.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
@Singleton @Provides AptoideAccountManager provideAptoideAccountManager(AdultContent adultContent, GoogleApiClient googleApiClient, StoreManager storeManager, AccountService accountService, LoginPreferences loginPreferences, AccountPersistence accountPersistence, @Named("facebookLoginPermissions") List<String> facebookPermissions) { FacebookSdk.sdkInitialize(application); return new AptoideAccountManager.Builder().setAccountPersistence( new MatureContentPersistence(accountPersistence, adultContent)) .setAccountService(accountService) .setAdultService(adultContent) .registerSignUpAdapter(GoogleSignUpAdapter.TYPE, new GoogleSignUpAdapter(googleApiClient, loginPreferences)) .registerSignUpAdapter(FacebookSignUpAdapter.TYPE, new FacebookSignUpAdapter(facebookPermissions, LoginManager.getInstance(), loginPreferences)) .setStoreManager(storeManager) .build(); }
Example 4
Source File: AndelaTrackChallenge.java From andela-crypto-app with Apache License 2.0 | 6 votes |
@Override public void onCreate() { super.onCreate(); // plant a new debug tree Timber.plant(new Timber.DebugTree()); // init Settings Settings.init(this); // Initialize Facebook SDK FacebookSdk.sdkInitialize(getApplicationContext()); if (EXTERNAL_DIR) { // Example how you could use a custom dir in "external storage" // (Android 6+ note: give the app storage permission in app info settings) File directory = new File(Environment.getExternalStorageDirectory(), "objectbox-andelatrackchallenge"); boxStore = MyObjectBox.builder().androidContext(this).directory(directory).build(); } else { // This is the minimal setup required on Android boxStore = MyObjectBox.builder().androidContext(this).build(); } historyRepo = new HistoryRepository(this, boxStore); }
Example 5
Source File: FacebookImpl.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
public static void init() { FacebookConnect.implClass = FacebookImpl.class; permissions = new ArrayList<String>(); String permissionsStr = Display.getInstance().getProperty("facebook_permissions", ""); permissionsStr = permissionsStr.trim(); StringTokenizer token = new StringTokenizer(permissionsStr, ", "); if (token.countTokens() > 0) { try { while (token.hasMoreElements()) { String permission = (String) token.nextToken(); permission = permission.trim(); permissions.add(permission); } } catch (Exception e) { //the pattern is not valid } } FacebookSdk.sdkInitialize(AndroidNativeUtil.getContext().getApplicationContext()); }
Example 6
Source File: LoginActivity.java From social-app-android with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FacebookSdk.sdkInitialize(getApplicationContext()); setContentView(R.layout.activity_login); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); } initGoogleSignIn(); initFirebaseAuth(); initFacebookSignIn(); }
Example 7
Source File: KuteApplication.java From kute with Apache License 2.0 | 5 votes |
@Override public void onCreate() { super.onCreate(); //Previous versions of Firebase FacebookSdk.sdkInitialize(getApplicationContext()); //Newer version of Firebase if(!FirebaseApp.getApps(this).isEmpty()) { FirebaseDatabase.getInstance().setPersistenceEnabled(true); } }
Example 8
Source File: LoginActivity.java From Simple-Blog-App with MIT License | 5 votes |
private void fbInit() { FacebookSdk.sdkInitialize(getApplicationContext()); callbackManager = CallbackManager.Factory.create(); LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { Log.d("facebook:token", AccessToken.getCurrentAccessToken().getToken()); AccessToken.getCurrentAccessToken().getToken(); signInWithFacebook(loginResult.getAccessToken()); } @Override public void onCancel() { Log.d(TAG, "facebook:onCancel"); } @Override public void onError(FacebookException error) { Log.d(TAG, "facebook:onError", error); } }); fbImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { LoginManager.getInstance().logInWithReadPermissions(LoginActivity.this, Arrays.asList("email", "user_location", "user_birthday", "public_profile", "user_friends")); } }); }
Example 9
Source File: FaceBookManager.java From FimiX8-RE with MIT License | 5 votes |
public void login(Context context, final LoginCallback callback) { this.loginCallback = callback; this.mCallbackManager = Factory.create(); FacebookSdk.sdkInitialize(context); this.loginManager = LoginManager.getInstance(); this.loginManager.registerCallback(this.mCallbackManager, new FacebookCallback<LoginResult>() { public void onSuccess(LoginResult loginResult) { GraphRequest.newMeRequest(loginResult.getAccessToken(), new GraphJSONObjectCallback() { public void onCompleted(JSONObject object, GraphResponse response) { Log.i(FaceBookManager.TAG, "onCompleted: "); if (object != null) { Map<String, String> map = new HashMap(); map.put("name", object.optString("name")); map.put(BlockInfo.KEY_UID, object.optString("id")); FaceBookManager.this.loginCallback.loginSuccess(map); } } }).executeAsync(); } public void onCancel() { Log.i(FaceBookManager.TAG, "onCancel: "); } public void onError(FacebookException error) { Log.i(FaceBookManager.TAG, "onError: "); callback.loginFail(error.getMessage()); } }); LoginManager.getInstance().logInWithReadPermissions((Activity) context, Arrays.asList(new String[]{"public_profile", "user_friends"})); }
Example 10
Source File: MainActivity.java From ExamplesAndroid with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //--------------------------------------------// FacebookSdk.sdkInitialize(this);//El SDK necesita ser inicializado antes de usar cualquiera de sus métodos,pasando el contexto de la actividad(Activity) callbackManager = CallbackManager.Factory.create();//inizializamos el CallbackManager //---------------------------------------------// setContentView(R.layout.activity_main); info = (TextView) findViewById(R.id.info); loginButton = (LoginButton) findViewById(R.id.login_button); //--------------------------------------------------// loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) {//Si la autenticacion fue correcta info.setText("Login attempt success."); } @Override public void onCancel() {//Si se cancela la solicitus de login info.setText("Login attempt canceled."); } @Override public void onError(FacebookException e) {//Si ocurre un error info.setText("Login attempt failed."); } }); }
Example 11
Source File: TestApplication.java From edx-app-android with Apache License 2.0 | 5 votes |
@Override public void onCreate() { // Register Font Awesome module in android-iconify library Iconify.with(new FontAwesomeModule()); application = this; // Facebook sdk should be initialized through AndroidManifest meta data declaration but // we are generating the meta data through gradle script due to which it is necessary // to manually initialize the sdk here. // Initialize to a Fake Application ID as it will not connect to the actual API FacebookSdk.setApplicationId("1234567812345678"); FacebookSdk.sdkInitialize(getApplicationContext()); }
Example 12
Source File: FBLoginInstance.java From ShareLoginPayUtil with Apache License 2.0 | 5 votes |
public FBLoginInstance(Activity activity, final LoginListener listener, final boolean fetchUserInfo) { super(activity, listener, fetchUserInfo); if (!FacebookSdk.isInitialized()) { FacebookSdk.setApplicationId(ShareManager.CONFIG.getFbClientId()); FacebookSdk.sdkInitialize(activity.getApplicationContext()); if (BuildConfig.DEBUG) { FacebookSdk.setIsDebugEnabled(true); FacebookSdk.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS); } } callbackManager = CallbackManager.Factory.create(); }
Example 13
Source File: SignInBaseActivity.java From Expert-Android-Programming with MIT License | 4 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); FacebookSdk.sdkInitialize(getApplicationContext()); callbackManager = CallbackManager.Factory.create(); LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { // App code MyLg.e(TAG, "Get Facebook User Details"); handleFacebookAccessToken(loginResult.getAccessToken()); } @Override public void onCancel() { // App code MyLg.e(TAG, "Get Facebook onCancel"); } @Override public void onError(FacebookException exception) { // App code MyLg.e(TAG, "Get Facebook onError "); exception.printStackTrace(); } }); // Configure Google Sign In GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(getString(R.string.default_web_client_id)) .requestEmail() .build(); mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this, this) .addApi(Auth.GOOGLE_SIGN_IN_API, gso) .build(); mAuth = FirebaseAuth.getInstance(); mAuthListener = new FirebaseAuth.AuthStateListener() { @Override public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { FirebaseUser user = firebaseAuth.getCurrentUser(); if (user != null) { // User is signed in MyLg.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid()); } else { // User is signed out MyLg.d(TAG, "onAuthStateChanged:signed_out"); } onGotFirebaseUser(user); } }; }
Example 14
Source File: LetvApplication.java From letv with Apache License 2.0 | 4 votes |
public void onCreate() { super.onCreate(); PluginHelper.getInstance().applicationOnCreate(getBaseContext()); LogInfo.log("test_yang", "application init ----->begining"); StatisticsUtils.init(); LogInfo.log("test_yang", "application init ----->begining"); initChannel(); initOriginalChannelFile(); StatisticsUtils.initDoubleChannel(); FacebookSdk.sdkInitialize(getApplicationContext()); LogInfo.log("test_yang", "application init ----->begining"); boolean z = !LetvUtils.is60() || PreferencesManager.getInstance().isApplyPermissionsSuccess(); JarUtil.sHasApplyPermissionsSuccess = z; if (isMainProcess()) { LogInfo.log("test_yang", "application init ----->begining"); LogInfo.log("plugin", "主进程调用initPlugin..."); JarUtil.initPlugin(this, new OnPluginInitedListener(this) { final /* synthetic */ LetvApplication this$0; { if (HotFix.PREVENT_VERIFY) { System.out.println(VerifyLoad.class); } this.this$0 = this$0; } public void onInited() { this.this$0.mIsPluginInitedSuccess = true; if (PluginInitedCallback.mPluginInitedListener != null) { PluginInitedCallback.mPluginInitedListener.onInited(); } PluginInitedCallback.mPluginInitedListener = null; } }); } if (isPipProcess()) { LogInfo.log("zhuqiao", "call init pip"); initLetvMediaPlayerManager(); setVType(); } LogInfo.log("test_yang", "application init ----->begining"); LogInfo.log("test_yang", "application init ----->begining"); if (!hasInited()) { FlurryAgent.setLogEnabled(false); FlurryAgent.init(this, LetvConfig.getFlurryKey()); if (LetvUtils.is60()) { DownloadManager.stopDownloadService(); } } LogInfo.log("test_yang", "application init ----->end"); }
Example 15
Source File: MainApplication.java From edx-app-android with Apache License 2.0 | 4 votes |
/** * Initializes the request manager, image cache, * all third party integrations and shared components. */ private void init() { application = this; // FIXME: Disable RoboBlender to avoid annotation processor issues for now, as we already have plans to move to some other DI framework. See LEARNER-1687. // ref: https://github.com/roboguice/roboguice/wiki/RoboBlender-wiki#disabling-roboblender // ref: https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration RoboGuice.setUseAnnotationDatabases(false); injector = RoboGuice.getOrCreateBaseApplicationInjector((Application) this, RoboGuice.DEFAULT_STAGE, (Module) RoboGuice.newDefaultRoboModule(this), (Module) new EdxDefaultModule(this)); injector.injectMembers(this); EventBus.getDefault().register(new CrashlyticsCrashReportObserver()); if (config.getNewRelicConfig().isEnabled()) { EventBus.getDefault().register(new NewRelicObserver()); } // initialize NewRelic with crash reporting disabled if (config.getNewRelicConfig().isEnabled()) { //Crash reporting for new relic has been disabled NewRelic.withApplicationToken(config.getNewRelicConfig().getNewRelicKey()) .withCrashReportingEnabled(false) .start(this); } // Add Segment as an analytics provider if enabled in the config if (config.getSegmentConfig().isEnabled()) { analyticsRegistry.addAnalyticsProvider(injector.getInstance(SegmentAnalytics.class)); } if (config.getFirebaseConfig().isAnalyticsSourceFirebase()) { // Only add Firebase as an analytics provider if enabled in the config and Segment is disabled // because if Segment is enabled, we'll be using Segment's implementation for Firebase analyticsRegistry.addAnalyticsProvider(injector.getInstance(FirebaseAnalytics.class)); } if (config.getFirebaseConfig().isEnabled()) { // Firebase notification needs to initialize the FirebaseApp before // subscribe/unsubscribe to/from the topics FirebaseApp.initializeApp(this); if (config.areFirebasePushNotificationsEnabled()) { NotificationUtil.subscribeToTopics(config); } else if (!config.areFirebasePushNotificationsEnabled()) { NotificationUtil.unsubscribeFromTopics(config); } } registerReceiver(new NetworkConnectivityReceiver(), new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); registerReceiver(new NetworkConnectivityReceiver(), new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION)); checkIfAppVersionUpgraded(this); // Register Font Awesome module in android-iconify library Iconify.with(new FontAwesomeModule()); CalligraphyConfig.initDefault(new CalligraphyConfig.Builder() .setDefaultFontPath("fonts/OpenSans-Regular.ttf") .setFontAttrId(R.attr.fontPath) .build() ); // Init Branch if (config.getBranchConfig().isEnabled()) { Branch.getAutoInstance(this); } // Force Glide to use our version of OkHttp which now supports TLS 1.2 out-of-the-box for // Pre-Lollipop devices if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { Glide.get(this).getRegistry().replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(injector.getInstance(OkHttpClientProvider.class).get())); } // Initialize Facebook SDK boolean isOnZeroRatedNetwork = NetworkUtil.isOnZeroRatedNetwork(getApplicationContext(), config); if (!isOnZeroRatedNetwork && config.getFacebookConfig().isEnabled()) { // Facebook sdk should be initialized through AndroidManifest meta data declaration but // we are generating the meta data through gradle script due to which it is necessary // to manually initialize the sdk here. FacebookSdk.setApplicationId(config.getFacebookConfig().getFacebookAppId()); FacebookSdk.sdkInitialize(getApplicationContext()); } if (PermissionsUtil.checkPermissions(Manifest.permission.WRITE_EXTERNAL_STORAGE, this)) { deleteExtraDownloadedFiles(); } }
Example 16
Source File: LogoutHelper.java From social-app-android with Apache License 2.0 | 4 votes |
private static void logoutFacebook(Context context) { FacebookSdk.sdkInitialize(context); LoginManager.getInstance().logOut(); }
Example 17
Source File: SocialLoginManager.java From SocialLoginManager with Apache License 2.0 | 4 votes |
public static void init(Application application) { FacebookSdk.sdkInitialize(application.getApplicationContext()); }
Example 18
Source File: MainActivity.java From HaiNaBaiChuan with Apache License 2.0 | 4 votes |
@Override protected void beforeSetContentView() { super.beforeSetContentView(); FacebookSdk.sdkInitialize(getApplicationContext()); }
Example 19
Source File: Utility.java From kognitivo with Apache License 2.0 | 3 votes |
public static String getMetadataApplicationId(Context context) { Validate.notNull(context, "context"); FacebookSdk.sdkInitialize(context); return FacebookSdk.getApplicationId(); }
Example 20
Source File: Stockita.java From stockita-point-of-sale with MIT License | 3 votes |
@Override public void onCreate() { super.onCreate(); // Track App installs and App opens by facebook FacebookSdk.sdkInitialize(getApplicationContext()); AppEventsLogger.activateApp(this); // Enable data persistence Firebase. FirebaseDatabase.getInstance().setPersistenceEnabled(true); }