1

I have written a Survey application in android. It contains 10 questions, which is having two checkboxes for each question which says Yes or No. After completing the survey if the user clicks the submit button it should send mail.

Below is my code,

submit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "abhi.bhardwaj75@gmail.com", null));
                intent.putExtra(Intent.EXTRA_SUBJECT,"Application Survey" );
                intent.putExtra(Intent.EXTRA_TEXT, question1);
                startActivity(Intent.createChooser(intent, "Choose an Email client :"));
            }
        });

Here in putExtra I am able to pass only one string value. Can you anyone please help me how to pass the multiple String values?

I tried the below code also, but it is not working. I am not getting the value.

intent.putExtra(Intent.EXTRA_TEXT, new String[]{question1});
Abhishek Jain
  • 3,562
  • 2
  • 26
  • 44
Abhi
  • 27
  • 1
  • 5
  • 2
    Possible duplicate of [Android, Can I use putExtra to pass multiple values](https://stackoverflow.com/questions/8452526/android-can-i-use-putextra-to-pass-multiple-values) – Bö macht Blau Apr 26 '18 at 16:57
  • You should either try Parcelable or create a HashMap of Questions and use Serrializable to extract data, otherwise if you are ok in creating 10 putExtra line you can use intent.putExtra(Intent.EXTRA_TEXT_Q1, question1); – Kumar Nitesh Apr 26 '18 at 17:50
  • Hi Knitesh, I tried to add 10 putExtra line, but it is giving error. I cannot add Intent.EXTRA_TEXT_Q1, it says cannot resolve symbol. – Abhi Apr 27 '18 at 18:16

1 Answers1

0

Try to use intent.putStringArrayListExtra(String name, ArrayList<String> value)

Warrocker
  • 734
  • 6
  • 12