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

Friday, April 8, 2011

AutomateIt - Frequently Asked Questions

Visit our new website at http://www.automateitapp.com

Question: Why do you require root for this application ? Will it still work if I don't have a rooted device ?
The root is used solely for the several actions such as “Kill Application”, "Shutdown Device" or on some devices (Android 2.3+) it might be required to turn on/off GPS and Sync.
It is used since the application does not run in a privileged context and cannot kill other applications or shutdown the device.
If this is something that is of no interest to you, you can just deny root access to the application and all other functionalities will work exactly the same, except you will not see the “Kill Application Action” in the action selection dropdown, and if you already defined a rule that uses this action, it will not show on the application main screen, and of course, will not execute.
You can also check out this post  for the source code used for executing root commands in the application.

Question: I keep getting a toast message for "AutomateIt has been granted superuser permission" . why is this happening ?
This behavior is caused by the way Android manages its services and applications. On times that are decided by the Android operating system it recycles some of its services and kills applications to release memory and other system resources.
As part of this recycling process, Android terminates the AutomateIt service and restarts it, which causes the "Superuser" message to pop (this message is shown by the "Superuser" application you use).
AutomateIt does NOT perform any activity when it is just started besides checking for root access. Unfortunately, Just by checking for root access pops this message.
You can also check out this post  for the source code used for checking for root access in the application.


As of version 1.22.0 (Free) and 2.22.0 (Pro) this toast message should no longer be displayed when AutomateIt service is recycled, but will still popup when an action that uses root privileges is launched.

Question: Enable/Disable GPS or sync action does not work or is not available on my device. Why is that ?
Enabling or disabling GPS and sync is officially not supported by Google. Up until Android 2.2 (Froyo) this was done in an unofficial way that is no longer available on Android 2.3 (Gingerbread) and above. If you have a device that runs Android 2.3 or above and you don't have root privileges, these actions will not be available. On rooted devices these actions will be available but might not work, depends on the installed ROM (For instance, Cyanogen-based ROMs supports this action).

Question: I want to make a rule based on a wifi network but the application does not show the network name even that this network is saved in my device , it only shows the name of the network I'm currently connected to. Is this how it should work ?
Yes, this is the expected behavior. In order to define a rule that relates to a specific WiFi network, it needs to be available at the time when you are defining this rule. This is caused by the fact that AutomateIt requires a unique value that identifies the network (Network name can't be trusted as unique value), and this is only available when the network is available.

Question: I defined a rule that uses a location trigger and it doesn't seem to work. What could be the reason for it ?
Please visit this post for a more detailed description on how to use the location trigger. most of the times, it's a matter of using the correct proximity radius for your area, available location providers and location fix accuracy.

Question: Does AutomateIt requires a lot of system resources ? How will it affect my battery consumption ?
The application is not supposed to consume battery since it literally sits and waits for events doing nothing. The only thing that might consume battery in the application is the location triggers, but its battery consumption can be controlled as described in this post.

Question: I'm trying to use the "SMS With Text" trigger and it doesn't seem to work, although the "Any SMS Trigger" does work. What could be the reason for it ?
In most cases where this happens, It's probably caused by a blank character in the text you've   defined for the "SMS with Text" trigger. make sure you don't have any blank space or new line in your SMS text.

Question: Can AutomateIt be moved to SD Card ?
Unfortunately, The short answer is "No". There are several types of applications that Android requires to run from internal storage due to technical limitations and AutomateIt is one of those apps. For a more technical explanation, see the "Applications That Should NOT Install on External Storage" section on this link.

Question: During a delayed execution of a rule I get a notification  on the notification bar with the execution countdown. Is there a way for this not to be shown ?
Since AutomateIt runs a a background process the only way to ensure that the delayed execution countdown will not be terminated is to show a notification on the notification bar. Also, If this notification is removed, you won't have any way to cancel the delayed execution. 

Question: I bought AutomateIt Pro and my rules have disappeared and I'm getting a "License can't be verified" message in my notification bar. How can I resolve this issue ?
AutomateIt Pro uses the licensing mechanism provided by Google which requires Internet connection once in a few days to validate the license. There are several things you can do to resolve this issue: Make sure your device has Internet connection and reboot your device. In most cases this should resolve the issue. If this does not resolve the issue you can uninstall the app (after making a backup of your rules before they are removed, immediately after reboot) and re-installing the app and restore your rules. If that also doesn't work, please contact the developer using the "Help !" button on the About screen of the app.


Question: When editing an action or a trigger, even though I press the "Save" button, the settings are not saved and revert back to the default values. What's wrong ?
This issue is caused by using the "Don't keep activities" checkbox of the "Developer options" on the device settings (See images below). When using this setting, it kills the activity with the edited properties before it returns back to the edit rule screen, hence, it can't get the edited settings. By unchecking this checkbox, the issue should be resolved.

Question: I'm getting a "Force Close" message or think I found a bug in your application. What is the best way to report it ?
There are two ways for reporting an issue with the application and such reports are very much appreciated as it helps me keep improving the application.
One way to report in case of a "Force Close" message is simply by pressing the "Report" button on the popup message. this will submit most of the data that is required for me to try and resolve the issue.
The other way (Which is more preferable by me as it delivers more relevant data)  is by pressing the "Help !" button on the "About" screen of the application, as soon as possible after you experience the error or unexpected behavior. This will create an email with a more detailed report and some additional files that will help me trying to resolve your issue.
Please be as descriptive as possible in describing the scenario that lead to having your problem.

More Q&A available on the XDA-Developers website in the application thread.