Fill in email using enteries Eclipse Android forms

I am new to coding, this is my first application and would like to fill out the body of the email using the entries from my form. I tried all day to make it work, I just did not understand, any help would be greatly appreciated. The log entries in the console reflect the input of the form, but the email is not populated. Thanks in advance,

Here is the code I have.

<?xml version="1.0" encoding="UTF-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/scrollView1" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <TextView android:id="@+id/appDiscription" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="@string/discription_text" android:textAppearance="?android:attr/textAppearanceLarge" /> <Spinner android:id="@+id/employeeSpinner" android:layout_width="match_parent" android:layout_height="44dp" android:entries="@array/employeeSpinner" android:prompt="@string/employeeSpinner" /> <Spinner android:id="@+id/jobTypeSpinner" android:layout_width="match_parent" android:layout_height="44dp" android:entries="@array/jobTypeSpinner" android:prompt="@string/jobTypeSpinner" /> <EditText android:id="@+id/jobDateText" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:hint="@string/job_date_text" android:inputType="date" > <requestFocus /> </EditText> <EditText android:id="@+id/clientText" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:hint="@string/client_text" android:inputType="textPersonName" /> <EditText android:id="@+id/arrivalText" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:hint="@string/arrival_text" android:inputType="time" /> <EditText android:id="@+id/departureText" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:hint="@string/departure_text" android:inputType="time" /> <EditText android:id="@+id/assignmentText" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:hint="@string/assignment_text" android:inputType="textPersonName"/> <EditText android:id="@+id/notesText" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:hint="@string/notes_text" android:inputType="textMultiLine" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:onClick="onClick" android:text="@string/submit_button" /> </LinearLayout> 


 import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.EditText; import android.widget.Spinner; public class AssignmentTracker extends Activity { Spinner employeeSpinner; Spinner jobTypeSpinner; EditText clientText; EditText jobDateText; EditText arrivalText; EditText departureText; EditText assignmentText; EditText notesText; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); employeeSpinner = (Spinner) findViewById(R.id.employeeSpinner); jobTypeSpinner = (Spinner) findViewById(R.id.jobTypeSpinner); clientText = (EditText) findViewById(R.id.clientText); jobDateText = (EditText) findViewById(R.id.jobDateText); arrivalText = (EditText) findViewById(R.id.arrivalText); departureText = (EditText) findViewById(R.id.departureText); assignmentText = (EditText) findViewById(R.id.assignmentText); notesText = (EditText) findViewById(R.id.notesText); } public void onClick(View v) { String employeeType = employeeSpinner.getSelectedItem().toString(); String jobType = jobTypeSpinner.getSelectedItem().toString(); String nameText = clientText.getText().toString(); String dateText = jobDateText.getText().toString(); String arrivalType = arrivalText.getText().toString(); String departureType = departureText.getText().toString(); String assignText = assignmentText.getText().toString(); String noteText = notesText.getText().toString(); Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Daily Worksheet"); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Employee:" + employeeSpinner.getSelectedItem().toString()); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Job Type:" + jobTypeSpinner.getSelectedItem().toString()); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Date:" + jobDateText.getText().toString()); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Client:" + clientText.getText().toString()); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Arrival Time:" + arrivalText.getText().toString()); emailIntent.putExtra(android.content.Intent. EXTRA_TEXT, "Departure Time:" + departureText.getText().toString()); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Assignment:" + assignmentText.getText().toString()); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Notes:" + notesText.getText().toString()); emailIntent.setType("plain/text"); startActivity(emailIntent); Log.d("AssignmentTracker", "onClicked " + employeeType); Log.d("AssignmentTracker", "onClicked " + jobType); Log.d("AssignmentTracker", "onClicked " + nameText); Log.d("AssignmentTracker", "onClicked " + dateText); Log.d("AssignmentTracker", "onClicked " + arrivalType); Log.d("AssignmentTracker", "onClicked " + departureType); Log.d("AssignmentTracker", "onClicked " + assignText); Log.d("AssignmentTracker", "onClicked " + noteText); 
+4
source share
1 answer

You can only set fields such as email address, subject and body.

You can compose body text from the fields that you have and send it as shown below.

 try { final Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType("plain/text"); if (recipient != null) intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{to}); if (subject != null) intent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject); if (message != null) intent.putExtra(android.content.Intent.EXTRA_TEXT, message); startActivity(Intent.createChooser(intent, "Send mail...")); } catch (ActivityNotFoundException e) { } 
0
source

Source: https://habr.com/ru/post/1438819/


All Articles