3

I created one app like email clients app such as Gmail.

When user click on email address in another apps and choose my app from email sending apps in list appear on .

The email content like email address , email subject and .... come to my app by intent .

But the problem is intent.getData(); is null value all of the time and i try to get email data from intent .

I tested bundle in intent and i saw its not null and when i write this code :

bundle = intent.getExtras();
                Log.e("Email",bundle.toString());

the bundle.toString() return Bundle[{android.intent.extra.EMAIL=[Ljava.lang.String;@11cda76c}] .

I dont know what is this [Ljava.lang.String;@11cda76c}] and how i can get the email address from here ! ?

Cœur
  • 37,241
  • 25
  • 195
  • 267
SAYE
  • 1,247
  • 2
  • 20
  • 47
  • this is similar with http://stackoverflow.com/questions/15881033/get-string-from-bundle-android-returns-null – Camahalan Royette Mar 02 '17 at 05:44
  • @camahalanroyette i think this link about how to get special bundle when we create it . but i dont know what is bundle content . only i can recive it – SAYE Mar 02 '17 at 05:57

1 Answers1

3

Found answer here Passing values through bundle and get its value on another activity

bundle = this.getIntent().getExtras();
String email= bundle.getString("EMAIL");

Edit:

bundle = this.getIntent().getExtras();
String [] emails=bundle.getStringArray(Intent.EXTRA_EMAIL );
Community
  • 1
  • 1
  • Thanks but `bundle.getString("EMAIL")` returned me a null value . – SAYE Mar 02 '17 at 05:55
  • if you read my question exactly . i didn't create any bundle . only i receive it from another apps and now i want to access its content. – SAYE Mar 02 '17 at 05:58
  • I searched and found that extra email is an array so try `String [] emails=bundle.getStringArrayExtra(Intent.EXTRA_EMAIL ); ` – Camahalan Royette Mar 02 '17 at 06:17
  • the bundle class have no method named : `getStringArrayExtra` i used this code : `String [] emails= bundle.getStringArray(Intent.EXTRA_EMAIL);` when i print emails it show me something like this string : `[Ljava.lang.String;@2244b9ca` . do you know what is this ? – SAYE Mar 02 '17 at 06:51
  • I'm sorry it's **getStringArray** instead of **getStringArrayExtra** – Camahalan Royette Mar 02 '17 at 06:57
  • ok i used this to convert it to string thank you for help `Arrays.toString(email array from bundle);` pls edit you answer i accepted your answer . – SAYE Mar 02 '17 at 07:05
  • 1
    Emails in bundle are stored in array because it might contain one or more email recipient so converting to string maybe a problem when two or more recipient will be passed to your intent – Camahalan Royette Mar 02 '17 at 07:10