Java 类com.facebook.FacebookSdk 实例源码
项目:kognitivo
文件:VideoUploader.java
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;
}
}
项目:kognitivo
文件:MessengerUtils.java
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);
}
}
项目:kognitivo
文件:MessengerUtils.java
/**
* 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();
}
}
项目:kognitivo
文件:AppLinkData.java
/**
* 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);
}
});
}
项目:kognitivo
文件:DialogPresenter.java
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);
}
项目:kognitivo
文件:DialogPresenter.java
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);
}
项目:kognitivo
文件:NativeAppCallAttachmentStore.java
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);
}
}
项目:kognitivo
文件:Utility.java
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();
}
}
}
项目:kognitivo
文件:NativeProtocol.java
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);
}
}
});
}
项目:kognitivo
文件:FacebookDialogBase.java
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);
}
}
}
项目:Stalker
文件:AuthenticateFragment.java
@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"));
}
项目:letv
文件:NativeProtocol.java
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();
}
}
}
项目:lecrec-android
文件:ActivityLaunchScreen.java
@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();
}
项目:CustomAndroidOneSheeld
文件:FacebookShield.java
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();
}
}
};
}
项目:AndelaTrackChallenge
文件:AndelaTrackChallenge.java
@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);
}
项目:BizareChat
文件:BizareChatApp.java
@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);
}
项目:Project-Chao
文件:Chao.java
@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);
}
项目:MovieManiac
文件:SupportDeveloperActivity.java
@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);
}
项目:uPods-android
文件:UpodsApplication.java
@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();
}
项目:sabbath-school-android
文件:SSLoginViewModel.java
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());
}
});
}
项目:PlatePicks-Android
文件:LoginFragment.java
@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();
}
项目:Stalker
文件:AuthenticateFragment.java
@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"));
}
项目:Saude-no-Mapa
文件:SaudeApp.java
@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()));
}
项目:FaceT
文件:MyApp.java
@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);
}
项目:apparel
文件:ApparelApplication.java
@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);
}
项目:EmbeddedSocial-Android-SDK
文件:EmbeddedSocial.java
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());
}
项目:android-protwall
文件:ApplicationEx.java
@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);
}
项目:FirebaseAuthExample
文件:FireAuthApplication.java
@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);
}
项目:Rocket.Chat-android
文件:LoginActivity.java
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);
}
}
项目:Rocket.Chat-android
文件:RocketApp.java
@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);
}
项目:android-fagyi
文件:App.java
@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());
}
项目:tidbit-android
文件:InitialActivity.java
@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();
}
项目:1Sheeld-Android-App
文件:FacebookShield.java
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();
}
}
};
}
项目:batatas-android
文件:MainFragment.java
@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());
}
项目:Move-Alarm_ORCA
文件:MessengerUtils.java
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);
}
}
项目:Move-Alarm_ORCA
文件:AppLinkData.java
/**
* 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);
}
});
}
项目:Move-Alarm_ORCA
文件:DialogPresenter.java
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);
}
项目:SocioBlood
文件:DialogPresenter.java
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);
}
项目:Move-Alarm_ORCA
文件:NativeAppCallAttachmentStore.java
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);
}
}
项目:Move-Alarm_ORCA
文件:NativeProtocol.java
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;
}