在我的应用程序中,我正在捕获图像并在第二个活动中进行设置,然后在执行某些操作后将其上传到服务器。如果图像存在特定ID,则在第一个图像视图中显示该图像其他活动显示一些默认图像。当我尝试通过捕获图像上传图像时,如果服务器中已存在该ID的图像,则捕获的图像在第一个活动的图像视图中更新。如果该ID没有图像,并且我设置时捕获的图像没有显示。如果我登录相同的ID,它第二次显示。如何从第二个活动返回后刷新第一个活动。这是我的代码:
self.crawler.engine.slot.scheduler.df.fingerprints = set()
@覆盖 protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); 的setContentView(R.layout.activity_image);
def reset_filter(self, spider):
self.crawler.engine.slot.scheduler.df.fingerprints = set()
#overriding the default from_crawler class method to access scrapy core components
@classmethod
def from_crawler(cls, crawler, *args, **kwargs):
spider = super(MySpider, cls).from_crawler(crawler, *args, **kwargs)
#initiate an event signal when spider is idle
crawler.signals.connect(spider.reset_filter, signals.spider_idle)
return spider
}
答案 0 :(得分:0)
在onActivityResult()
中设置图片不要再次调用onResume。
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {
Bitmap imageData = null;
if (resultCode == RESULT_OK) {
imageData = (Bitmap) data.getExtras().get("data");
// set image here
bmImage.setImageBitmap(imageData);
//Intent i = new Intent(this, Image.class);
//i.putExtra("name", imageData);
//startActivityForResult(i,3);
} else if (resultCode == RESULT_CANCELED) {
// User cancelled the image capture
} else {
// Image capture failed, advise user
}
}
else if (requestCode == 3) {
onResume();
}
}
答案 1 :(得分:0)
我们在项目中完成了相同的场景,我们使用第三方库来裁剪图像。裁剪图像后,我们将意图传递给上一个活动来处理裁剪。这是代码,
if (resultCode == Activity.RESULT_OK) {
Uri croppedUri = Crop.getOutput(result);
File outPutFile = new File(croppedUri.getPath());
mImagePath = outPutFile.getAbsolutePath();
mCurrentPhotoPath = mImagePath;
Point size = Utility.getDisplayPoint(mActivity);
int width = size.x;
int height = (width * 9) / 16;
Logger.i("height", height + "");
Logger.i("cropped path", outPutFile.getAbsolutePath() + "");
changeBeamPosterDimension(height, width);
setPic(mImagePath);
}