我想在 DialogListener 中完成 Facebook 登录后开始一个新活动。登录成功 没有错误出现,但活动没有开始。如果您需要 logcat,我可以给您发电子邮件。以下是我的代码。
这是我的家庭活动
package com.example.faceb;
import com.facebook.android.AsyncFacebookRunner;
import com.facebook.android.Facebook;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class HomeActivity extends Activity implements OnClickListener{
private static final String TAG = "Facebook";
private Button mLogin, mLogout, mShare;
private Facebook facebook;
private AsyncFacebookRunner abRunner;
public boolean flag;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.activity_home);
facebook = new Facebook("479652662068145");
abRunner = new AsyncFacebookRunner(facebook);
mLogin= (Button) findViewById(R.id.Login);
mLogout= (Button) findViewById(R.id.Logout);
mLogin.setOnClickListener(this);
mLogout.setOnClickListener(this);
}
@Override
public void onClick(View v){
int id = v.getId();
switch(id){
case R.id.Login:
FacebookLoginDialog login = new FacebookLoginDialog(this);
facebook.authorize(this, login);
if (func()==true)
{
Intent i = new Intent(this, SearchActivity.class);
startActivity(i);
}
break;
case R.id.Logout:
FacebookLogoutRequest logout = new FacebookLogoutRequest(this);
abRunner.logout(this, logout);
Toast toast = Toast.makeText(this, "You Are Logged Out", Toast.LENGTH_SHORT);
toast.show();
break;
default:
break;
}
}
public static boolean func() {
return true;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_home, menu);
return true;
}
}
并按照我的 FacebookLoginDialog 类
public class FacebookLoginDialog implements DialogListener{
@Override
public void onComplete(Bundle values) {
HomeActivity.func();
}
@Override
public void onFacebookError(FacebookError e) {
// TODO Auto-generated method stub
}
@Override
public void onError(DialogError e) {
// TODO Auto-generated method stub
}
@Override
public void onCancel() {
// TODO Auto-generated method stub
}
}
此对话框从我的HomeActivity
. 请帮助我搜索了很多并尝试但无法解决此问题。