当前位置: 首页>>代码示例>>Java>>正文


Java Facebook类代码示例

本文整理汇总了Java中com.facebook.android.Facebook的典型用法代码示例。如果您正苦于以下问题:Java Facebook类的具体用法?Java Facebook怎么用?Java Facebook使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Facebook类属于com.facebook.android包,在下文中一共展示了Facebook类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import com.facebook.android.Facebook; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
	//ALog.m();
	
	super.onCreate(savedInstanceState);

	mFacebook = new Facebook();
       
       if ( mFacebook.isSessionValid() ) {
   		//ALog.i("Already have a saved Facebook session, skipping authorization.");
   		
       	setResult(RESULT_OK);
       	finish();
       	return;
       }        
       
       mFacebook.authorize(this, FacebookConfig.getAppId(), PERMISSIONS, new LoginDialogListener());
	//setContentView(R.layout.facebook);
   }
 
开发者ID:skylight1,项目名称:SevenWonders,代码行数:20,代码来源:LoginAndGetPermissions.java

示例2: startFacebookWebViewActivity

import com.facebook.android.Facebook; //导入依赖的package包/类
private void startFacebookWebViewActivity() {
    Intent intent = new Intent(this, FacebookWebViewActivity.class);
    intent.putExtra(FacebookWebViewActivity.INTENT_EXTRA_ACTION, Facebook.LOGIN);
    intent.putExtra(FacebookWebViewActivity.INTENT_EXTRA_KEY_APP_ID, 
            getResources().getString(R.string.facebook_api_key));
    intent.putExtra(FacebookWebViewActivity.INTENT_EXTRA_KEY_PERMISSIONS, 
            new String[] {}); //{"publish_stream", "read_stream", "offline_access"});
    intent.putExtra(FacebookWebViewActivity.INTENT_EXTRA_KEY_DEBUG, false);
    intent.putExtra(FacebookWebViewActivity.INTENT_EXTRA_KEY_CLEAR_COOKIES, true);
    startActivityForResult(intent, ACTIVITY_RESULT_FACEBOOK_WEBVIEW_ACTIVITY);
}
 
开发者ID:Kamshak,项目名称:foursquared,代码行数:12,代码来源:AddFriendsByUserInputActivity.java

示例3: onActivityResult

import com.facebook.android.Facebook; //导入依赖的package包/类
/**
 * Listen for FacebookWebViewActivity finishing, inspect success/failure and returned
 * request parameters.
 */
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == ACTIVITY_RESULT_FACEBOOK_WEBVIEW_ACTIVITY) {
        // If RESULT_OK, means the request was attempted, but we still have to check the return status.
        if (resultCode == RESULT_OK) {
            // Check return status.
            if (data.getBooleanExtra(FacebookWebViewActivity.INTENT_RESULT_KEY_RESULT_STATUS, false)) {
                    
                // If ok, the result bundle will contain all data from the webview.
                Bundle bundle = data.getBundleExtra(FacebookWebViewActivity.INTENT_RESULT_KEY_RESULT_BUNDLE);
                    
                // We can switch on the action here, the activity echoes it back to us for convenience.
                String suppliedAction = data.getStringExtra(FacebookWebViewActivity.INTENT_RESULT_KEY_SUPPLIED_ACTION);
                if (suppliedAction.equals(Facebook.LOGIN)) {
                    // We can now start a task to fetch foursquare friends using their facebook id.
                    mStateHolder.startTaskFindFriends(
                            AddFriendsByUserInputActivity.this, bundle.getString(Facebook.TOKEN));
                }
            } else {
                // Error running the operation, report to user perhaps.
                String error = data.getStringExtra(FacebookWebViewActivity.INTENT_RESULT_KEY_ERROR);
                Log.e(TAG, error);
                Toast.makeText(this, error, Toast.LENGTH_LONG).show();
                finish();
            }
        } else {
            // If the user cancelled enterting their facebook credentials, exit here too.
            finish();
        }
    }
}
 
开发者ID:Kamshak,项目名称:foursquared,代码行数:36,代码来源:AddFriendsByUserInputActivity.java

示例4: clearFacebookCredentials

import com.facebook.android.Facebook; //导入依赖的package包/类
public static void clearFacebookCredentials(Facebook facebook, Context context) {	
	if(facebook.isSessionValid())
		facebook.getSession().close();
	Editor editor = context.getSharedPreferences(FACEBOOK_KEY, Context.MODE_PRIVATE).edit();
	editor.remove(FACEBOOK_TOKEN);
	editor.commit();
}
 
开发者ID:Nikhil-Nandagopal,项目名称:Socialite,代码行数:8,代码来源:SharedPreferencesCredentialStore.java

示例5: FacebookConnector

import com.facebook.android.Facebook; //导入依赖的package包/类
public FacebookConnector(String appId, String[] permissions, SocialActivity socialActivity) {

		this.facebook = new Facebook(appId);
		SharedPreferencesCredentialStore.restoreFacebookSession(facebook, socialActivity.getApplicationContext());
		this.permissions=permissions;
		this.mHandler = new Handler();
		this.activity = socialActivity;
		socialActivity.registerSocialConnector(this);

	}
 
开发者ID:Nikhil-Nandagopal,项目名称:Socialite,代码行数:11,代码来源:FacebookConnector.java

示例6: shareFacebook

