我已将Facebook集成到我的应用中.但是,它不会在对话框中显示,而是打开全屏.我想知道是否有人知道如何将此更改为对话框.
FaceBook处理程序类:
@OverrIDepublic voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.main); /* * Get existing access_token if any */ mPrefs = getPreferences(MODE_PRIVATE); String access_token = mPrefs.getString("access_token", null); long expires = mPrefs.getLong("access_expires", 0); if(access_token != null) facebook.setAccesstoken(access_token); if(expires != 0) facebook.setAccessExpires(expires); if (facebook.isSessionValID()) postFacebookMessage(); else { facebook.authorize(this, new String[] {"publish_stream"}, new Facebook.DialogListener() { @OverrIDe public voID onFacebookError(FacebookError e) { Toast.makeText(FacebookConnector.this, "Facebook error: " + e.getLocalizedMessage(), Toast.LENGTH_LONG).show(); } @OverrIDe public voID one rror(DialogError e) { Toast.makeText(FacebookConnector.this, "Facebook dialog error: " + e.getLocalizedMessage(), Toast.LENGTH_LONG).show(); } @OverrIDe public voID onComplete(Bundle values) { postFacebookMessage(); Toast.makeText(FacebookConnector.this, "Thank You For Sharing!", Toast.LENGTH_SHORT).show(); } @OverrIDe public voID onCancel() {Toast.makeText(FacebookConnector.this, "Facebook authorization cancelled.", Toast.LENGTH_LONG).show(); } }); }} private voID postFacebookMessage() { AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook); Bundle params = new Bundle(); params.putString("message", MSG); params.putString("picture", "http://meanwhileinwv.com/meanwhile.png"); mAsyncRunner.request("me/Feed", params, "POST", new FacebookPostListener(), null); } @OverrIDepublic voID onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); facebook.authorizeCallback(requestCode, resultCode, data);}}
上面的代码产生以下结果:
我希望它是facebook窗口打开的对话框.我用我的Twitter代码实现了这个目标:
解决方法:
使用附加参数Facebook.FORCE_DIALOG_AUTH调用授权,如下所示:
facebook.authorize(this, new String[] {"publish_stream"}, Facebook.FORCE_DIALOG_AUTH, new Facebook.DialogListener() { ... });
总结 以上是内存溢出为你收集整理的java – Android Facebook对话全部内容,希望文章能够帮你解决java – Android Facebook对话所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)