Fatal signal 6 (SIGABRT) when switching applications

Context:
- My application uses webview to display a report with some data.
- This webview has a toolbar on top with a print button.
- When you press the print button opens a menu that allows the user to choose from a list of applications that can print the report.
- Printing process: take a screenshot of the report, compress it to reduce its size, send the png to the printer application.

Problem:
- When the printer app opens with a printable image, I get an ANR saying my background app has stopped working.
- If I press the back button on android the app is still alive and I can navigate without any error, which is strange, I just got a warning that it stops working.

Some code for enlightenment:

Code that takes a screenshot and sends to the print application

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.print) {
        Bitmap bitmap = Util.screenShot(mWebView);
        ByteArrayOutputStream bytes = new ByteArrayOutputStream();
        bitmap.compress(Bitmap.CompressFormat.JPEG, 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 true;
    }
    return super.onOptionsItemSelected(item);
}

      

Magazine:

03-23 14:32:54.726 11347-11388/br.gov.go.agrodefesa.tabletagrodefesa E/IMGSRV: kickresource.c:1130: Debug assertion failed!
03-23 14:32:54.836 9039-9039/? A/google-breakpad: M B0DE6000 00018000 00015000 000000000000000000000000000000000 data@app@br.gov.go.agrodefesa.tabletagrodefesa-1@base.apk@classes.dex
03-23 14:32:54.876 11347-11388/br.gov.go.agrodefesa.tabletagrodefesa W/google-breakpad: ### ### ### ### ### ### ### ### ### ### ### ### ###
03-23 14:32:54.876 11347-11388/br.gov.go.agrodefesa.tabletagrodefesa W/google-breakpad: Chrome build fingerprint:
03-23 14:32:54.876 11347-11388/br.gov.go.agrodefesa.tabletagrodefesa W/google-breakpad: 1.27
03-23 14:32:54.876 11347-11388/br.gov.go.agrodefesa.tabletagrodefesa W/google-breakpad: 1
03-23 14:32:54.876 11347-11388/br.gov.go.agrodefesa.tabletagrodefesa W/google-breakpad: ### ### ### ### ### ### ### ### ### ### ### ### ###
03-23 14:32:54.876 11347-11388/br.gov.go.agrodefesa.tabletagrodefesa A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 11388 (RenderThread)
03-23 14:32:54.976 9769-9769/? I/DEBUG: pid: 11347, tid: 11388, name: RenderThread  >>> br.gov.go.agrodefesa.tabletagrodefesa <<<
03-23 14:32:55.056 1710-1777/? D/UsageStatistics: Pkg: br.gov.go.agrodefesa.tabletagrodefesa    ForegroundTime: 2701177 FirstTime: 3-22-2017 21:00:00:000 LastTime: 3-23-2017 14:32:54:057 LastTimeUsed: 3-23-2017 14:32:54:057
03-23 14:32:55.466 524-1117/? I/WindowState: WIN DEATH: Window{2ba92055 u0 br.gov.go.agrodefesa.tabletagrodefesa/br.gov.go.agrodefesa.tabletagrodefesa.activities.TermoFiscalizacaoListActivity}
03-23 14:32:55.476 524-980/? I/WindowState: WIN DEATH: Window{1892d68d u0 br.gov.go.agrodefesa.tabletagrodefesa/br.gov.go.agrodefesa.tabletagrodefesa.activities.ImpressaoActivity}
03-23 14:32:55.496 524-654/? I/ActivityManager: Process br.gov.go.agrodefesa.tabletagrodefesa (pid 11347) has died

      

+3


source to share


1 answer


Oh, I see your mistake. You are using this:

bitmap.compress(Bitmap.CompressFormat.JPEG, 40, bytes);

which creates a JPEG image in CompressFormat and in the intent you are sending the PNG image



intent.setAction(Intent.ACTION_SEND);
intent.setType("image/png");

      

what is causing the error. To resolve this, use PNG instead of JPEG.

0


source







All Articles