M. Stanton M. Stanton - 4 months ago 16
Java Question

Android: Get user-provided information sent to a private email

How would I get user-provided information (e.g. product feedback) from an android app to be sent to a private email account?

I currently run a website and we would like to develop an android app that allows users to input product feedback. We would like this feedback to then be sent or stored in a way that is only accessible to certain people. It doesn't necessarily have to be sent to email, it just needs to be private. We just want the product feedback to be available for us for review and comment.

Is there any place I could go to get started thinking about this?

Answer

Assume you have a EditText in your layout file, you get the text in your activity like this, where the et_some_user_input is the id of the EditText in your layout file.

EditText etSomeUserInput = (EditText)findViewById(R.id.et_some_user_input);
String someUserInput      =  etSomeUserInput.getText().toString();

Now you have the user input in someUserInput, you can send this string like this:

Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL  , new String[]{"recipient@private.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
i.putExtra(Intent.EXTRA_TEXT   , someUserInput);
try {
    startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
    Toast.makeText(MyActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}

Reference of the send email code.

This will make the user to fire up an email client such as google email, or yahoo email or any other email client the user choose. In case, you want the user input to be sent to your private email or somewhere you can access to without going through an email client. One suggestion is to set up a server that accepts user messages, so in your android app, you can send this message to your server, and you server can save that message into some sort of database, and you can then set up an admin web app to connect to that database to see what's being submitted by the user, or can you query that database directly.

If you are not sure what I am talking about, you will need to do some research to

How to set up a server to accept REST service calls in Java, PHP, Ruby, Python, Node.js or whatever programming language you prefer?

How to make REST service calls in Android?

If you don't have the resources to set up the server, then you can try to ask the internet if it's possible to send an email in Android without going through an email client.

Comments