大佬教程收集整理的这篇文章主要介绍了android – 在设备/模拟器上安装Facebook应用程序时,发布到用户Facebook墙不能正常工作,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
public class AchievementActivity extends Activity implements DialogListener,OnClickListener{ private Facebook facebook; Button facebookPostButton; String defaultFacebookPost; @Override public void onCreate(Bundle savedInstanceStatE){ super.onCreate(savedInstanceStatE); requestWindowFeature(Window.FEATURE_CUSTOM_titlE); setContentView(R.layout.achievements); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_titlE,R.layout.custom_title_layout); View achievementDivider = (View)findViewById(R.id.achievementDivider); int[] colors = {0,0xff00ffff,0}; achievementDivider.setBACkgroundDrawable(new GradientDrawable(Orientation.RIGHT_LEFT,colors)); //get the title of the achievement from thE intent that started this activity from the activity StatisticsActivity String achievementtitleString = geTintent().getStringExtra("title"); String achievementTextToDisplay = getAchievementTextToDisplay(achievementtitleString); defaultFacebookPost = getDefaultPost(achievementtitleString); //ImageView achievementActivityAchievementBadgeImageView = (ImageView)findViewById(R.id.achievementActivityAchievementBadgeImageView); TextView achievementActivityBadgetitleTextView = (TextView)findViewById(R.id.achievementActivityBadgetitleTextView); achievementActivityBadgetitleTextView.setText(achievementtitleString); TextView achievementActivityAchievementText = (TextView)findViewById(R.id.achievementActivityAchievementText); achievementActivityAchievementText.setText(achievementTextToDisplay); facebookPostButton = (Button)findViewById(R.id.facebookPostButton); facebookPostButton.setOnClickListener(this); } @Override public void onComplete(Bundle values) { if (values.isEmpty()) { Toast.makeText(getApplicationContext(),"Empty",Toast.LENGTH_SHORT); return; } if (!values.containsKey("post_id")) { try { Bundle parameters = new Bundle(); parameters.putString("message",defaultFacebookPost);// the message to post to the wall facebook.dialog(AchievementActivity.this,"stream.publish",parameters,this);// "stream.publish" is an API call } catch (Exception E) { // TODO: handle exception System.out.println(e.getmessage()); } } try { facebook.logout(getApplicationContext()); } catch (MalformedURLException E) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException E) { // TODO Auto-generated catch block e.printStackTrace(); } } @Override public void onFacebookError(FacebookError error) { Toast.makeText(AchievementActivity.this,"onFacebookError",Toast.LENGTH_LONG); } @Override public void onError(DialogError E) { Toast.makeText(AchievementActivity.this,"onError",Toast.LENGTH_LONG); } @Override public void onCancel() { Toast.makeText(AchievementActivity.this,"onCancel",Toast.LENGTH_LONG); } @Override public void onClick(View v) { if (v == facebookPostButton) { facebook = new Facebook("my_facebook_api"); // replace APP_APi_iD with your own facebook.authorize(this,new String[] {"publish_stream","read_stream","offline_access"},this); } } private String getDefaultPost(String defaulttitleString) { //do some stuff here to get a String to post to wall return defaultPost; } private String getAchievementTextToDisplay(String achievementtitleString) { String achievementTextToDisplay = "DEFAULT"; //do some stuff here to get text to display in the activity //this has nothing to do with the facebook post... return achievementTextToDisplay; } }@H_944_5@Logcat告诉我这个: @H_944_5@
05-11 13:03:34.076: INFO/Activitymanager(98): StarTing activity: Intent { cmp=com.facebook.katana/.ProxyAuth (has extras) } 05-11 13:03:34.246: INFO/Activitymanager(98): Displayed activity com.facebook.katana/.ProxyAuth: 158 ms (@R_598_10586@l 158 ms) 05-11 13:03:35.166: DEBUG/dalvikvm(12390): GC_FOR_MALLOC freed 6729 objects / 418424 bytes in 44ms 05-11 13:03:35.166: DEBUG/webviewglue(12390): nativeDestroy view: 0x527e20 05-11 13:03:35.166: DEBUG/NativeCrypto(12390): Freeing OpenSSL session@H_944_5@编辑
以上是大佬教程为你收集整理的android – 在设备/模拟器上安装Facebook应用程序时,发布到用户Facebook墙不能正常工作全部内容,希望文章能够帮你解决android – 在设备/模拟器上安装Facebook应用程序时,发布到用户Facebook墙不能正常工作所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。