How to check sent text in OnActivityResult? - android

I need to be able to check if the user has sent the text I set in my code;
Intent messageIntent = new Intent(Intent.ACTION_SEND)
messageIntent.putExtra(Intent.EXTRA_TEXT, "Text I want to send");
or has changed the prefixed text (on the SMS client app, email client app, or the app that gets launched by the intent) before sending it.
I need to know this because sharing my game link will give a reward to the user, so I need to check if that link is correctly shared.
I would appreciate any answer that could help.
Thanks.

ACTION_SEND isn't documented to return a result. So starting the intent with startActivityForResult() will return the default result: RESULT_CANCELED. That is, unless the receiving app has implemented support for returning a result; which is highly unlikely because it's not part of the documented behavior.
In summary, what you want to do is not possible with any of the common Intents.

You can try this...
String message = "Your Message";
intent.putExtra("IDENTIFIER", message);
And where you are going to receive the message...
String messageReceived = getIntent().getExtras().get("IDENTIFIER").toString();

Related

Autoresponse for Line

How to achieve the android line automatically reply message function?
Receiving messages using NotificationListenerService, what you need to do now is to reply to the messenger when you receive the message, and automatically do not touch the screen at all?
The following is the message text to the line, and you want to manually select the object to be transferred.
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse("line://msg/text/" + text));
startActivity(intent);
But I would like to send a message to a specific person manually.
A similar problem is Automatic reply for whatsapp messages approach, but I was going to automatic-reply-for-line not whatsapp.
There are other products seen on this function, but can try all the methods have tried to achieve the function I want ....
So is this possible?

How to receive email from system, using Intent Filter?

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
Suppose I receive a message on my WhatsApp chat box containing an email id (xyz#test.com).
On clicking the email id (xyz#test.com), I want my app to open. (Figured, using Intent-filter)
Upon opening my application, I want the email id (xyz#test.com) to be automatically copied into the EditText on my activity.
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.
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
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>.

Launch a different sms app to send sms programmatically without opening it

This below approach opens the app but doesn't do anything.
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
String phoneNumber = "phone number here";
String text = "Hi belated happy diwali";
Intent smsIntent = getPackageManager().getLaunchIntentForPackage("sun.way2sms.hyd.com");
smsIntent.setType("vnd.android-dir/mms-sms");
smsIntent.putExtra("address", phoneNumber);
smsIntent.putExtra("sms_body", text);
startActivity(smsIntent);
}
});
As per my knowledge, like default SMS Manager you can't send message directly with other apps....like way2sms / whatsapp. If and only if they are providing there SDK and with that option.
Do you know the 'key' -> "address" and "sms_body" are using by way2sms app to receive your data!!!!
For Eg: Facebook you can post directly with ur app by using some user permissions.
If you are using a third party app the best you can do is launch the third party app with the data pre filled just like the native app.
If the third party app provides any support for sending sms in the background (like a broadcast or something) then you can do it. Although the chances of any app having such functionality is low

What's the proper way to share via Intent.createChooser

The problem is I have an article that want to share to other apps, and I want to let the user to choose which app to share to. What I want to share is basically:
the title of the article
the URL of the article
the article content as HTML
the URL with some extra text (such as 'http://foo.com/article share from #FooApp')
All of these fields are optional, but I want to share at least one of them.
Such as when share via SMS or twitter, I want to set the content to part 4. when share via Facebook, I want to set 1, 2, 3 together. And when share via email, I want to set subject as 1 and message as 4.
I know (correct me if I'm wrong) every target intent receiver has it's own logic to pick up the fields it needed. So I want to provide as much information as possible and I wrote the following code:
String message = article.getURL() + " #FooApp";
Intent intent = new Intent().setData(Uri.parse(article.getURL())
.putExtra(Intent.EXTRA_SUBJECT, article.getTitle())
.putExtra(Intent.EXTRA_TEXT, message)
.putExtra(Intent.EXTRA_HTML_TEXT, article.getHTML())
.putExtra("sms_body", message)
...
.setType(HTTP.PLAIN_TEXT_TYPE);
startActivity(Intent.createChooser(intent, "Share to"));
But the problem is, it seems like a trick between setData, putExtra, setType.
For some apps appear in the chooser dialog, when I choose, the confirm share window (of that app) display nothing that I set to the intent. (for some other apps they just say failed to fetch resource)
For the putExtra part, when I add or remove some putExtra code, the target intent receivers diff a lot than I expected.
So the question is: am I doing it the wrong way? Are there some guideline for this problem?

How to send MMS without prompting to send it via gmail ,whatsapp or something else ?

When I am Using this code to send mms to specific user it shows me popup to send it via gmail,whatsapp,gtalk,message and etc. But in my case I just want to send that image as an mms to specific number that i will define in address field whithout showing any popup can any body tell me How to do this ? I googled for this and find lot of stuff on it.
Here is my code*strong text*
public void sendData(int num){
String fileString = "..."; //put the location of the file here
Intent mmsIntent = new Intent(Intent.ACTION_SEND);
mmsIntent.putExtra("sms_body", "text");
mmsIntent.putExtra("address", num);
mmsIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(fileString)));
msIntent.setType("image/jpeg");
startActivity(Intent.createChooser(mmsIntent, "Send"));
}
Using an intent (like you did) is the preferred way because it's easy to implement and let the user choose his favorite app for the task of sending the MMS.
That being said you can still implement yourself the operation and send the MMS programmatically from your app by crafting and sending the appropriate HTTP request.
The following answer will provide you all the information you need: How to send image via MMS in Android?

Categories

Resources