def*_*ant -1 android facebook-android-sdk
我一直在寻找一种方法来做到这一点.但似乎没有什么对我有用.有人可以帮忙这样做吗?
这是我状态帖子的图片按钮:
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/hoributtons"
android:layout_alignTop="@+id/imageButton2"
android:background="#00000000"
android:contentDescription="@string/facebook"
android:onClick="shareOnFacebook"
android:src="@drawable/facebookbutton" />
Run Code Online (Sandbox Code Playgroud)
这是我的mainactivity.java文件的相应部分:
public class MainActivity extends FacebookActivity {
private static final String APP_ID = "xxxxxxxxxxxxx";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void shareOnFacebook(View v) {
//mfacebook = new Facebook("xxxxxxxxxxxxx");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
有人能指出正确的方向吗?:)
gsb*_*gsb 11
假设您想在自己的墙上张贴(因为问题不明确),这应该适合您.
public class MainActivity extends Activity {
private static final String APP_ID = "xxxxxxxxxxxxx";
private Facebook mFacebook;
private AsyncFacebookRunner mAsyncRunner;
private EditText yourEditText;
private String toShare;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mFacebook = new Facebook();
mAsyncRunner = new AsyncFacebookRunner(mFacebook);
SessionEvents.addAuthListener(new SampleAuthListener());
SessionEvents.addLogoutListener(new SampleLogoutListener());
yourEditText = (EditText) findViewById(R.id.<youreditTextId>);
toShare = yourEditText.getText().toString();
}
public void shareOnFacebook(View v) {
Bundle params = new Bundle();
params.putString("message", toShare);
mAsyncRunner.request("me/feed", params, "POST", new RequestListener() {
public void onMalformedURLException(MalformedURLException e) {}
public void onIOException(IOException e) {}
public void onFileNotFoundException(FileNotFoundException e) {}
public void onFacebookError(FacebookError e) {}
public void onComplete(String response) {
}
});
Toast.makeText(MainActivity.this, "Posting to your Wall", Toast.LENGTH_SHORT).show();
}
}
Run Code Online (Sandbox Code Playgroud)
有关将图片发布到墙上的详细信息,Facebook有一个很好的文档.
| 归档时间: |
|
| 查看次数: |
4800 次 |
| 最近记录: |