Reputation: 538
I searched for the query online and figured the intent-filter
in the AndroidManifest.xml file. However, I am still unable to find how to receive the clicked email id in my application.
My problem
I have tried with the following function:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = getIntent();
String x = intent.getExtras().getString(Intent.EXTRA_EMAIL);
Toast.makeText(MainActivity.this, x, Toast.LENGTH_SHORT).show();
}
*Toast is for checking whether string is being received or no.
However, the toast appears empty,showing that the string is not getting received.
Upvotes: 0
Views: 686
Reputation: 1007369
If an app invokes your activity via an ACTION_VIEW
Intent
, there is no documented means for that app to give you an email address.
If an app invokes your activity via an ACTION_SENDTO
Intent
, the email address will be in the Uri
. That Uri
scheme should be mailto:
(as that what your filter is restricting it to). I think you get the address via getSchemeSpecificPart()
on the Uri
, though I have not tried this.
Note that there is no requirement for an app to launch any third-party activity when the user clicks an email address, let alone one of the two that you that you have set up via the <intent-filter>
.
Upvotes: 0
Reputation: 1592
I believe that the email intent is really designed for sending/composing an email, not for copying data from the email into your application. See here:
http://developer.android.com/guide/components/intents-common.html#Email
If you wanted to get an email address for someone, you may want to try the contacts intent instead:
http://developer.android.com/guide/components/intents-common.html#Contacts
Upvotes: 1