13

I am trying to share data from my app to other app like sms or any other app. I have a app where I need to send or share some data to apps like sms or fb messenger. Using this link through I can open up the app and add data into text box using this code:

  Intent sendIntent = new Intent();
  sendIntent.setPackage("com.sms or fb");
  sendIntent.setAction(Intent.ACTION_SEND);
  sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
  sendIntent.setType("text/plain");
  startActivity(sendIntent);

Using this app I can open up the other app and add value in text area my question is is there any way by which I can trigger click or send event to send automatic message to other app like sms facebook. If so how I have seen google app where I used my voice to send hi to my whatsapp contact so this method is there google app can send message and trigger event using my voice. My question is how can I trigger the event send using my android code. If rooted system is out there I can also use that.

None of the answer is even close to what I want to solve no answer deserves bounty.

Nilay Singh
  • 2,201
  • 6
  • 31
  • 61
  • "I know that when you use google app voice command they can open the app and send message without clicking" -- that is because WhatsApp integrated with Google's voice command system. – CommonsWare May 02 '17 at 16:38
  • you tell me where to find which app are integrated and which are not. And Can I do it programmatically if you know how to tell me. – Nilay Singh May 03 '17 at 12:14

8 Answers8

2

I don't know if it works but there is a SMSButtler App which replys automatic on receveid SMS. The good thing is that the app is opensource and you can download the code from this Github post.

I can't give you a answer about your Whatsapp problem but I analysed the code and I got this Method out of there:

To automaticly send a SMS message you first need to create a SMSManager

SmsManager sms = SmsManager.getDefault();

and then just send a text message

sms.sendTextMessage(destinationAddress, scAddress, text, sentIntent, deliveryIntent);

Parameter:

  • destinationAddress the address to send the message to
  • scAddress is the service center address or null to use the current default SMSC
  • text the body of the message to send
  • sentIntent if not NULL this PendingIntent is broadcast when the message is successfully sent, or failed.
  • deliveryIntent if not NULL this PendingIntent is broadcast when the message is delivered to the recipient. The raw pdu of the status report is in the extended data ("pdu").

Important: Using this method requires that your app has the android.Manifest.permission_SEND_SMS permission.

Note: There are also other Methods of this class where you can for example send images or other content.

Valentin Gavran
  • 341
  • 9
  • 21
1

There is no official api for normal third party apps to simulate user interaction. Frankly, I would not like my app being remote-controlled by another app. Depending on the app you want to control, there may be some options if these apps offer their services or content proiders to other apps. But you would need to consult their api docu, if one exists.

  • I am saying how google app open up the app and click a send button on whatsapp or wechat is there any way that I can open the app and put text with above code I can open the app and put text just need to know how to trigger click event. – Nilay Singh May 01 '17 at 14:02
  • As I said, there is no public means to simulate user interaction, that is, to trigger a click event –  May 01 '17 at 14:06
  • If my device is rooted then is it possible – Nilay Singh May 01 '17 at 14:07
  • It might be possible. You may want to check this answer to another Stack Overflow question: http://stackoverflow.com/a/15561286/5956451 –  May 01 '17 at 14:12
1

As @Thomas suggests. There is no official way to tell the other on what to do. For Google App the 3rd apps expose their Intent to invoke a particular action in their app from Google. Probably you could explore how it does.

But there are some possible solutions like app exposing Intent to trigger the action from 3rd party app.

Akshay Chordiya
  • 4,761
  • 3
  • 40
  • 52
1

I guess you need the capture the intent which google voice app is firing to the whatsapp/facebook app and use the same intent from your app.to check which intents are getting fired use adb logcat -b events.

However I feel even if you fire the same intent the security check in the receiving app might prevent it to do it.

You need to check whether facebook/whatsapp have publicly available APIs to do it.If not it is not possible.

Other approach-Use Uiautomator to perform click on the other apps button.But this is tricky to implement as you might need a separate app which listens for the events and triggers the automation code.

rupesh jain
  • 3,410
  • 1
  • 14
  • 22
1

There is a site/app called IFTTT(If this then that) that can control other sservices and send you alerts/emails/etc. Link: https://ifttt.com/

nabu
  • 25
  • 1
  • 10
1

If you want other apps trigger events in your apps, a general way includes two steps:.

  1. Your app needs to provide API following Android way.

  2. Other apps interact with your app by consuming the above API.

The type of API and its implementation depends on app data and function. For example, you can consider to use Content Provider, Intend and Broadcast to provide API.

Quang Nguyen
  • 2,600
  • 2
  • 17
  • 24
1

There is no general way provided by Android to remote control another app like you intend. You would have to modify the app you wish to control or the Android system itself. Either way, it won't be possible without non-trivial modifications to the system or app source code.

3k-
  • 2,467
  • 2
  • 23
  • 24
0

Please follow official android training (listed below):

Building Apps with Content Sharing: https://developer.android.com/training/building-content-sharing.html

Sending Simple Data to Other Apps: https://developer.android.com/training/sharing/send.html

Receiving Simple Data from Other Apps: https://developer.android.com/training/sharing/receive.html

silwalprabin
  • 637
  • 7
  • 20