我正在寫一個應用程序,它的整個連接到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. 取消圖像上傳到Facebook從Facebook
- 2. 如何從Android上傳圖像到Facebook
- 3. 將圖像從as3上傳到instagram/facebook
- 4. 將圖像上傳到Facebook而不使用Facebook android-sdk
- 5. 用FBSDKShareButton將圖像上傳到Facebook
- 6. 將圖像上傳到Facebook Objective-C
- 7. Android:將圖像上傳到Facebook上的特定相冊
- 8. Facebook多個圖像上傳
- 9. 如何從Android設備的圖像上傳到Facebook服務器
- 10. 從Android到Facebook頁面的圖像
- 11. Android發佈圖像到Facebook
- 12. Facebook圖形API將本地圖像上傳到牆上(Objective-C)
- 13. 上傳圖片到FB從Android的:沒有錯誤,但沒有上傳至Facebook
- 14. 將圖像發佈到Facebook
- 15. Facebook Graph API圖片上傳圖像ID
- 16. Facebook圖表api上傳圖像withou sdk
- 17. 將圖像從電子郵件上傳到Facebook
- 18. 將facebook圖片上傳到圖像查看
- 19. 將圖片上傳到Facebook SDK Android
- 20. 從android SD卡上傳圖片到facebook
- 21. Android的facebook通知圖像
- 22. 分享圖像從Android應用程序到Facebook,與Facebook的SDK
- 23. 將圖片從統一上傳到Facebook
- 24. 在Facebook牆上的Android發佈圖像
- 25. 像Android的Facebook的圖像網格
- 26. 將圖像上傳到特定的Facebook專輯
- 27. 將圖像上傳到Facebook的按鈕點擊
- 28. 使用facebook API上傳圖像
- 29. 使用Facebook瀏覽器上傳圖像
- 30. Facebook的opengraph圖像標籤讀取,但沒有圖像出現
你嘗試過什麼了嗎?你有什麼工作嗎? – trgraglia 2012-02-21 22:56:31
到目前爲止我嘗試過使用sdk,沒有任何工作 – 2012-02-22 07:30:38