Android在共享图像后关闭应用程序

Android在共享图像后关闭应用程序,android,android-intent,Android,Android Intent,我的应用程序共享一个图像,但同时用户共享的应用程序在后台关闭。日志为空,没有错误,没有警告。你能看到错误吗 试试看{ fout=新文件输出流(imageFile); 压缩(bitmap.CompressFormat.JPEG,90,fout); fout.flush(); fout.close(); }catch(filenotfounde异常){ e、 printStackTrace(); }捕获(IOE异常){ e、 printStackTrace(); } Uri=Uri.fromFile

我的应用程序共享一个图像,但同时用户共享的应用程序在后台关闭。日志为空,没有错误,没有警告。你能看到错误吗

试试看{
fout=新文件输出流(imageFile);
压缩(bitmap.CompressFormat.JPEG,90,fout);
fout.flush();
fout.close();
}catch(filenotfounde异常){
e、 printStackTrace();
}捕获(IOE异常){
e、 printStackTrace();
}
Uri=Uri.fromFile(新文件(mPath));
btn1.setVisibility(View.VISIBLE);
btn2.setVisibility(View.VISIBLE);
水印.设置可见性(视图.不可见);
意向共享意向=新意向(android.content.Intent.ACTION\u SEND);
setType(“图像/jpeg”);
putExtra(android.content.Intent.EXTRA_流,uri);
if(Build.VERSION.SDK\u INT>=Build.VERSION\u code.KITKAT){
startActivity(shareIntent);
}否则{
startActivity(Intent.createChooser(shareIntent,“Compartir Vía”));
}
编辑:

  • 当我再次打开它回到开始时,应用程序从未崩溃,几乎继续正常记录

尝试使用startActivityForResult@Chris不是批评,只是好奇:为什么
startActivityForResult()
会产生不同的效果?我不知道具体的区别是什么。然而,我发现这是不同的。例如,如果使用
startActivity
而不是
startActivityForResult
,则
Activity.getCallingActivity()
不起作用。这是一个简单的改变,值得一试。因为我不知道它是否能解决您的问题,所以我将其作为评论提交。