非常感谢!
答案 0 :(得分:0)
使用这种方式捕获视图图像。
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是root布局,而不是使用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);
}
});