private void initialize() throws FileNotFoundException { ParcelFileDescriptor fileDescriptor = null; try { if (Utility.isFileUri(videoUri)) { fileDescriptor = ParcelFileDescriptor.open( new File(videoUri.getPath()), ParcelFileDescriptor.MODE_READ_ONLY); videoSize = fileDescriptor.getStatSize(); videoStream = new ParcelFileDescriptor.AutoCloseInputStream(fileDescriptor); } else if (Utility.isContentUri(videoUri)) { videoSize = Utility.getContentSize(videoUri); videoStream = FacebookSdk .getApplicationContext() .getContentResolver() .openInputStream(videoUri); } else { throw new FacebookException("Uri must be a content:// or file:// uri"); } } catch (FileNotFoundException e) { Utility.closeQuietly(videoStream); throw e; } }
private static void shareToMessenger20150314( Activity activity, int requestCode, ShareToMessengerParams shareToMessengerParams) { try { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); shareIntent.setPackage(PACKAGE_NAME); shareIntent.putExtra(Intent.EXTRA_STREAM, shareToMessengerParams.uri); shareIntent.setType(shareToMessengerParams.mimeType); String appId = FacebookSdk.getApplicationId(); if (appId != null) { shareIntent.putExtra(EXTRA_PROTOCOL_VERSION, PROTOCOL_VERSION_20150314); shareIntent.putExtra(EXTRA_APP_ID, appId); shareIntent.putExtra(EXTRA_METADATA, shareToMessengerParams.metaData); shareIntent.putExtra(EXTRA_EXTERNAL_URI, shareToMessengerParams.externalUri); } activity.startActivityForResult(shareIntent, requestCode); } catch (ActivityNotFoundException e) { Intent openMessenger = activity.getPackageManager().getLaunchIntentForPackage(PACKAGE_NAME); activity.startActivity(openMessenger); } }
/** * Finishes the activity and returns the media item the user picked to Messenger. * * @param activity the activity that received the original intent from Messenger * @param shareToMessengerParams parameters for what to share */ public static void finishShareToMessenger( Activity activity, ShareToMessengerParams shareToMessengerParams) { Intent originalIntent = activity.getIntent(); Set<String> categories = originalIntent.getCategories(); if (categories == null) { // This shouldn't happen. activity.setResult(Activity.RESULT_CANCELED, null); activity.finish(); return; } if (categories.contains(ORCA_THREAD_CATEGORY_20150314)) { Bundle appLinkExtras = AppLinks.getAppLinkExtras(originalIntent); Intent resultIntent = new Intent(); if (categories.contains(ORCA_THREAD_CATEGORY_20150314)) { resultIntent.putExtra(EXTRA_PROTOCOL_VERSION, MessengerUtils.PROTOCOL_VERSION_20150314); String threadToken = appLinkExtras.getString(MessengerUtils.EXTRA_THREAD_TOKEN_KEY); resultIntent.putExtra(EXTRA_THREAD_TOKEN_KEY, threadToken); } else { throw new RuntimeException(); // Can't happen. } resultIntent.setDataAndType(shareToMessengerParams.uri, shareToMessengerParams.mimeType); resultIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); resultIntent.putExtra(EXTRA_APP_ID, FacebookSdk.getApplicationId()); resultIntent.putExtra(EXTRA_METADATA, shareToMessengerParams.metaData); resultIntent.putExtra(EXTRA_EXTERNAL_URI, shareToMessengerParams.externalUri); activity.setResult(Activity.RESULT_OK, resultIntent); activity.finish(); } else { // This shouldn't happen. activity.setResult(Activity.RESULT_CANCELED, null); activity.finish(); } }
/** * Asynchronously fetches app link information that might have been stored for use after * installation of the app * * @param context The context * @param applicationId Facebook application Id. If null, it is taken from the manifest * @param completionHandler CompletionHandler to be notified with the AppLinkData object or null * if none is available. Must not be null. */ public static void fetchDeferredAppLinkData( Context context, String applicationId, final CompletionHandler completionHandler) { Validate.notNull(context, "context"); Validate.notNull(completionHandler, "completionHandler"); if (applicationId == null) { applicationId = Utility.getMetadataApplicationId(context); } Validate.notNull(applicationId, "applicationId"); final Context applicationContext = context.getApplicationContext(); final String applicationIdCopy = applicationId; FacebookSdk.getExecutor().execute(new Runnable() { @Override public void run() { fetchDeferredAppLinkFromServer( applicationContext, applicationIdCopy, completionHandler); } }); }
public static void setupAppCallForErrorResult(AppCall appCall, FacebookException exception) { if (exception == null) { return; } Validate.hasFacebookActivity(FacebookSdk.getApplicationContext()); Intent errorResultIntent = new Intent(); errorResultIntent.setClass(FacebookSdk.getApplicationContext(), FacebookActivity.class); errorResultIntent.setAction(FacebookActivity.PASS_THROUGH_CANCEL_ACTION); NativeProtocol.setupProtocolRequestIntent( errorResultIntent, appCall.getCallId().toString(), null, NativeProtocol.getLatestKnownVersion(), NativeProtocol.createBundleForException(exception)); appCall.setRequestIntent(errorResultIntent); }
public static void setupAppCallForWebDialog( AppCall appCall, String actionName, Bundle parameters) { Validate.hasFacebookActivity(FacebookSdk.getApplicationContext()); Validate.hasInternetPermissions(FacebookSdk.getApplicationContext()); Bundle intentParameters = new Bundle(); intentParameters.putString(NativeProtocol.WEB_DIALOG_ACTION, actionName); intentParameters.putBundle(NativeProtocol.WEB_DIALOG_PARAMS, parameters); Intent webDialogIntent = new Intent(); NativeProtocol.setupProtocolRequestIntent( webDialogIntent, appCall.getCallId().toString(), actionName, NativeProtocol.getLatestKnownVersion(), intentParameters); webDialogIntent.setClass(FacebookSdk.getApplicationContext(), FacebookActivity.class); webDialogIntent.setAction(FacebookDialogFragment.TAG); appCall.setRequestIntent(webDialogIntent); }
private static void processAttachmentFile( Uri imageUri, boolean isContentUri, File outputFile) throws IOException { FileOutputStream outputStream = new FileOutputStream(outputFile); try { InputStream inputStream = null; if (!isContentUri) { inputStream = new FileInputStream(imageUri.getPath()); } else { inputStream = FacebookSdk .getApplicationContext() .getContentResolver() .openInputStream(imageUri); } Utility.copyAndCloseInputStream(inputStream, outputStream); } finally { Utility.closeQuietly(outputStream); } }
public static long getContentSize(final Uri contentUri) { Cursor cursor = null; try { cursor = FacebookSdk .getApplicationContext() .getContentResolver() .query(contentUri, null, null, null, null); int sizeIndex = cursor.getColumnIndex(OpenableColumns.SIZE); cursor.moveToFirst(); return cursor.getLong(sizeIndex); } finally { if (cursor != null) { cursor.close(); } } }
public static void updateAllAvailableProtocolVersionsAsync() { if (!protocolVersionsAsyncUpdating.compareAndSet(false, true)) { return; } FacebookSdk.getExecutor().execute(new Runnable() { @Override public void run() { try { for (NativeAppInfo appInfo : facebookAppInfoList) { appInfo.fetchAvailableVersions(true); } } finally { protocolVersionsAsyncUpdating.set(false); } } }); }
protected void showImpl(final CONTENT content, final Object mode) { AppCall appCall = createAppCallForMode(content, mode); if (appCall != null) { if (fragment != null) { DialogPresenter.present(appCall, fragment); } else { DialogPresenter.present(appCall, activity); } } else { // If we got a null appCall, then the derived dialog code is doing something wrong String errorMessage = "No code path should ever result in a null appCall"; Log.e(TAG, errorMessage); if (FacebookSdk.isDebugEnabled()) { throw new IllegalStateException(errorMessage); } } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (!FacebookSdk.isInitialized()) { FacebookSdk.sdkInitialize(getApplicationContext()); AppEventsLogger.activateApp(getActivity().getApplication()); } // Initialize Firebase Auth fireBaseAuth = FirebaseAuth.getInstance(); fireBaseAuth.signOut(); facebookCallbackManager = CallbackManager.Factory.create(); registerFirebase(); registerFacebookCallback(); LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("email", "public_profile")); }
private static TreeSet<Integer> fetchAllAvailableProtocolVersionsForAppInfo(NativeAppInfo appInfo) { TreeSet<Integer> allAvailableVersions = new TreeSet(); ContentResolver contentResolver = FacebookSdk.getApplicationContext().getContentResolver(); String[] projection = new String[]{"version"}; Uri uri = buildPlatformProviderVersionURI(appInfo); Cursor c = null; try { if (FacebookSdk.getApplicationContext().getPackageManager().resolveContentProvider(appInfo.getPackage() + PLATFORM_PROVIDER, 0) != null) { c = contentResolver.query(uri, projection, null, null, null); if (c != null) { while (c.moveToNext()) { allAvailableVersions.add(Integer.valueOf(c.getInt(c.getColumnIndex("version")))); } } } if (c != null) { c.close(); } return allAvailableVersions; } catch (Throwable th) { if (c != null) { c.close(); } } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FacebookSdk.sdkInitialize(getApplicationContext()); callbackManager = CallbackManager.Factory.create(); if(AppController.USER_ID != null && AppController.USER_TOKEN != null) { new CountDownTimer(1000, 100) { public void onTick(long millisUntilFinished) { } public void onFinish() { goActivityMain(); } }.start(); } else { changeToLoginView(); } pref = getSharedPreferences(CONST.PREF_NAME, MODE_PRIVATE); editor = pref.edit(); }
private void initFBSdk() { if (!FacebookSdk.isInitialized()) { FacebookSdk.setApplicationId(ApiObjects.facebook.get("app_id")); FacebookSdk.sdkInitialize(getActivity().getApplicationContext()); } callbackManager = CallbackManager.Factory.create(); profileTracker = new ProfileTracker() { @Override protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) { if (eventHandler != null) { if (currentProfile != null) eventHandler.onFacebookLoggedIn(); } } }; }
@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); }
@Override public void onCreate() { super.onCreate(); if (BuildConfig.CRASH_REPORTS) { Fabric.with(this, new Crashlytics()); } INSTANCE = this; // if(LeakCanary.isInAnalyzerProcess(this)) // return; // LeakCanary.install(this); FacebookSdk.sdkInitialize(getApplicationContext()); AppEventsLogger.activateApp(this); UserToken.getInstance().initSharedPreferences(this); }
@Override public void onCreate() { super.onCreate(); sInstance = this; RealmConfiguration configuration = new RealmConfiguration.Builder(this).deleteRealmIfMigrationNeeded() .migration(new RealmMigration() { @Override public void migrate(DynamicRealm realm, long oldVersion, long newVersion) { } }) .name("chao.realm") .build(); Realm.setDefaultConfiguration(configuration); Stetho.initialize(Stetho.newInitializerBuilder(this) .enableDumpapp(Stetho.defaultDumperPluginsProvider(this)) .enableWebKitInspector(RealmInspectorModulesProvider.builder(this).build()) .build()); FacebookSdk.sdkInitialize(getApplicationContext()); AppEventsLogger.activateApp(this); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_support_developer); FacebookSdk.sdkInitialize(getApplicationContext()); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); toolbar.setNavigationIcon(R.drawable.ic_action_navigation_arrow_back_inverted); toolbar.setTitleTextColor(ContextCompat.getColor(this, android.R.color.white)); setTitle(R.string.support_developers_string); LikeView likeView = (LikeView) findViewById(R.id.facebookLikeView); if (likeView != null) { likeView.setObjectIdAndType(NetworkConstants.FACEBOOK_PAGE_URL, LikeView.ObjectType.PAGE); likeView.setLikeViewStyle(LikeView.Style.BOX_COUNT); } findViewById(R.id.buttonReportBugs).setOnClickListener(this); }
@Override public void onCreate() { isLoaded = false; applicationContext = getApplicationContext(); YandexMetrica.activate(getApplicationContext(), Config.YANDEX_METRICS_API_KEY); YandexMetrica.enableActivityAutoTracking(this); FacebookSdk.sdkInitialize(applicationContext); LoginMaster.getInstance().init(); new Prefs.Builder() .setContext(this) .setMode(ContextWrapper.MODE_PRIVATE) .setPrefsName(getPackageName()) .setUseDefaultSharedPreference(true).build(); super.onCreate(); }
private void configureFacebookLogin(){ FacebookSdk.sdkInitialize(context.getApplicationContext()); ssFacebookCallbackManager = CallbackManager.Factory.create(); LoginManager.getInstance().registerCallback(ssFacebookCallbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { handleFacebookAccessToken(loginResult.getAccessToken()); } @Override public void onCancel() { // TODO: Handle unsuccessful / cancel } @Override public void onError(FacebookException exception) { loginFailed(exception.getMessage()); } }); }
@Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); FacebookSdk.sdkInitialize(getActivity().getApplicationContext()); callbackManager = CallbackManager.Factory.create(); accessTokenTracker = new AccessTokenTracker() { @Override protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken currentAccessToken) { } }; profileTracker = new ProfileTracker() { @Override protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) { //Toast.makeText(getActivity(), "newProfile", Toast.LENGTH_SHORT).show(); //displayMessage(currentProfile); } }; accessTokenTracker.startTracking(); profileTracker.startTracking(); }
@Override public void onCreate() { super.onCreate(); Fabric.with(this, new Crashlytics()); Timber.plant(new Timber.DebugTree()); RealmConfiguration configuration = new RealmConfiguration.Builder(this) .deleteRealmIfMigrationNeeded() .build(); Realm.setDefaultConfiguration(configuration); FacebookSdk.sdkInitialize(getApplicationContext()); Timber.i("Signature " + FacebookSdk.getApplicationSignature(getApplicationContext())); }
@Override public void onCreate() { super.onCreate(); Log.d("Myapp " , " start"); // _instance = this; FirebaseApp.getApps(this); //enable the offline capability for firebase if (!FirebaseApp.getApps(this).isEmpty()) { FirebaseDatabase.getInstance().setPersistenceEnabled(true); } EmojiManager.install(new EmojiOneProvider()); Picasso.Builder builder = new Picasso.Builder(this); // builder.downloader(new OkHttpDownloader(this,Integer.MAX_VALUE)); Picasso built = builder.build(); // built.setIndicatorsEnabled(false); // built.setLoggingEnabled(true); Picasso.setSingletonInstance(built); // Initialize the SDK before executing any other operations, FacebookSdk.sdkInitialize(getApplicationContext()); AppEventsLogger.activateApp(this); }
@Override public void onCreate() { super.onCreate(); Fresco.initialize(this); FacebookSdk.sdkInitialize(getApplicationContext()); AppEventsLogger.activateApp(this); ContentResolver.addPeriodicSync( AuthenticationManager.getSyncAccount(getApplicationContext()), ApparelContract.AUTHORITY, Bundle.EMPTY, SYNC_INTERVAL); }
private static void initGlobalObjects(Context context, Options options) { GlobalObjectRegistry.addObject(OpenHelperManager.getHelper(context, DatabaseHelper.class)); Gson gson = new GsonBuilder() .setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE) .create(); GlobalObjectRegistry.addObject(gson); ImageLoader.init(context); EmbeddedSocialServiceProvider serviceProvider = new EmbeddedSocialServiceProvider(context); GlobalObjectRegistry.addObject(EmbeddedSocialServiceProvider.class, serviceProvider); GlobalObjectRegistry.addObject(new Preferences(context)); GlobalObjectRegistry.addObject(new RequestInfoProvider(context)); GlobalObjectRegistry.addObject(new UserAccount(context)); GlobalObjectRegistry.addObject(new NotificationController(context)); NetworkAvailability networkAccessibility = new NetworkAvailability(); networkAccessibility.startMonitoring(context); GlobalObjectRegistry.addObject(networkAccessibility); FacebookSdk.sdkInitialize(context); FacebookSdk.setApplicationId(options.getFacebookApplicationId()); }
@Override public void onCreate() { super.onCreate(); Log.i(TAG, "Create version=" + Util.getSelfVersionName(this) + "/" + Util.getSelfVersionCode(this)); mPrevHandler = Thread.getDefaultUncaughtExceptionHandler(); Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread thread, Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); if (mPrevHandler != null) mPrevHandler.uncaughtException(thread, ex); } }); //Initialize facebook sdk to track installs FacebookSdk.sdkInitialize(getApplicationContext()); AppEventsLogger.activateApp(this); }
@Override public void onCreate() { super.onCreate(); TwitterAuthConfig authConfig = new TwitterAuthConfig(Constants.TWITTER_KEY, Constants.TWITTER_SECRET); Fabric.with(this, new Twitter(authConfig)); FacebookSdk.sdkInitialize(getApplicationContext()); boolean isDebuggable = (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE)); if (isDebuggable) { Timber.plant(new Timber.DebugTree()); } mApplicationComponent = DaggerApplicationComponent.builder().applicationModule(new ApplicationModule(this)).build(); mApplicationComponent.inject(this); }
private void setupFacebookLogin() { //TODO: Check if facebook login is actvated in the server String appId = FacebookSdk.getApplicationId(); Timber.d("appId: " + appId); if (appId != null) { mCallbackManager = CallbackManager.Factory.create(); mFacebookButton.setReadPermissions(PERMISSIONS); mFacebookButton.registerCallback(mCallbackManager, mFacebookCallback); mAccessTokenTracker = new AccessTokenTracker() { @Override protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken currentAccessToken) { if (currentAccessToken != null) { mRxRocketMethods.loginWithFacebook(currentAccessToken.getToken(), currentAccessToken.getExpires().getTime() - new Date().getTime()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(mLoginSubscriber); } } }; } else { mFacebookButton.setVisibility(View.GONE); } }
@Override public void onCreate() { super.onCreate(); setupTimber(); // Note: Your consumer key and secret should be obfuscated in your source code before shipping. if (!TextUtils.isEmpty(BuildConfig.TWITTER_KEY)) { TwitterAuthConfig authConfig = new TwitterAuthConfig(BuildConfig.TWITTER_KEY, BuildConfig.TWITTER_SECRET); Fabric.with(this, new Twitter(authConfig), new Crashlytics()); } else { Fabric.with(this, new Crashlytics()); } FacebookSdk.sdkInitialize(getApplicationContext()); DBManager.getInstance().init(this); mAppComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build(); String url = BuildConfig.WS_PROTOCOL + "://" + BuildConfig.WS_HOST + BuildConfig.WS_PATH; mAppComponent.plus(new RocketModule(url)).inject(this); }
@Override public void onCreate() { super.onCreate(); mContext = getApplicationContext(); mAppHelper = new AppHelper(); FacebookSdk.sdkInitialize(getApplicationContext()); initScreenSize(); if (Config.IS_DEBUG_MODE) { mAppHelper.showKeyHash(); mAppHelper.showSHA1Key(); } CalligraphyConfig.initDefault(new CalligraphyConfig.Builder() // .setDefaultFontPath("fonts/Roboto-RobotoRegular.ttf") .setFontAttrId(R.attr.fontPath) .build()); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_initial); FacebookSdk.sdkInitialize(getApplicationContext()); if (new SessionManager(this).isLoggedIn()) { proceedToApp(); } FBLoginFragment login = (savedInstanceState == null) ? new FBLoginFragment() : (FBLoginFragment) getSupportFragmentManager().findFragmentById(R.id.container_initial); getSupportFragmentManager().beginTransaction().replace(R.id.container_initial, login).commit(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FacebookSdk.sdkInitialize(getActivity().getApplicationContext()); mCallbackManager = CallbackManager.Factory.create(); profileTracker = new ProfileTracker() { @Override protected void onCurrentProfileChanged(Profile oldProfile, Profile currentProfile) { final Profile profile = currentProfile; if (profile != null) { final Thread thread = new Thread() { public void run() { createUserFromFacebook(profile); openListsOverview(); } }; thread.start(); } } }; printKeyHash(getActivity()); }
public static void setupAppCallForErrorResult(AppCall appCall, FacebookException exception) { if (exception == null) { return; } Intent errorResultIntent = new Intent(); errorResultIntent.setClass(FacebookSdk.getApplicationContext(), FacebookActivity.class); errorResultIntent.setAction(FacebookActivity.PASS_THROUGH_CANCEL_ACTION); NativeProtocol.setupProtocolRequestIntent( errorResultIntent, appCall.getCallId().toString(), null, NativeProtocol.getLatestKnownVersion(), NativeProtocol.createBundleForException(exception)); appCall.setRequestIntent(errorResultIntent); }
private static TreeSet<Integer> getAllAvailableProtocolVersionsForAppInfo( NativeAppInfo appInfo) { TreeSet<Integer> allAvailableVersions = new TreeSet<>(); Context appContext = FacebookSdk.getApplicationContext(); ContentResolver contentResolver = appContext.getContentResolver(); String [] projection = new String[]{ PLATFORM_PROVIDER_VERSION_COLUMN }; Uri uri = buildPlatformProviderVersionURI(appInfo); Cursor c = null; try { c = contentResolver.query(uri, projection, null, null, null); if (c != null) { while (c.moveToNext()) { int version = c.getInt(c.getColumnIndex(PLATFORM_PROVIDER_VERSION_COLUMN)); allAvailableVersions.add(version); } } } finally { if (c != null) { c.close(); } } return allAvailableVersions; }