-2
나는 안드로이드와 페이스 북 SDK를 사용하여 페이스 북에 이미지 + 텍스트를 게시하는 올바른 방법을 찾기 위해 도처를 찾고 있습니다. 나는 단지이 메시지를 게시하도록이 코드를 얻을 수 있지만 내가 스크린 샷을 게시하려고 할 때 null 포인터 예외로 끝납니다. 나는 다른 스레드에서 많은 다른 코드 스 니펫을 시도했지만 아무 것도 나를 위해 작동하는 것. 내가 할 수있는 최선의 방법은 내 벽에 메시지를 게시하지만 사진은 게시하지 않는 코드입니다. 여기에서 잘못하고있는 것이 무엇인지 말해주세요. 매우 감사.안드로이드 개발 : 페이스 북 벽면에 스크린 캡슐 이미지 게시
View content = findViewById(R.id.row1);
Log.d("captureScreen", content.getId()+"");
byte[] byteArray=null;
Bitmap screenshot=null;
try {
if (content != null) {
int width = content.getWidth();
int height = content.getHeight();
screenshot = Bitmap.createBitmap(width, height,
Bitmap.Config.RGB_565);
content.draw(new Canvas(screenshot));
Log.d("captureScreen", "success");
}
} catch (Exception e) {
Log.d("captureScreen", "Failed");
}
try{
ByteArrayOutputStream stream = new ByteArrayOutputStream();
screenshot.compress(Bitmap.CompressFormat.PNG, 100, stream);
byteArray = stream.toByteArray();
Log.d("byte array", "sucesss");
} catch(Exception e){
Log.d("byte array", "failed");
}
Request.Callback callback = new Request.Callback() {
public void onCompleted(Response response) {
JSONObject graphResponse = response.getGraphObject()
.getInnerJSONObject();
Log.d("onCompleted", "2 sucess");
String postId = null;
try {
postId = graphResponse.getString("id");
Log.d("onCompleted", "3 sucess");
} catch (JSONException e) {
Log.d("json failed", "failed");
Log.i(TAG, "JSON error " + e.getMessage());
}
FacebookRequestError error = response.getError();
if (error != null) {
} else {
CreateDialog("your post was a sucess", "posted");
}
}
};
Bundle params = new Bundle();
params.putString("message","tester");
//params.putString("method", "photos.upload");
//params.putByteArray("source", byteArray);
// params.putString("caption", "test Caption");
Request request = new Request(session, "me/photos", params,
HttpMethod.POST, callback);
RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();
안녕 덕분에 많이 답장을 보내라고 SampleUploadListener 내가 어딘가에 내 페이스 북의 클래스를이 평균 엉망 않는 형태로 해결 될 수없는 이유는 무엇입니까? 다시 한 번 고마워요 – itburnz
@itburnz, FB API를 사용하고 있습니까? SampleUploadListener는 아무것도 구현하지 못하고 있습니다. "public class SampleUploadListener extends BaseKeyListener는 RequestListener를 구현합니다. –
안녕하세요, 여기에 다운로드 링크에서 sdk가 있습니다. http://developers.facebook.com/docs/getting-started/facebook-sdk-for- android/3.0/ – itburnz