added code for sending email

This commit is contained in:
Marcin Jedynski 2018-11-11 19:55:17 +01:00
parent 9f23aae620
commit 1323c02b30

View File

@ -3,6 +3,7 @@ package com.uam.wmi.findmytutor.activity;
import android.Manifest;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
@ -101,6 +102,11 @@ public abstract class BaseActivity
}
startActivity(i);
finish();
} else if (itemName.equals(getResources().getString(R.string.navigation_item_feedback))) {
sendFeedback(getApplicationContext());
} else if (itemName.equals(getResources().getString(R.string.navigation_item_bug))) {
}
@ -351,6 +357,28 @@ public abstract class BaseActivity
MenuItem item = navigationView.getMenu().findItem(itemId);
item.setChecked(true);
}
/**
* Email client intent to send support mail
* Appends the necessary device information to email body
* useful when providing support
*/
static public void sendFeedback(Context context) {
String body = null;
try {
body = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
body = "\n\n-----------------------------\nPlease don't remove this information\n Device OS: Android \n Device OS version: " +
Build.VERSION.RELEASE + "\n App Version: " + body + "\n Device Brand: " + Build.BRAND +
"\n Device Model: " + Build.MODEL + "\n Device Manufacturer: " + Build.MANUFACTURER;
} catch (PackageManager.NameNotFoundException e) {
}
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("message/rfc822");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"team@findmytutor.com"});
intent.putExtra(Intent.EXTRA_SUBJECT, "Query from android app");
intent.putExtra(Intent.EXTRA_TEXT, body);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(Intent.createChooser(intent, context.getString(R.string.choose_email_client)));
}
abstract int getNavigationMenuItemId();