Tuesday, April 12, 2011

Help Me 2 Help You !

After publishing my first app on the Android market I started getting emails from users that were having difficulties with some functionalities of my application or even some suspected bugs (No way ! My applications don't have bugs ! believe me !).

I then found myself trying to debug some weird behaviors only happening on some unknown device with no actual knowledge on what's going on this device... Kinda feels like looking for a needle in a haystack... in the dark... with one hand tied behind your back... and someone keeps hitting you on the head...

The next step any developer would take was requesting the user to download one of the logcat applications available out there, create a log file, send the log to the developer and hopefully attach some information on the device (Which device ? Which Android version ? Any custom ROM ? etc).

Obviously this is not something that most users are used to and it could be very frustrating both for the user (assuming he hasn't already uninstalled your app) and for the developer.

One of the recent changes I implemented for AutomateIt was adding a "Help !" button on the About screen. What this button does is packing all the files that could help me reproduce the problem reported by the user and gives me some insight on the user's device.

I found out that once you give the user a tool that by "a press of a button" gives you all the information you need as a developer, more users are responding and you can resolve more issues pretty easily.

This got me to building "Help Me 2 Help You" which can be used to send some detailed reports from users who report an error or a weird behavior with your application simply by pressing the "Help !" button on the application main screen.

The report created is an email that includes some information on the user's device, a logcat file and (optionally) a description of the problem by the user.
All that's left for the user to do is write the developer's email in the "To" field and send the report.

Developers: In order to get the most out of this application, use detailed logging so that the Logcat.txt attached will include all the data you might need.

[Added feature in v1.1 - Support activation from other applications using broadcast intent]
Version 1.1 includes a new feature that allows developers to launch the "Help !" screen from their applications using a broadcast intent as can be seen in the sample below:
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends Activity implements OnClickListener {
  // Action Name
  private static final String 

   HELP_REQUEST_BROADCAST_ACTION = "Muzikant.HelpMe2HelpYou.HelpRequest";

  // Action Extras
  private static final String

    EXTRA_DEVELOPER_EMAIL = "developer_email";

  private static final String
    EXTRA_EMAIL_SUBJECT = "email_subject";

  private static final String
    EXTRA_PROBLEM_DESCRIPTION = "problem_description";

  private static final String
    EXTRA_ADDITIONAL_INFO = "additional_info";

  private Button btnSendHelpRequest = null;

  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);


    btnSendHelpRequest = (ButtonfindViewById(R.id.btnSendHelpRequest);
    btnSendHelpRequest.setOnClickListener(this);
  }

  private void prepareHelpRequest() {
    Intent helpRequestIntent = new Intent(HELP_REQUEST_BROADCAST_ACTION);

    // All extras are OPTIONAL
    helpRequestIntent.putExtra(EXTRA_DEVELOPER_EMAIL, "developer@domain.com");
    helpRequestIntent.putExtra(EXTRA_EMAIL_SUBJECT, "Demo Help Request Mail Subject");
    helpRequestIntent.putExtra(EXTRA_PROBLEM_DESCRIPTION, "Demo Detailed Problem Description");
    helpRequestIntent.putExtra(EXTRA_ADDITIONAL_INFO, "Demo Additional Info");

    sendBroadcast(helpRequestIntent);
  }

  @Override
  public void onClick(View p_clickedView) {
    if (R.id.btnSendHelpRequest == p_clickedView.getId())
    {
      prepareHelpRequest();
    }
  }
}

After calling the sendBroadcast function, the "Help Me 2 Help You !" screen will be displayed and the user can click the "Help !" button to generate the report, which will include all the data provided by the broadcast intent:

Download it from the following link:
https://market.android.com/details?id=HelpMe2HelpYou.mainPackage