2012-02-21 2 views
3

페이스 북과의 전체 연결이 비트 맵 업로드를위한 앱을 작성 중입니다. 앱을 등록하거나 SDK 등을 다운로드하지 않고도 앱을 다운로드 할 수있는 방법이 있습니까?페이스 북없이 안드로이드에서 페이스 북으로 이미지 업로드 sdk

+0

당신은 아직 아무것도 시도 해 봤나 시도를? 아무 일 없니? – trgraglia

+0

지금까지 SDK를 사용해 보았지만 아무 것도 작동하지 않았습니다. –

답변

0

물론 페이스 북 앱이 이미 설치되어 있다고 가정하면 이미지로 ACTION_SEND 의도를 실행할 수 있습니다. 사용자는 그런 다음 페이스 북을 선택하고 그런 식으로 업로드합니다. 일종의 추한 이모 ... 왜 sdk 피할까요? 통합하기가 그리 어렵지 않고 앱에서해야 할 일을 생각할 때 훨씬 더 많은 유연성을 제공합니다.

0

'broody'가 말한 것처럼, 그것은 끈적 할 것입니다. 개인 앱입니까, 아니면 배포 용입니까?

당신이 SDK를 사용하기로 결정한 경우 등,이 게시물에 체크 아웃 : Android - Upload photo to Facebook with Facebook Android SDK

+0

전에이 게시물을 사용해 보았습니다. 다운로드 한 모든 것 등이 있지만 문제가있었습니다. Java는 특정 라이브러리 등을 인식하지 못하므로 매우 간단한 방법이 있기를 바란다. 그것. 희망적으로 배포 할 수 있습니다 :) –

+0

코드를 게시해야합니다 ... IT는 사람들이 무슨 일이 일어나고 있는지 알 수 있도록 도와줍니다. – trgraglia

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); 
    } 
}} 
관련 문제