我正在写一个应用程序,它的整个连接到Facebook是用于上传位图。有没有办法不注册应用程序,下载SDK等?将图像从Android上传到Facebook没有Facebook的图像
3
A
回答
0
当然,假设用户已经安装了Facebook应用程序,您可以使用您的映像启动ACTION_SEND意图。用户然后选择Facebook并以这种方式上传。一种丑陋的imo ...为什么要避免sdk?当你想到应用中的其他功能时,整合并不难,并且给予你更多的灵活性。
0
就像'broody'说的那样,它会很俗气。这是个人应用还是分发?
如果你决定使用SDK等等,看看这个帖子:Android - Upload photo to Facebook with Facebook Android SDK
+0
我尝试过这篇文章之前,下载了所有东西等,但有一些问题。 Java不识别某些库等,所以我希望有一个非常简单的方法。它。这是希望分发:) – 2012-02-22 07:28:40
+0
你应该发布代码... IT可以帮助人们知道发生了什么,以便他们可以提供帮助。 – trgraglia 2012-02-22 07:44:19
0
花花公子试试这个
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.text.util.Linkify;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
public class UploadPhotoResultDialog extends Dialog {
private String response, photo_id;
private TextView mOutput, mUsefulTip;
private Button mViewPhotoButton, mTagPhotoButton;
private ImageView mUploadedPhoto;
private Activity activity;
private ProgressDialog dialog;
private boolean hidePhoto = false;
private Handler mHandler;
public UploadPhotoResultDialog(Activity activity, String title, String response) {
super(activity);
this.activity = activity;
this.response = response;
setTitle(title);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mHandler = new Handler();
setContentView(R.layout.upload_photo_response);
LayoutParams params = getWindow().getAttributes();
params.width = LayoutParams.FILL_PARENT;
params.height = LayoutParams.FILL_PARENT;
getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);
mOutput = (TextView) findViewById(R.id.apiOutput);
mUsefulTip = (TextView) findViewById(R.id.usefulTip);
mViewPhotoButton = (Button) findViewById(R.id.view_photo_button);
mTagPhotoButton = (Button) findViewById(R.id.tag_photo_button);
mUploadedPhoto = (ImageView) findViewById(R.id.uploadedPhoto);
JSONObject json;
try {
json = Util.parseJson(response);
final String photo_id = json.getString("id");
this.photo_id = photo_id;
mOutput.setText(json.toString(2));
mUsefulTip.setText(activity.getString(R.string.photo_tip));
Linkify.addLinks(mUsefulTip, Linkify.WEB_URLS);
mViewPhotoButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (hidePhoto) {
mViewPhotoButton.setText(R.string.view_photo);
hidePhoto = false;
mUploadedPhoto.setImageBitmap(null);
} else {
hidePhoto = true;
mViewPhotoButton.setText(R.string.hide_photo);
/*
* Source tag: view_photo_tag
*/
Bundle params = new Bundle();
params.putString("fields", "picture");
dialog = ProgressDialog.show(activity, "",
activity.getString(R.string.please_wait), true, true);
dialog.show();
Utility.mAsyncRunner.request(photo_id, params,
new ViewPhotoRequestListener());
}
}
});
mTagPhotoButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
/*
* Source tag: tag_photo_tag
*/
setTag();
}
});
} catch (JSONException e) {
setText(activity.getString(R.string.exception) + e.getMessage());
} catch (FacebookError e) {
setText(activity.getString(R.string.facebook_error) + e.getMessage());
}
}
public void setTag() {
String relativePath = photo_id + "/tags/" + Utility.userUID;
Bundle params = new Bundle();
params.putString("x", "5");
params.putString("y", "5");
Utility.mAsyncRunner.request(relativePath, params, "POST", new TagPhotoRequestListener(),
null);
}
public class ViewPhotoRequestListener extends BaseRequestListener {
@Override
public void onComplete(final String response, final Object state) {
try {
JSONObject json = Util.parseJson(response);
final String pictureURL = json.getString("picture");
if (TextUtils.isEmpty(pictureURL)) {
setText("Error getting \'picture\' field of the photo");
} else {
mHandler.post(new Runnable() {
@Override
public void run() {
new FetchImage().execute(pictureURL);
}
});
}
} catch (JSONException e) {
dialog.dismiss();
setText(activity.getString(R.string.exception) + e.getMessage());
} catch (FacebookError e) {
dialog.dismiss();
setText(activity.getString(R.string.facebook_error) + e.getMessage());
}
}
public void onFacebookError(FacebookError error) {
dialog.dismiss();
setText(activity.getString(R.string.facebook_error) + error.getMessage());
}
}
public class TagPhotoRequestListener extends BaseRequestListener {
@Override
public void onComplete(final String response, final Object state) {
if (response.equals("true")) {
String message = "User tagged in photo at (5, 5)" + "\n";
message += "Api Response: " + response;
setText(message);
} else {
setText("User could not be tagged.");
}
}
public void onFacebookError(FacebookError error) {
setText(activity.getString(R.string.facebook_error) + error.getMessage());
}
}
public void setText(final String txt) {
mHandler.post(new Runnable() {
@Override
public void run() {
mOutput.setText(txt);
}
});
}
private class FetchImage extends AsyncTask<String, Void, Bitmap> {
@Override
protected Bitmap doInBackground(String... urls) {
return Utility.getBitmap(urls[0]);
}
@Override
protected void onPostExecute(Bitmap result) {
dialog.dismiss();
mUploadedPhoto.setImageBitmap(result);
}
}}
相关问题
- 1. 将图像从as3上传到instagram/facebook
- 2. 将图像上传到Facebook而不使用Facebook android-sdk
- 3. 用FBSDKShareButton将图像上传到Facebook
- 4. 将图像上传到Facebook Objective-C
- 5. Android:将图像上传到Facebook上的特定相册
- 6. 如何从Android设备的图像上传到Facebook服务器
- 7. Android发布图像到Facebook
- 8. 将图像发布到Facebook
- 9. 将图像从电子邮件上传到Facebook
- 10. 将facebook图片上传到图像查看
- 11. 将图片上传到Facebook SDK Android
- 12. Android的facebook通知图像
- 13. 像Android的Facebook的图像网格
- 14. 将图像上传到Facebook的按钮点击
- 15. 将图像上传到特定的Facebook专辑
- 16. 使用facebook API上传图像
- 17. 如何使用Graph API将图像上传到Facebook
- 18. 使用Python API将图像上传到Facebook
- 19. 如何使用图API将信息发布到Facebook上,而没有图像?
- 20. 发布流显示没有图像 - Facebook
- 21. 分享图像没有在Facebook中
- 22. 在Facebook上发布图像
- 23. android facebook api发布到图像墙
- 24. 的Android上传图库图片至Facebook ------位图图像的内存不足
- 25. Facebook的PHP图像
- 26. 使用Android SDK将视频或图像上载到Facebook
- 27. 将图像发布到Facebook墙(存储图像的位置)
- 28. Php上传到Facebook没有Facebook登录
- 29. 错误:图像从sd卡上传到facebook中的相册android sdk
- 30. Facebook Graph post图像到页
你尝试过什么了吗?你有什么工作吗? – trgraglia 2012-02-21 22:56:31
到目前为止我尝试过使用sdk,没有任何工作 – 2012-02-22 07:30:38