0

I have some log files in my application, and I want to make a zip file with this logs, and send it via Instabug, when I shake my phone and press on "Report a Bug" or "Send Feedback".

This is the code from my Application:

  Instabug.initialize(this)
            .setAnnotationActivityClass(InstabugAnnotationActivity.class)
            .setShowIntroDialog(true, PSTimelineActivity.class)
            .enableEmailField(true,false)
            .setEnableOverflowMenuItem(true)
            .setDebugEnabled(true)
            .setBugHeaderText("Error")
            .attachFileAtLocation(Environment.getExternalStorageDirectory() + "/Passenger/log.zip");

As you can see, I select the file that should be attached, but I also need to make that file from my log file, just after I shook the phone (so it will take the latest logs), and before pressing any of the 2 buttons to report. I have the archive function, I just don't know where I could put it so this would work. Any ideeas?

Mohammad AbuShady
  • 40,884
  • 11
  • 78
  • 89
rosu alin
  • 5,674
  • 11
  • 69
  • 150
  • 1
    Hi, this is Hassan from Instabug. I think you should take a look at [setPreSendingRunnable](https://instabug.com/public/android-api-reference/com/instabug/library/Instabug.html#setPreSendingRunnable-java.lang.Runnable-), it runs right before sending a report and you can do that pre-processing there. Let me know how it goes, we're also available at contactus@instabug.com – Hassan Ibraheem Apr 15 '15 at 13:38
  • @HassanIbraheem Thanks a lot!! It worked perfectly. Another thing, I noticed that if I shake to report a bug, and make a screenshot of an Activity that contains a dialog, or a google maps view. The dialogs will not appear in the screenshot, and the google maps view is grey. Is This from Instabug, or is it an issue on my side of the app? – rosu alin Apr 16 '15 at 10:58
  • That's great to hear. Regarding dialogs and Google Maps, unfortunately you'll have to add some calls to make them work, since they're rendered differently. For Google Maps, take a look at [addMapView](https://instabug.com/public/android-api-reference/com/instabug/library/Instabug.html#addMapView-android.view.View-com.google.android.gms.maps.GoogleMap-), and for dialogs: [setDialog](https://instabug.com/public/android-api-reference/com/instabug/library/Instabug.html#setDialog-android.app.Dialog-). – Hassan Ibraheem Apr 16 '15 at 11:21

1 Answers1

0

I initialised Instabug like this:

Instabug.initialize(this)
            .setAnnotationActivityClass(InstabugAnnotationActivity.class)
            .setShowIntroDialog(true, PSTimelineActivity.class)
            .enableEmailField(true,false)
            .setEnableOverflowMenuItem(true)
            .setDebugEnabled(true)
            .setBugHeaderText("Error")
            .setPreSendingRunnable(new Runnable() {
                @Override
                public void run() {
                    String[] files = new String[2];
                    files[0] = Environment.getExternalStorageDirectory() + "/Passenger/passenger_log.txt";
                    files[1] = Environment.getExternalStorageDirectory() + "/Passenger/passenger_log2.txt";
                    Compress compress = new Compress(files, Environment.getExternalStorageDirectory() + "/Passenger/log.zip");
                    compress.zip(new CrudStateCallback() {
                        @Override
                        public void onResponse(String string) {
                            Log.i("", "ended making the archive");
                        }
                    });
                }
            })
            .attachFileAtLocation(Environment.getExternalStorageDirectory() + "/Passenger/log.zip");

Following Hassan Ibraheem's advice, and now I create the .zip in the preSendingRunnable.

rosu alin
  • 5,674
  • 11
  • 69
  • 150