简体   繁体   中英

I want my android app to have a simple form that can send information to my gmail

Please Help! I'm kinda new to android but I am trying to create an app with a simple form that consists of a name field an email field and a send button. When the button is clicked, I need it to send their name and email address to my email address. Is this possible? I'm not trying to have them open up an email client on the device but just to be able to click the button once send their name and email to my email kinda like website forms.

Here is my java code (Sorry if its kinda hard to read)

package com.mail;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

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

    }
        public void sendFeedback(View button) {  
                    // Do click handling here  

           final EditText nameField = (EditText) findViewById(R.id.EditTextName);  
          String name = nameField.getText().toString();  

          final EditText emailField = (EditText) findViewById(R.id.EditTextEmail);  
          String email = emailField.getText().toString(); 

    }
}

If you want to send the email through an email app installed on the device you can use the process described in the " how to send email from my android application " question.

However, it sounds like you want to send the email without any user interaction with an email app.

You could make "a website form that sends email" like you mentioned in your question, and invoke the form's action URL with parameters built from your two fields using Android's HttpClient class.

If you want to build and send the email from the Android app itself, and not rely on separate code on a web server, you'll want to use something like JavaMail inside your app. Here's a blog post with code and links to an Android compatible version of JavaMail.

You cannot send an email on behalf of the user wihtout the user explicitly agreeing to it. What you can do though is to send that data to a Google docs spreadsheet and then have the Google sheet send you a notification on gmail every time someone sends data. This article details how to send data from android app to Google docs sheet.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM