I'm writing an app which sends a predefined message to a predefined number. It then gets the response and displays this to the user. I've got the mobile side working, and I am now working on the Wear app, however have become a little stuck as to how to do it.
I've managed to send the message from the Wear device by implementing a listener on the mobile app, which then triggers the activity to send a message. What I can't figure out how to do, is that the response the app gets and send it back to the Wear device.
Looking here:https://developer.android.com/training/wearables/data-layer/index.html
I have used the MessagesAPI for sending the message, however unsure what to use if I want to receive a message. Does anyone know what the best way to do this would be? My initial instinct says I'm going to have to ditch the messagesApi and use the Data one?
You should send the response the same way you used to send the first message, but this time the wearable will be listening for messages (usually in your WearableListenerService).
Take a look at this: https://github.com/heinrisch/talkclient
Either you can use the library or look at the code. I would look at the code, its quite easy to follow.
It sounds like you can use either data or message api, depending on your needs. To receive a message you either have the app active and get it though a listener, or you create a service.
Related
There is a scenario where I have to communicate from one android device to another android device (Far Away). But without using any server or sms service. Although I do have an active internet connection. I found a way through GCM, as GCM service provide data upstream as well as data downstream.
I want to know is there anymore way of doing this ?
You need a notification service, and google has something like that for us...
how does this works??
Take a look at the image below,
you need to register your android app in the google service, and your web interface will need an id, so everytime you want to push something to the android, your web interface instead will push it to the google server with the Id of the app, then google (no matter how) will localize your app, and even if its not running, they will get the notification,
behind the scenes there is a couple of thing that you must do, bu nothing like launching rockets from the NASA.
I will suggest to take a look to some tutorials
in order to start with the registration of your app, get the api key etc etc..
In your case
you will need the id of the other phone, so you can push it data.
I’m trying to develop an application to do some manipulation (compression and security matters) on the outgoing Sms regardless of the composer application. The main challenge is that I cannot capture the Sms exactly before being sent. For instance the user compose the message body using Go Sms Pro and when the send button is pressed , right before the sms is actually sent we capture it and do the compression and security matters on .
Any solution or replacement idea appreciated.
Starting with KitKat, the SMS content provider has been opened up (finally): http://developer.android.com/about/versions/android-4.4.html
To make this work with previous versions of android, you could set up a content observer to watch content://sms/, query the appropriate tables in that database, and then do whatever you like to erase the message before it goes out. This is just a thought mind you, but whatever you do will likely involve using this method.
This is not possible, short of via your own custom build of the Android OS. You have no ability to intercept, let alone modify, the calls from an arbitrary app via SmsManager to the OS to send an SMS message.
In a certain situation, I'd like my app to be able to "fake" an incoming SMS on the user's device, as a sort of notification. This would save me money when I'd normally use Twilio to send a text to my users but I know they already have my app. Is there any way to do this? I imagine it would have something to do with Intents and Content Providers but I don't really know where to start.
To clarify:
I'm not new to Android and I do respect all of the normal Notification methods. However, my app will have an opt-in for text messages and I'd like to be able to trigger them for free rather than paying for it. This is for SMS-specific uses and not as a substitute for a normal Notification.
Yes (although I really don't support doing this) it is, in theory possible by creating and broadcasting the proper intent. Specifically, they android.provider.Telephony.SMS_RECEIVED intent will be received by anybody who is listening for SMS messages, including the default SMS application. This will in turn cause the notification to be displayed.
All of that said, I've only ever done this in a custom version of Android from within the system process. I'm really not sure if a generic application can do this (in fact, I kinda doubt it). The other caveat is that you will need to formulate your data into PDU's which represent the binary data format of an SMS message. You can look this up, but it's nontrivial.
A far better approach would be to simply have your application display a notification in the tray, the way well behaved applications are supposed to notify the users of events. Take a look at the Notification class.
If you install the apk named ApiDemos-debug.apk that usually comes installed with your choosen platform for the SDK, you will find an example in
<Api Demos> > App > Notification > IncomingMessage
the complete source for this package is usually under
<SDK root>/samples/android-xx/ApiDemos
I've got an idea for an Android Application, however I am unsure if it would work. Essentially what I want to do is "intercept" all text messages sent from any SMS App and make modifications to them.
For example, say I write out the following SMS:
Hi {Name}, how are you today? Can you tell {Boss} I'll be 15 minutes late today.
The onSMSSend function in my application(assuming it is currently running in the background) would then be able to edit the content of the message(Eg. Replacing variables with ones defined in the application), and then send it on to the recipient.
Is Android able to provide this functionality?
No it is not. Android may be able to inform you after an SMS was send. But there is no way to intercept a message that should be sent and apply changes to it on a non rooted phone.
What you could do is to write a new messaging App that allows the user to type a message, choose a number and send the message. Now you have full control over the message that is send but building a replacement for the sms app is a fair amount of work.
Is there a way to send messages directly from application to application? I'm making an app that needs verification from another phone, but I only send the messages via SMS, so there is a big chance that a false message having the same format might end up being recognized by the application as a legit one.
I don't think it's possible. For functionality like this you would usually use server, and, maybe Google Cloud2Device to send Push messages.
If both phones are in close proximity to each other, you could make a bluetooth connection and transfer the data that way. It would work like that Bump app that transfers files when the phones are bumped together.
As a work around to the way you are doing it now, you could do a simple encryption of the messages so that they are not plain text and won't match a real text message. If you wanted to make it pretty, you could encode the data in a picture so it doesn't look like a garbage text to the end user.