import com.facebook.android.Facebook; //导入依赖的package包/类
public void shareFacebook(){
	facebook = new Facebook("1418005058449444");
	restoreCredentials(facebook);
	messageToPost = "Hello Everyone.";
	if (!facebook.isSessionValid()) {
		loginAndPostToWall();
	} else {
		postToWall(messageToPost);
	}
}
 
开发者ID:thoinv,项目名称:kaorisan,代码行数:11,代码来源:ShareFacebookActivity.java

示例7: save

import com.facebook.android.Facebook; //导入依赖的package包/类
public static boolean save(Facebook session, Context context) {
    Editor editor =
        context.getSharedPreferences(KEY, Context.MODE_PRIVATE).edit();
    editor.putString(TOKEN, session.getAccessToken());
    editor.putLong(EXPIRES, session.getAccessExpires());
    return editor.commit();
}
 
开发者ID:skylight1,项目名称:SevenWonders,代码行数:8,代码来源:SessionStore.java

示例8: restore

import com.facebook.android.Facebook; //导入依赖的package包/类
public static boolean restore(Facebook session, Context context) {
    SharedPreferences savedSession =
        context.getSharedPreferences(KEY, Context.MODE_PRIVATE);
    session.setAccessToken(savedSession.getString(TOKEN, null));
    session.setAccessExpires(savedSession.getLong(EXPIRES, 0));
    return session.isSessionValid();
}
 
开发者ID:skylight1,项目名称:SevenWonders,代码行数:8,代码来源:SessionStore.java

示例9: makeWallPost

import com.facebook.android.Facebook; //导入依赖的package包/类
private void makeWallPost() {
	//ALog.m();
	
	Facebook facebook = new Facebook();		 
	SessionStore.restore(facebook, this);

	//ALog.i("stream.publish parameters: ", mParams);
	facebook.dialog(FacebookApplicationPost.this, "stream.publish", mParams, 
		new WallPostDialogListener());	
}
 
开发者ID:skylight1,项目名称:SevenWonders,代码行数:11,代码来源:FacebookApplicationPost.java

示例10: onComplete

import com.facebook.android.Facebook; //导入依赖的package包/类
@Override
public void onComplete(Bundle values) {
	//Log.i("got values", values.toString());
	accessToken = values.getString(Facebook.TOKEN);
	// TODO Auto-generated method stub

}
 
开发者ID:mots,项目名称:haxsync,代码行数:8,代码来源:FacebookUtil.java

示例11: testPublicApi

import com.facebook.android.Facebook; //导入依赖的package包/类
public boolean testPublicApi() {
    Facebook fb = new Facebook(APP_ID);
    try {
        Log.d("Tests", "Testing standard API call");
        JSONObject response = Util.parseJson(fb.request("4"));
        if (!response.getString("name").equals("Mark Zuckerberg")) {
            return false;
        }
        
        Log.d("Tests", "Testing an API call with a specific method");
        response = Util.parseJson(
                fb.request("soneff", new Bundle(), "GET"));
        if (!response.getString("name").equals("Steven Soneff")) {
            return false;
        }
        
        Log.d("Tests", "Testing a public search query");
        Bundle params = new Bundle();
        params.putString("q", "facebook");
        response = Util.parseJson(fb.request("search", params));
        if (response.getJSONArray("data").length() == 0) return false;
        
        Log.d("Tests", "Public API Tests passed"); 
        return true;
    } catch (Throwable e) {
        e.printStackTrace();
        return false;
    }
}
 
开发者ID:GrioSF,项目名称:facebook-android-sdk,代码行数:30,代码来源:Tests.java

示例12: restoreFacebookSession

import com.facebook.android.Facebook; //导入依赖的package包/类
public static boolean restoreFacebookSession(Facebook facebook, Context context) {	
	SharedPreferences savedSession = context.getSharedPreferences(FACEBOOK_KEY, Context.MODE_PRIVATE);
	facebook.setAccessToken(savedSession.getString(FACEBOOK_TOKEN, null));
	facebook.setAccessExpires(savedSession.getLong(EXPIRES, 0));
	return facebook.isSessionValid();
}
 
开发者ID:Nikhil-Nandagopal,项目名称:Socialite,代码行数:7,代码来源:SharedPreferencesCredentialStore.java

示例13: saveFacebookToken

import com.facebook.android.Facebook; //导入依赖的package包/类
public static boolean saveFacebookToken(Facebook session, Context context) {
	Editor editor =	context.getSharedPreferences(FACEBOOK_KEY, Context.MODE_PRIVATE).edit();
	editor.putString(FACEBOOK_TOKEN, session.getAccessToken());
	editor.putLong(EXPIRES, session.getAccessExpires());
	return editor.commit();
}
 
开发者ID:Nikhil-Nandagopal,项目名称:Socialite,代码行数:7,代码来源:SharedPreferencesCredentialStore.java

示例14: forceAuthenticate

import com.facebook.android.Facebook; //导入依赖的package包/类
public void forceAuthenticate() {
	facebook.authorize(this.activity, this.permissions, Facebook.FORCE_DIALOG_AUTH,new LoginDialogListener());
}
 
开发者ID:Nikhil-Nandagopal,项目名称:Socialite,代码行数:4,代码来源:FacebookConnector.java

示例15: getFacebook

import com.facebook.android.Facebook; //导入依赖的package包/类
public Facebook getFacebook() {
	return this.facebook;
}
 
开发者ID:Nikhil-Nandagopal,项目名称:Socialite,代码行数:4,代码来源:FacebookConnector.java


注:本文中的com.facebook.android.Facebook类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。