我有这个AsyncTask,我想要处理Bitmap,我想要做的是缓存图像并将位图发送到可以发布或保存到本地存储的活动,代码在一些android中工作版本,而不是在一些工作,请帮助。在此先感谢。
参见代码......
// Async task for onClick
class Forward extends AsyncTask<Object,Object,Object>
{
// Before forwarding
@ Override
protected void onPreExecute()
{
super.onPreExecute();
linlaHeaderProgress.setVisibility(View.VISIBLE);
linlaHeaderProgress.bringToFront();
photoEditorView.pause();
photoEditorView.invalidate();
}
// Forwarding
@ Override
protected String doInBackground(Object ... arg0)
{
Intent forward = new Intent(selfRef, SaveResultingPhotoActivity.class);
photoEditorView.buildDrawingCache(true);
photoEditorView.buildDrawingCache();
photoBitmap = Bitmap.createBitmap(photoEditorView.getDrawingCache());
saveImage();
forward.putExtra("com.vanniatech.mImageCache",
cacheImage_forPassing.getPath());
startActivity(forward);
photoEditorView.buildDrawingCache(false);
return "DONE";
}
// After forwarding
@ Override
protected void onPostExecute(Object result)
{
photoEditorView.buildDrawingCache(true);
photoEditorView.buildDrawingCache();
photoBitmap = Bitmap.createBitmap(photoEditorView.getDrawingCache());
saveImage();
linlaHeaderProgress.setVisibility(View.GONE);
super.onPostExecute(result);
}
}
答案 0 :(得分:1)
您正在创建和Intent并在doInBackground()方法中启动活动。这是一个不,因为从背景开始活动不是你想要的。应该在onPostExecute方法中启动活动。