0
누군가 나를 도와 줄 수 있습니까? 스크린 샷을 찍어 페이 스북 벽에 게시하고 싶습니다 (메시지와 함께)! 몇 가지 주제와 포럼을 읽었지만 나에게 도움이되는 것을 찾지 못했습니다! 이미 Facebook SDK가 있습니다!Android : 스크린 샷을 찍어 페이스 북 벽에 게시
고맙습니다.
누군가 나를 도와 줄 수 있습니까? 스크린 샷을 찍어 페이 스북 벽에 게시하고 싶습니다 (메시지와 함께)! 몇 가지 주제와 포럼을 읽었지만 나에게 도움이되는 것을 찾지 못했습니다! 이미 Facebook SDK가 있습니다!Android : 스크린 샷을 찍어 페이스 북 벽에 게시
고맙습니다.
이 방법을 사용하여보기 이미지를 캡처하십시오.
View v = view.getRootView();
v.setDrawingCacheEnabled(true);
Bitmap b = v.getDrawingCache();
String extr = Environment.getExternalStorageDirectory().toString();
File myPath = new File(extr, "yourImageName.jpg");
FileOutputStream fos = null;
try {
fos = new FileOutputStream(myPath);
b.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.flush();
fos.close();
MediaStore.Images.Media.insertImage(getContentResolver(), b, "Screen", "screen");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
여기서 v는 루트 레이아웃이며 SDK 3.5를 사용하여 Facebook에 게시 사진보다 많습니다. 이 방법
private SimpleFacebook mSimpleFacebook;
mSimpleFacebook = SimpleFacebook.getInstance(this);
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap bitmap = BitmapFactory.decodeFile(photoPath, options);
// create Photo instace and add some properties
Photo photo = new Photo(bitmap);
photo.addDescription("Screenshot from sample application");
photo.addPlace("110619208966868");
// publish
mSimpleFacebook.publish(photo, new OnPublishListener()
{
@Override
public void onFail(String reason)
{
mProgress.hide();
// insure that you are logged in before publishing
Log.w(TAG, "Failed to publish");
}
@Override
public void onException(Throwable throwable)
{
mProgress.hide();
Log.e(TAG, "Bad thing happened", throwable);
}
@Override
public void onThinking()
{
// show progress bar or something to the user while publishing
mProgress = ProgressDialog.show(this, "Thinking",
"Waiting for Facebook", true);
}
@Override
public void onComplete(String id)
{
mProgress.hide();
toast("Published successfully. The new image id = " + id);
}
});
감사와 같은
. free_ticket 문자열이란 무엇입니까? 어떤 경로가 가장 좋은가? 그리고 getContentResolver는 무엇인가? 그것은 내 Fragment 클래스에서 메서드를 찾지 못했습니다! – user3143691
내 편집 된 답변보기 –
고마워요! 스크린 샷이 정상적으로 작동합니다! 그러나 업로드는 작동하지 않습니다! simpleFacebook 클래스 란 무엇입니까? 그리고 OnPublishListener? 그리고 사진 사진 = 새로운 사진 (비트 맵) doesnt 일 ->이 오류가오고 : ContactsContract.CommonDataKinds.Photo (비트 맵) 정의되지 않았습니다! 미안 해요, 초보자입니다. ( – user3143691