Android/iOS programming to trigger an action - android

Is there any possibility to trigger an action on Android?
Like if we send a message to an android phone, it should execute some instruction, like running an app or something.
Is it possible with Android? Or iOS?
Or can the event be anything like reception of an email or phone call from a specific number or anything that can be done remotely?
Something as shown in the link here. But I want to know how to program these triggers.
Can someone help me out, please?
I want to manipulate the network settings so that it can automatically switch on the Wi-Fi or data and send back some data. Is that possible?

Yes you can trigger an action on android.
For that, you need to use a broadcastreceiver (here is a good article about how to use it http://www.vogella.com/articles/AndroidBroadcastReceiver/article.html)
Here is a simple example of the source code in order to display a message to the user when a sms is received.
http://androidsourcecode.blogspot.ch/2010/10/receiving-sms-using-broadcastreceiver.html

Related

Android App Detect Other Activity

I've been trying to look up solution but I just can't seem to find one that suits my need. It could be that I'm not using the correct keyword, so I'm gonna try to explain it the best I can.
Simply saying, I'm building an Android application. The application need to detect some other activities on the phone and show some message.
For example:
User launch MyApplication.
User received some notification from another app. (a phone call, text message, email, whatever)
MyApplication shows a message via toast or dialog, saying that "you just received an notification from another app"
I'm not entirely sure what function I should be looking for here, any help is appreciated.
Thanks!
You will want to look at NotificationListenerService, this will let you receive calls from the system when new notifications are posted or removed, or their ranking changed.
Once you receive a callback from the NotificationListenerService, you will want to create a Toast.
Take a look at this tutorial should help you get started.
To detect when other apps ask the OS to display a Notification, you would need to implement a NotificationListenerService. The user would then not only need to install your app, but also go into Settings and specifically allow you to monitor notifications.

Are there things like an Android trigger

I have never developed something in Android before, but now my company has put me on a project which includes android.
My question is this: Is it possible to write an application that runs in the background and waits for triggers (if that is the correct word for it). For instance lets say I want my application to do something as soon as you open your emails or as soon as you get an email. Is there some API that I can use to interact with other applications such as Mail. The application does not have to have any GUI, it will literally just push some information notifications on the mail just received or opened.
I don't require a to technical answer, but rather just yes or no, and indeed yes, where can I get more info on it. Also if it is not possible, is there some workaround to achieve this. I have googled it, but most of the links are how to send an email from your application.
Thanks
EDIT: So it can even be triggered when a notification is received. Then I just want to look at the notification and determine if it is an email?
You could register BroadCastReceiver for the actions that you need to be caught

How to send data to another android device

I want that my app will send data (Equation) to another android device and when the other device will get that data he will make calculation with that data (equation).
any idea's how to send data ??
Thanks.
P.s: its similar to this preview question: Send an equation to another android user for solving auto
You can use GCM. it's the Android push notification.
The notifications will arrive to the device regardless if the app is in the background or forground.
About the user noticing it, it's up you. The push notification itself is not showing anything to the user. It enters a callback (OnReceive) and you as the developer decides what to do with it. you can show an alert at the status bar, Send a broadcast to a service, update the DB or in your case do something with an equation etc...
Are you considering Bluetooth as an option?
If so, this lib may help you https://github.com/buddles/AndBT

Receive specific SMS and elaborate it with an Android app?

sorry fo my complete ignorance developing an Android.
I'm asking about the feaseability of this pseudocode I would like to implement as native app; let imagine a task that:
when a specific SMS arrive (only those sent from a specific sender number)
possibly (multi-SMS in case of text bigger than 160 chars )
elaborate/format each received SMS:
. save text content on a local db
. print text on a bluetooth printer
. reply to sender with some sort of "ACK" SMS
BTW, what above could be sort of background task, and I would need on foreground a sort of user interface that visualizes received SMS and do some user actions (sending back SMS to sender)
Is all that possible on Android ? Any issue ?
I mean, above all: is possible to "catch" specific SMSs (by example those sent by a specific sender number), living unalterated the usual SMS workflow for ALL other SMSs ?
Sorry for my beginner question and Thanks for your patience
giorgio
www.giorgiorobino.com
Following this link to implement a BroadcastReceiver that will listen for incoming SMS.
Inside your onReceive from your BroadcastReceiver, handle your logic (print/save/..)
It is possible, yes. But not recommended. That being said the way to set this up is to catch the SMS intent, so your app would be started when an SMS is received. Otherwise it would not run at all (as long as you don't have any other interface open). For a code example on the message interception part, see this post. For the database part look up local storage on android phones. Look up on SMS messaging for the reply. Not sure how bluetooth printing would work as I've never done it, but if it's a standard protocol I'm sure there's either built in support or a library for it.

capture the Sms exactly before being sent

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.

Categories

Resources