当我在android上打开另一个应用程序时,我收到致命信号6(SIGABRT)
我的应用打开一个png图像。当我发送到打印时,我的应用程序停止,我的控制台(logcat)只显示以下消息:当我在android上打开另一个应用程序时,我收到致命信号6(SIGABRT),android,sigabrt,android-anr-dialog,Android,Sigabrt,Android Anr Dialog,我的应用打开一个png图像。当我发送到打印时,我的应用程序停止,我的控制台(logcat)只显示以下消息: Fatal signal 6 (SIGABRT), code -6 in tid 13555 (RenderThread) 在平板电脑屏幕中显示:应用程序无响应(ANR) 我可以打印图像,但我的应用程序停止,我需要重新启动会话 我在寻找解决办法 一些代码: public boolean onOptionsItemSelected(MenuItem item) { int
Fatal signal 6 (SIGABRT), code -6 in tid 13555 (RenderThread)
在平板电脑屏幕中显示:应用程序无响应(ANR)
我可以打印图像,但我的应用程序停止,我需要重新启动会话
我在寻找解决办法
一些代码:
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.imprimir) {
Bitmap bitmap = Util.screenShot(mWebView);
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 40, bytes);
File file = new File(Environment.getExternalStorageDirectory() + File.separator + "screenshot.png");
try {
file.createNewFile();
FileOutputStream fo = new FileOutputStream(file);
fo.write(bytes.toByteArray());
fo.close();
} catch (IOException e) {
e.printStackTrace();
}
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("image/png");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
startActivity(intent);
}
return super.onOptionsItemSelected(item);
}
如果看到一些代码尝试在后台线程而不是UI线程上完成所有这些工作,那么您就不会得到ANR,这真的没有什么坏处