access to any email inbox from my activity in android - android

As we use "content://sms/inbox" for sms inbox, do we have anything like this for email.I want to read email from after selecting email client.I tried the following the code
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setType("message/rfc822");
Uri data = Uri.parse("content://mail/inbox");
intent.setData(data);
startactivity(intent);
I dont want to send mail,just to read the mail,So i cant use mailto:

You should use this :
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("message/rfc822");
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.putExtra(Intent.EXTRA_TEXT, message);
Intent mailer = Intent.createChooser(intent, null);
startActivity(mailer);

Related

Open email app programmatically in android for new update

How can I open a device email to send an email on the new update of android? it's showing a list of applications with support text/message/html/plain with the following code?
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{context.getString("email_to")});
intent.putExtra(Intent.EXTRA_SUBJECT, context.getString("email_subject"));
context.startActivity(Intent.createChooser(intent, context.getString("email_body")));
This Intent will work For Email client with mailto Uri:
try {
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:")); // only email apps should handle this
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"example.yahoo.com"});
intent.putExtra(Intent.EXTRA_SUBJECT, "App feedback");
startActivity(intent);
} catch (android.content.ActivityNotFoundException ex) {
ToastUtil.showShortToast(getActivity(), "There are no email client installed on your device.");
}
I have found the following code to open the email app programmatically use the following code. I hope this may solve your problem.
Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse("mailto:"+"email_to"));
intent.putExtra(Intent.EXTRA_SUBJECT, "email_subject");
intent.putExtra(Intent.EXTRA_TEXT, "email_body");
startActivity(intent);

Search for linkedin app in android via intent

I am using intent to get the list of all apps i can post text to. However, linkedin is not appearing in that list. Do i need to do anything extra for linkedin?
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "dcsd");
package= mContext.getPackageManager();
List<ResolveInfo> appTargets= package.queryIntentActivities(shareIntent, 0);
I am able to get all other apps like Facebook, Twitter except LinkedIn?
What could be the possible reason?
Code is
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
String shareBody = "https://developers.facebook.com/docs/android/share";
intent.putExtra(Intent.EXTRA_TITLE,"Share From Test App");
intent.putExtra(Intent.EXTRA_TEXT,shareBody);
intent.putExtra(Intent.EXTRA_SUBJECT, "hello");
startActivity(Intent.createChooser(intent, "Share With"));
Add this to the intent:
intent.putExtra(Intent.EXTRA_SUBJECT, "dsvs");

How to send multimedia messages with android intent?

I'm trying to send an multimedia message(with an image) through an intent.How should I build the intent?
I've tried the code:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/png");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/documents/aaa.png")));
I can select mms app(Textra) from chooser dialog to send the image. But the chooser dialog lists other apps(such as Google Keep).
Then I tried this:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("sms:"));
Only mms apps appears now.But I don't know how to attach my image.
Is there any solution for that?
try this may help,
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
intent.putExtra("sms_body", "write some text here");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/documents/whatever.png")));
intent.setType("image/*");
startActivity(intent);
Try this way,hope this will help you to solve your problem.
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra("sms_body", "some text");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/documents/aaa.png")));
intent.setType("image/png");
startActivity(intent);

intent to share text to email clients (only email clients)

String value = text.getText().toString();
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"test#test.test"});
intent.putExtra(Intent.EXTRA_SUBJECT, "subject");
intent.putExtra(Intent.EXTRA_TEXT, value);
startActivity(Intent.createChooser(intent, "Send Email"));
this code runs, but it show a list of applications like notepad (and other notepad app), whatsapp (and several chat app).
I need a list of only email clients. I done a long search but the code is always same.
try the following code with content type:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("plain/text");
intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "some#email.address" });
intent.putExtra(Intent.EXTRA_SUBJECT, "subject");
intent.putExtra(Intent.EXTRA_TEXT, "mail body");
startActivity(Intent.createChooser(intent, ""));
Edit1: Check out this post for sending email directly without opening the email client.

How to send mail only through email clients in my android application

How to send mail through only email clients from my android application.
I am using the below code in my application but its opeing messeges and bluetooth also. I need only Email clients like Gmail or yahoo.
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/rfc822");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, "mailto#gmail.com");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "My subject");
startActivity(Intent.createChooser(emailIntent, "Email:"))
Just Go on to Use this Code...It will always invoke your default Email Client.
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri data = Uri.parse("mailto:?subject=" + subject + "&body=" + body);
intent.setData(data);
startActivity(intent);
Is this of any help? This one is using the gmail client it seems.
Intent URI to launch Gmail App
I use this way to avoid choosing other app but default email client.
Intent it = new Intent(Intent.ACTION_SEND);
it.setType("text/plain");
it.putExtra(Intent.EXTRA_EMAIL, new String[]{emailAddr});
it.putExtra(Intent.EXTRA_SUBJECT, emailSubject);
it.putExtra(Intent.EXTRA_TEXT, emailContent);
it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + emailAddr));
emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ActivityInfo info = emailIntent.resolveActivityInfo(mContext.getPackageManager(), PackageManager.MATCH_DEFAULT_ONLY);
if (info != null) {
it.setPackage(info.packageName);
}
mContext.startActivity(it);
I hope it can help you ~
I made it work using this:
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("mp3/3gp");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "recording voice");
Uri eri=Uri.parse(rlm.getPlayList().get(position).get("songPath"));
emailIntent.putExtra(Intent.EXTRA_STREAM,eri);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "hello, it is the recorded file of our conversassion");
emailIntent.putExtra(Intent.EXTRA_STREAM,rlm.getPlayList().get(position).get("songPath") );
RecordedList.this.startActivity(Intent.createChooser(emailIntent, "Send Email"));

Categories

Resources