android react to new notifications - android

is it possible to react to a notification that did not come from my own program? I need some kind of receiver that reacts when i.e. k9 creates a notification or whatsapp or whatever. I don't necessarily need to read the contents of the notification. So far I've come across nothing on my search, maybe you can help. If I need root for the solution, I'd accept that if necessary.
thanks,
Catscrash

I know this has been sitting for a little bit, but I came across it in my searching, and I figured I would share what I found.
There is a way to do this, and rooting/modding is not required. I do not know what API level you are targeting, but you should look into Accessibility. It is geared towards assisting those with disabilities, but with the user's permission, it grants other apps access to things such as notifications. You can filter by the source package, get the contents, and so much more.
Here is a link to a page on Accessibility Services: http://developer.android.com/guide/topics/ui/accessibility/services.html
This is what I used to run a quick test to prove to myself that it did work. Make a quick project with this, create some notifications, and watch LogCat. This logs much more than just the notifications from the status bar, as you'll see: https://gist.github.com/qihnus/1909616

Related

How to detect if another application is open in Flutter?

[EDITED]
I want to create an application that discourages the usage of social media applications. Like if they open Instagram or something then the Flutter app will know.
How would I detect if another application (Such as Instagram or Twitter) is open when my Flutter app is opened?
If this is difficult to implement in Flutter, can anyone suggest some other languages or code for this functionality?
Thanks!!
It is possible at least on Android. I do not program for IOS so I can't say for sure. As #Gaurav pointed out, the solution will need to be custom-made and it probably won't be specific to Flutter. If you are willing to work outside Flutter than it is possible.
Once again, the following solutions are for Android devices:
Solution 1: Since you are targeting social media apps you can lookup the public intents of each app (i.e. Facebook, WhatsApp, etc...) find out the names of the intents they are broadcasting and add a broadcast receiver in your application. Many will say this is not a good idea because the app developer's themselves could change the intents and that you shouldn't listen for anything that hasn't been declared for public use. They are probably right, but this discussion is about how to detect the other apps launching and this method works.
Simply google how to add a broadcast receiver, a good example can be found here.
There are websites that contain databases for a lot of broadcast intents for popular Android applications, but if you have trouble finding the name of a particular one then I'd suggest using ADB to find it. For example, Facebook would be:
adb shell pm dump com.facebook.katana | grep ' filter' | cut -d ' ' -f 12
In some versions of Android broadcast intents do not work, however registering it in the application has worked pretty well for myself.
Once you have a listener setup properly, then you can detect the app when the user launches it and process it accordingly.
Solution 2: You could monitor the processes on the Android device via "Process" and/or "PackageManager" and see when one of the social media applications popup. This method is not very reliable because apps are on all the time and just because they're in the process list doesn't mean they are actively being used.
Solution 3: Once again, this is a very "hacky" solution, but you could listen to the logs on each device. Basically get the output of console logs, read the last 100 lines and see if the app is doing something. If so, then you may be able to determine if the app is active. The biggest problem with this solution (besides trying to read logs on all your user's devices) is that this is not an instant solution and may require special privileges depending on the device you're working on. You would also probably need to setup a service that actively listens and reads the logs, which might cause some significant battery usage.

Is it possible to intercept an incoming call via an APP (IOS and Android)

Hey does anyone know if it's possible to intercept incoming calls via an app for both IOS and Android (no jailbreak) then based on certain criteria the phone takes action?
Have already read a few posts saying it's not possible however they are quite old, anyone know of anything new?
Thanks!
The short answer:
On Android: You can do this, but this may require special treatment for different vendors and/or OS versions. It won't be simple to support all (or at least most) devices, but with a lot of manual trial and error, it can be done.
On iOS: It's not possible locally, as Apple sees it as an invasion to the user's privacy.
The (slightly) longer explanation:
What is possible, for both iOS and Android, but will probably require a lot more work and external support than you originally planned, is to divert the calls via a server. This way, when someone calls you, the call is "stolen" by the server (which the user has to manually allow when installing the app) and the call is received on your device as a VOIP call, allowing the app (on the server side) full control over the call (which ones are actually received on the device, what's played, how long, recording, etc). You can see this app for an example of how it works: https://yallo.com/.
I hope this helps. Good Luck.

Is it common practice to ask users whether they wish to receive push notifications?

I'm new to the Android platform. Apple requires every iOS app to ask for and confirm push notifications, but I have not noticed any apps that I've downloaded on my new Android phone prompting me if I want to receive push notifications. It just automatically registers me for them. Is this normal Android convention, to automatically register users for push notifications, assuming they can disable them later?
In my own Android application, should I be prompting users and asking if they want them before I register them? Obviously it would be the polite thing to do to ask permission before signing them up for push notifications, but if that's not common practice I see no reason to potentially lose some receivers of them.
Making decisions for the user is actually a strong Android guideline. Here is a list of the "Android Design Principles", written by Google. As you can see "Decide for me, but let me have the final say" fits the behavior that you've mentioned.
Some things to keep in mind when discussing Android notifications:
Users can disable your app's notifications in their OS settings. If they really don't want to hear from your app, they'll disable notification's there.
User context. You don't know what context the user is installing your app in. Users who are on a crowded train, relaxing on their day off, hanging out at a friend's place, or maybe waiting for a flight, all want different things out of your app at the time of installation. The guy on a crowded train is going to want your app to work immediately, with very minimal setup, while the guy relaxing at home may not mind a long setup process.
Your setup process can have a significant impact on your user retention. This Forbes article briefly discusses intrusive setup forums and their impact on app uninstalls.
At the end of the day however, it all depends on the needs of your audience. If you're targeting professionals, then they might be willing to put in some extra time up-front if they believe your app could help make their job easier. If you're targeting a casual gamer, you'll want them to get in and rolling as fast as possible. It's up to you to decide how best to serve your audience.
Here's a video from Google I/O 2013 that discusses the Android Design Principals in greater detail.
Hope I was able to provide some insight.
Sadly, it does not appear to be a very common practice. I've installed several Android applications that will randomly give me a notification in the middle of the night. I've recently made a new habit of disabling notifications for every new app that I install unless I really want notifications from it. I think your application would result in a much better user experience if you prompted them for notifications. You could also offer configurations for which notifications they wish to receive. If other apps were like this I might choose to receive some notifications instead of globally turning them off.

Sony SmartWatch 2 Control & Notification for the same app possible?

I was trying to port my existing app from SW 1 to SW 2 and stumbled upon the limitation that it is not allowed to have notifications and a control for the same app (even when setting LAUNCH_MODE to CONTROL).
As a workaround I tried to register 2 services, one for the notification and one for the control. As they share the same app package name, this didn't work and only the first that registered was available.
Is there a better workaround?
Or will this limitation be addressed in a future update? My app really depends on both, the notifications and the control.
A distant workaround may be to use only the Control, and build some sort of a notification mechanism as part of the Control. I did exactly that in my Log app: https://play.google.com/store/apps/details?id=eir.log
The notification mechanism is triggered by a different event, in the same BroadcastReceiver. Works wonderfully for me.
I believe this is indeed not possible today. One option for you would be to start up your control extension from a notification list item. So from where you read your notification you can enable a menu and then in that option start up your control. Have a look at the SMS app to get an idea.
Not possible and no workaround available. We have to wait for Sony to fix this issue though they haven't mentioned when they will address it.
We have posted a blog on Sony Developer World regarding this topic:
http://developer.sonymobile.com/2013/12/26/using-both-the-control-notification-apis-for-customised-uis-in-your-smartwatch-2-extension-code/

Can you send a message to clients who have just joined your access point?

I am wondering if there is a way to send a message to users that have entered your wifi's reach? I am not sure if this is possible or how it's called.
A hint of what to look for or some sample code (if this is possible at all) would be much appreciated!
The only thing that is possible as far as I know is to add software to your accesspoint to do a splash screen (or possibly a login page).
This would not completely solve your use-case, but like the various "free" wifi in bars you do need to log in to first, you need to open a browser first and perform an action, before you have a real connection.
You could just skip the authentication-part, and put your message on the splash screen.
A random example of what you can find on the internet is this: http://www.dd-wrt.com/wiki/index.php/NoCatSplash
I have no experience with it, but it seems to serve above mentioned purpose, and you can easily go from there.
I am aware that this is NOT an android specifi answer, but as far as I know it is not an android specific question: you want to send a message to people connection to your wireless.

Categories

Resources