Are there things like an Android trigger - android

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

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.

Android/iOS programming to trigger an action

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

Is it possible to fake an incoming SMS on Android?

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

Is there any way I can read the notifcations that appear in my android home screen Notifications tab using java code?

The android home page displays notifications from different applications.
I would like to read those notifications using my program.
I tried to find information on that in forums and in android help but I was not able to find any information.
My actual goal is to read the notifications and if the notification is about an email from a certain person then I want to perform something in my application.(I use touch down for my email)
Any help is appreciated.
Not possible due to security reasons.
If you want to respond to events then you should try listening to them directly with intents.
You need to create an AccessibilityService and set it to listen to TYPE_NOTIFICATION_STATE_CHANGED events. This way, each time any of the application packages specified while configuring the AccessibilityService generates a new notification, the onAccessibilityEvent callback of your service will be called with all the information about the notification.

Android: Is there an onSMSSend event?

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.

Categories

Resources