Tutorial details

[TUT] Email Feedback from Users (device information) | App Code for Sale | Preview

[TUT] Email Feedback from Users (device information) | Android Tutorial

How to get Email Feedback from Users

Overview PAGE TOP

I recently updated my McDonalds Calories application and improved the feedback facilities. Whilst I was doing this I realised it would be good to do in all of my apps and therefore wrote this utility class just for the purpose.

The idea is to gain more information about the users devices when they send you (dare I say it complaint) feedback about the app functionality.

This email will now include by default a good amount of information about the device. Including the Android version and make, model, screen density of the device. The email automatically sets the subject to the name of the application and appends the version of the running app to the end.

Like so:

feedback-168x300.png

I made it nice and easy I can now just include my FeedbackUtils class and with one line get a nice feedback email with a lot of information to help my deliteful users!

1   FeedbackUtils.askForFeedback(context);

And here is the code.

FeedbackUtils.java

1   import android.content.Context;
2   import android.content.Intent;
3   import android.content.pm.PackageManager.NameNotFoundException;
4   import android.os.Build;
5    
6   public class FeedbackUtils {
7       private static final String FEEDBACK_CHOOSER_TITLE = "Feedback. Have we forgotten something?";
8       private static final String EMAIL_ADDRESS = "support@blundell-apps.com";
9    
10      public static void askForFeedback(Context context) {
11          final Intent emailIntent = new Intent(Intent.ACTION_SEND);
12          emailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
13          emailIntent.setType("plain/text");
14          emailIntent.putExtra(Intent.EXTRA_EMAIL, getFeedbackEmailAddress());
15          emailIntent.putExtra(Intent.EXTRA_SUBJECT, getFeedbackEmailSubject(context));
16          emailIntent.putExtra(Intent.EXTRA_TEXT, getFeedbackDeviceInformation(context));
17          context.startActivity(Intent.createChooser(emailIntent, FEEDBACK_CHOOSER_TITLE));
18      }
19   
20      private static String[] getFeedbackEmailAddress() {
21          return new String[] { EMAIL_ADDRESS };
22      }
23   
24      private static String getFeedbackEmailSubject(Context context) {
25          return getApplicationName(context) + " Feedback v" + getAppVersion(context);
26      }
27   
28      private static String getApplicationName(Context context) {
29          return context.getString(context.getApplicationInfo().labelRes);
30      }
31   
32      private static String getAppVersion(Context context) {
33          try {
34              return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
35          } catch (NameNotFoundException e) {
36              return "vX.XX";
37          }
38      }
39   
40      private static String getFeedbackDeviceInformation(Context context) {
41          StringBuilder emailMessage = new StringBuilder();
42          emailMessage.append("\n\n_________________");
43          emailMessage.append("\n\nDevice info:\n\n");
44          emailMessage.append(getHandsetInformation(context));
45          emailMessage.append("\nPlease leave this data in the email to help with app issues and write above or below here. \n\n");
46          emailMessage.append("_________________\n\n");
47          return emailMessage.toString();
48      }
49   
50      private static String getHandsetInformation(Context context) {
51          StringBuilder handsetInfoBuilder = new StringBuilder();
52          handsetInfoBuilder.append("Bootloader: " + Build.BOOTLOADER);
53          handsetInfoBuilder.append("\nBrand: " + Build.BRAND);
54          handsetInfoBuilder.append("\nDevice: " + Build.DEVICE);
55          handsetInfoBuilder.append("\nManufacturer: " + Build.MANUFACTURER);
56          handsetInfoBuilder.append("\nModel: " + Build.MODEL);
57          handsetInfoBuilder.append("\nScreen Density: " + getDeviceDensity(context));
58          handsetInfoBuilder.append("\nVersion SDK int: " + Build.VERSION.SDK_INT);
59          handsetInfoBuilder.append("\nVersion codename: " + Build.VERSION.CODENAME);
60          handsetInfoBuilder.append("\nVersion incremental: " + Build.VERSION.INCREMENTAL);
61          handsetInfoBuilder.append("\n");
62          return handsetInfoBuilder.toString();
63      }
64   
65      private static float getDeviceDensity(Context context) {
66          return context.getResources().getDisplayMetrics().density;
67      }
68  }

Enjoy!

Reference PAGE TOP

http://blog.blundell-apps.com/tut-email-feedback-from-users-device-information/

0 Comments Leave a comment

Please login in order to leave a comment.

Newest first
!

Sign-in to your Chupamobile Account.

The Easiest way to Launch your next App or Game.

Join Chupamobile and get instant access to thousands of ready made App and Game Templates.

Creating an account means you’re okay with Chupamobile’s Terms of Service and Privacy Policy.