0
我使用此代碼允許用戶在應用程序打開時登錄到Facebook。一旦它在應用程序中的用戶進入主菜單。如何在用戶登錄Facebook時創建活動的對話框覆蓋?
public class facebook_social extends Activity implements LoginListener {
private FBLoginManager fbManager;
Intent intentResult;
Bitmap bmImg = null;
URL myFileUrl =null;
ImageView i;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
intentResult = new Intent(getApplicationContext(), MainMenu.class);
//If the sdk version is Honeycomb the take off strictMode to allow for network connection in main thread.
if(Build.VERSION.SDK_INT >= 11){
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
}
shareFacebook();
}
public void shareFacebook() {
String permissions[] = { "read_stream", "user_relationship_details",
"user_religion_politics", "user_work_history",
"user_relationships", "user_interests", "user_likes",
"user_location", "user_hometown", "user_education_history",
"user_activities","offline_access"};
fbManager = new FBLoginManager(this,R.layout.black,"173174566087561",permissions);
if (fbManager.existsSavedFacebook()) {
fbManager.loadFacebook();
} else {
fbManager.login();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
fbManager.loginSuccess(data);
}
public void loginFail() {
fbManager.displayToast("Login failed!");
}
public void logoutSuccess() {
fbManager.displayToast("Logout success!");
}
public void loginSuccess(Facebook facebook) {
GraphApi graphApi = new GraphApi(facebook);
User user = new User();
try {
user = graphApi.getMyAccountInfo();
} catch (EasyFacebookError e) {
e.toString();
}
String pkg = getPackageName();
intentResult.putExtra(pkg + ".myName", user.getName());
intentResult.putExtra(pkg + ".myId", user.getId());
startActivity(intentResult);
Intent i = new Intent();
i.putExtra("name", user.getName());
}
}
正如你在這裏看到的應用程序提供了一個黑色的研究背景,在這個畫面時允許用戶登錄。我想要做的是什麼,都在日誌中多名主力的頂部菜單。我將如何去做這件事?
將它集成到主菜單中的活動?
你能提供一個來自我的例子的編輯嗎? –
如果您查看LogInSuceess方法。當登錄成功時,我正在啓動主菜單。我不想要的是,當用戶在主菜單上按下後退按鈕時。它返回到登錄活動發生的黑色背景。我希望後退按鈕可以直接進入設備的主菜單或主屏幕。 –
啓動應用程序時,啓動主菜單並通過startActivityForResult啓動登錄活動。現在,當用戶按下後,您將收到主菜單活動的取消。如果是這樣,只需關閉將返回到主屏幕的應用程序。 –