Sending email through intent without having to press send button - java

Currently I have a button that when pushed calls the Intent below.
Intent sharingIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
sharingIntent.putExtra(Intent.EXTRA_EMAIL,
new String[] { toString });
sharingIntent.putExtra(Intent.EXTRA_SUBJECT,
"New Files from Safe Storage");
sharingIntent.setType("text/*");
startActivity(sharingIntent);
This intent then uses the default share activity to share the email with my attached file (which i took out for this example). When this code goes off it opens the gmail activity for me, but i still need to push the send button even though everything is filled in. Is there a way to make this instead just send automatically without showing the user the activity and having them forced to push "Send"?

Have a look on the following link, there is an answer for your question.
Sending Email in Android using JavaMail API without using the default android app(Builtin Email application)

Related

How to share programmatically a message with a hyperlink from my Android app to Telegram without using bots?

I want to get something like this:
Download my app here
...but in a Telegram message when the user clicks a button in my Android app. Note the link in the word here.
I have the following code inside the button's onClickListener callback:
String msg = "Download my app here";
Intent myIntent = new Intent(Intent.ACTION_SEND);
myIntent.setType("text/plain");
myIntent.putExtra(Intent.EXTRA_TEXT, msg);
startActivity(Intent.createChooser(myIntent, "Share with"));
However, the above code does not create a clikable link on the word here, instead it explicitly shows what I have in the msg variable.
I tried with HTML:
This is an example
...and with markdown:
[This is an example](https://example.com)
Both cases don't work for my.
How to share programmatically a message with a hyperlink from my Android app to Telegram without using bots?
Please, note in my question that I don't want to use Telegram bots, like:
https://api.telegram.org/bot<BOT_TOKEN>/sendMessage?text=%3Ca+href%3D%27url.com%27%3Eword%3C%2Fa%3E&chat_id=<chat_id>&parse_mode=HTML

Android, killing an Activity from another Activity from GCM message

I've currently wrote an app that receives a GCM message and stores it in a database then creates an alertDialog to show above any app what the new message is, the only problem i have is if a new message is received before the current alertDialog is closed you don't get to see the new message, if i sit and close each message its fine.
So i think what ive been trying is to ask 'is the alertDialog showing...if not show the message, if its already showing close it and open a new one with the new message'.
Does this sound feasible?
Cheers
Mark
I would recommend using a notification rather than an alert dialog for showing incoming messages. The NotificationManager lets you set an id and tag when you post a notification. Then if you later post one with the same id and tag, the existing one will be updated.
On Lollipop (and newer) devices you can even get a similar effect to what you describe with the notification coming up on top of the current app using heads up notifications: http://developer.android.com/guide/topics/ui/notifiers/notifications.html#Heads-up

Android notification, when pushed should open that activity

Im having problems with notifications in android. Im making a chat client.
when my client tells me that someone is chatting with me from a previous chat, and I push it, it opens up a new instance of that chat. I want it to work like the facebook mesenger, that is when I push the notification it opens up the chat for the person which is trying to speak to me, instead of an empty chat window.
regards.
In your Notification you can set a Intent:
Notification n;
n.setContentIntent(intent)
In your intent you will set the activity that will be started and also you can put extras, like an ID of the conversation or something that can be identified latter.
Because when you start this new chat activity on onCreate() you need to check if there is extras, take the ID for example and search for your conversation history and write all your logic.

How do i get parent caller

Let us say that user opens Twitter app and hits share button for a selected tweet. He then sees my app in the list along with other apps like Gmail, SMS etc.
In OnCreate method of my activity, I process the tweet. Remove short links etc and then call the PostActivity of twitter app. Below code then shows "My tweet" in compose tweet section of twitter app.
Intent intent1 = new Intent("android.intent.action.MAIN");
intent1.setComponent(new ComponentName("com.twitter.android","com.twitter.android.PostActivity"));
intent1.setAction(android.content.Intent.ACTION_SEND);
intent1.putExtra(android.content.Intent.EXTRA_TEXT,"my tweet");
intent1.setType("text/plain");
startActivity(intent1);
What i want to do is ,before i call PostActivity, i need make 100% sure that my activity was called from twitter app.

Trivial: Get confirmation of email sent in android

After starting an email intent how can I get confirmation that the email has sent or there has been an error back into the activity it was called from?
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setType("png/image");
String subject = "Email Subject";
String body = "Message Body";
emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(Intent.EXTRA_TEXT, body);
emailIntent.putExtra(Intent.EXTRA_STREAM,
Uri.parse("file:///sdcard/" + IMAGE_FILENAME));
startActivity(Intent.createChooser(emailIntent, "Send email..."));
//Here I need to do something on a successfully sent email
Maybe start activityForResult? But what result should I expect back if any?
That really depends on the app that is launched by your Intent. It could be the Gmail app, it could be the Email app, or it could be any third-party app. Because of this, there is no 100% reliable way to determine whether the user actually pressed Send or not.
The only thing you can do is check if the Gmail and Email apps return anything relevant when called via startActivityForResult and rely on that. But beware that is not reliable because, again, there could be third party apps. Also, since these apps do not specify publicly what they return, they might change that at some point without any notice.
you cannot get any useful resultcode from an email intent. onActivityResult always return 0 as soon as sending starts or sending is canceled.
Additionaly if you attach files, onActivityResult is called BEFORE those files are read.
You can NOT do this.
ACTION_SEND does NOT have any output as a result you always get the default value which is RESULT_CANCELED.
Also you can NOT check it with Intent data coming back because it is always null either mail send or discard.

Categories

Resources