Basically I'm trying to get the "notifications" present in the notification bar somewhere else, or something similar in effect.*
Mind the ": I'm not really interested in catching and possibly messing with the original notification, I just want to know that it is there. There seems to be more questions around this topic, but mostly the quality is "I WANT THIS" with an expected "YOU CAN'T" answer. Maybe you (we) can come up with another option?
Things I have come up with, but that seem problematic are:
1:
Catching all send notification's. I don't think you can extend/override/change the current notificationManager. People seem to think this is not needed for non-evil apps. I disagree. But nevertheless I don't know any method that can accomplish this. Another option would mean to ask the manager for the current 'live' notification, but there is no such method I believe. Also the conclusion of these threads:
Global intents that are fired for all Android notifications
Receive Android NotificationManager Notifications from Non-System Apps
Is it possible for an app to replace the NotificationManager? (google groups)
2: Catching Broadcasts. This seems more doable, although not everything has a broadcast available. Apart from that last point: This would mean I would have to find out what broadcasts are available, and act on each one hard-coded. How feasable would it be to let users add their own broadcasts? And how would they know if (and what) their favorite program sends out? (I mean: add their own the app should listen to, not add a broadcast itself obviously)
This might involve something like an activity that catches everything for a certain period of time, and then you make sure you let your program send a notification, hoping it also sends something like a broadcast? Once a broadcast is identified, you want to act on that, but I don't know if you can change your behavior this dynamically.
3: Something completely different that will let me send as many different types of information (user choosable in the end) to an 'outside' place.
* I'm trying to send all notifications to a secondary location (a watch in this case). I can make something for all sorts of different situations (SMS, phone, mail, twitter etc), but this means double bandwith and cpu (battery), and everytime I (or a user) wants to add another type of message, I need to code more.
But nevertheless I don't know any method that can accomplish this.
Correct, short of modifying firmware.
Another option would mean to ask the manager for the current 'live' notification, but there is no such method I believe
Also correct, short of modifying firmware.
And how would they know if (and what) their favorite program sends out?
They wouldn't.
You are certainly welcome to:
Define your own broadcast Intent structure for a broadcast saying "hey, if anyone out there has some sort of extended notification thingy, here's one!"
Create one or more end-user applications that consume such events (e.g., routing to your watch)
Document and evangelize your Intent structure, convincing developers to take advantage of it, either to broadcast such events or consume such broadcasts
Related
I want to try to make an Android alarm app that is impossible to stop. In other words, it keeps going for a predetermined amount of time, even if the user presses the power button, tries to reduce the volume, or anything else.
It does not seem feasible to me, but since I have very little Android experience, I'd like to know if something like that is theoretically able to be done. Thanks.
This question has been addressed on SO here: Override Power button just like Home button
.
There are several answers in the link that will give you options and get you 90% of the way there, but no answer will cover all devices/scenarios. The accepted answer in the link puts it best:
The Android system, as far as is documented, defines (a physical button press) as a
broadcast action. Following the publish-subscribe pattern of message
propagation, this message will notify all concerned parties of this
action. Because this message is sent by the system, because the
message stack is managed by the system, and because the message is
also received by the system, your code simply (cannot be) injected in the
right place to block the reception of this message.
I have a series of Android apps, and I need to coordinate their execution. On any given device, there can be any one of those apps installed, or any two of them installed, or any three of them, or any four, and so on. All of those apps can do one specific thing, and they all will try to do that thing from time to time. Now here's the problem: at any instant, at most one of those apps should be allowed to do that thing. If any one app is doing that thing, none of the other apps should be doing it; they should either wait for their turn, or simply pass. In other words, I need a global mutex or critical section mechanism on Android. In addition, I want to avoid NDK, if possible. What should I do?
You might have to give a bit more detail to get a more specific answer. But from what I understand it sounds like you could use BroadcastReceiver in each application that listens for an action to get broadcast and takes it as sign that it needs to either wait, or cancel it's action. Then inside each application whenever you are going to start your action you broadcast an intent with the action string something like `com.your.packagename.ACTION_STARTING_THE_THING. All of the other apps that are installed (if any) will receive this intent and can act upon it accordingly.
It's the first time I post here, and I am a non-native speaker. So please forgive me if there is any bad grammar.
I am working on a project that wants to detect this:
When an app A sends some data to another app B and app B behaves abnormally after receiving the data, the app I wrote should send an notification to users.
For example, app B's memory usage suddenly shoots up to, say, 50%.
However, after searching, I found a post that says it is impossible to detect/intercept explicit intent sent between apps.
Does that mean I have no way to tell whether two apps communicate with each other?
ps: I know that it is possible to detect implicit intents, but that's not what I want.
Thank you!
As you suggested, there is no way to tell whether two apps communicate with each other, so what you're asking simply isn't possible.
I've got a unique situation where I have to query the phone to determine which app will be handling incoming phone calls. I realize that in 95% of cases com.android.phone is doing this work, however, I can't only be right 95% of the time, I need to know 100% of the time what app it'll be (user could have installed a custom phone app afterall to handle calls).
Being familiar with intents, I figured I could simply ask PackageManager to identify all apps that could handle these actions: Intent.ACTION_ANSWER and or Intent.ACTION_CALL (the only two Intent actions relevant to phone calls), after all, this approach works for virtually all other phone functions I've tried.
Unfortunately, whenever one tries to query PackageManager, say either using .resolveActivity() or .queryIntentActivities(), the result is always 'null', even when default applications exist for these intents. To further compound my frustration, there's absolutely zero documentation on why these intent actions can't be utilized. The documentation reads as if I am doing everything exactly right to reach my objective.
So, the question is two-fold: is there any reasonable method whatsoever to determine the phone app (hopefully the default app) AND why the heck can't intent actions created for this exact purpose be utilized?
TL;DR There's two intent actions that relate to phone calls, except, you can't use these to query PackageManager to find the underlying apps that facilitate these intent actions. Why not?
I have an android app which needs to keep sending SMS. My problem is that whenever we send a message we get a pop up showing (your SMS charges and your curent talktime balance in phone). When i send many SMS these pop ups keep getting accumulated one over the other which is undesirable for me. I need a way out to either remove or somehow consume these pop ups.
Any ideas ??
a pop up? Do you mean a toast? or notifications accumulating below the status bar?
You'll have to pardon my seemingly simple question. In the US, I've had multiple Android phones on at least two carriers, and I don't get any such message in any form, but may be that's because I've always had unlimited texting so additional texts do not cost me anything.
I bet you're talking about notifications accumulating in the status bar. So if your carrier is doing that, take a look at the code in the "API Demos" > App > Notification > Status Bar
There in the callback attached to the "Clear Notification" button, you'll find the code you're looking for.
And if I could suggest something, I know that many notifications accumulating on top of each other can be super annoying, but if you can try to consolidate all those notifications into one notification at least with the running count (unless your user explicitly opts out from being notified). This way, you still communicate to the user the most important part of the information - how many texts in total his phone has been sending so far, without completely overwhelming him with many-many notifications about basically the same event happening over and over again.
For those who don't know, "API Demos" is a free application you can download from the Market. And there may be several to choose from, so just pick the one with five stars next to it, but "API Demos" is also the same sample code that comes with different SDKs when you download it with the SDK Manager, and you can access that code when you create a new Android Project with the New Android Project... wizard from within Eclipse and then select the radio button "Create Existing Project from Sample" (or something like that, I don't have Eclipse in front of me, so the wording may be slightly incorrect). And of course, if you don't use Eclipse, you can always find that sample code through the Sample code directory itself.
As a potentially more elegant alternative, or may be just in case your carrier is indeed crude enough to pop up an actual modal dialog every time a text is sent, it may be that your carrier is using a broadcast receiver to trigger those notifications or those dialogs, so if that's the case, and hopefully the carrier isn't using "100" as a priority for its receiver, it may be possible for you to register a receiver with "100", and then kill the broadcast before it propagates to the other receivers. But of course, that's assuming that your carrier designed it that way for you.