I have an app that recieves push messages from Google Cloud Messaging.
So when the app is not visible user recieves Notification. If app is visible user recieves Toast. But want to try more interesting solutions if they are exist.
So the question is what views in Android could be called from any Activity of the app like this happens when we use Toast?
Thanks in advance for your answers!
Ok, there is no legal way to do what I wanted. It's possible to invoke AlertDialog, but it will block the current activity. To not block the activity, we can still use Toasts, even custom, but without possibility to make it stay on the screen.
But the best solution is to do nothing, but leave notifications only, doesnt metter if app is visible or not.
Related
I have this Android application with an ongoing notification and there I have a copied text from the user's clipboard. So, what I'd like to do is: Whenever the user copies a new text (when he's NOT in my app), update this text on the notification at the Status Bar.
I've looked at the ClipboardManager.OnPrimaryClipChangedListener, so apparently it's possible to detect when it changes, but how can I do it when the user already exited my app?
Is it possible? Where should I implement this?
For now, I've called the mentioned listener on the onPause(), and onDestroy() methods, and also called set moveTaskToBack(true); when the user press the back button, so it doesn't close the activity, just minimize it.
It works for awhile, but after some time it eventually stops working (when the system eventually stops the activity). Is there a workaround?
Thanks for any help at all.
If someone else had the same issue, take a look at Service and BroadcastReceiver.
Solved my problem. Did exactly what I wanted to do.
i just want to know how can i detect if the user opens an app so an activity of mine launches as well.
For example, the user opens the sms app and right after a kind of lockscreen appears.
You can create a service which will run int the background and you can use this API to determine which activity is visible. That's how many app lock works.
As far as I understand the Android system, it is not possible unless you are making a custom firmware.
While pressing the power button we are able to see a alert dialog in any android device from any activity. Just like that i want to show a alert dialogue when my application receives a broadcast intent. How i can implement that function ?
Add this intent to your Activity Manifest tag.
In your Activity's onCreate(), Handle the intent you received:
If it matches your intent, show the dialog.
Else, do nothing.
As the previous person stated, you cannot have this functionality, since it is in the Android Framework code, unless you edit that code to expose it. An example of the functionality you are looking for (from Android code) resides in the PowerUI class, which extends SystemUI. In SystemUI, there is a Context(mContext) that sub-classes use to show Alerts on any screen. This is what you need. I had to recently do this for an app. I just mirrored what PowerUI did, and created another child of SystemUI. The PowerUI does this to let you know that your battery is low(from any activity/screen), among other things.
It's a bit of a bear, but that is what I believe you are talking about. Doesn't really help you much though, if you are releasing to the public. But, for a personal app...
I am new to Android and have a problem with the Notifications. I know that this topic has been taken up earlier as well but I just wanted to know if there is any other way to go about it.
Problem : In my application I want that the user is notified that he/she has entered in the radius of a particular location. I have the functionality working when the application is alive and in the foreground. I will however want that the user is also notified when the application is not working and not there in the foreground.
In the previous posts I have found out that this can be done by using something called as the C2DM. Altough I am not much aware of it but by using C2DM I would be introducing an extra network trip. My question is that the only way to go about it? Can't this functionality be done any other way round, something locally like something of a daemon thread of sorts?
Also if C2DM is only the way, and as my application is not in my foreground will the C2DM also inform once the user reaches the radius of a particular location?
Will like to thank you all in advance. Please do let me know if any one of you have faced a situation/problem/requirement similar to this before and also if you can highlight the way forward for this?
I have the functionality working when the application is alive and in the foreground. I will however want that the user is also notified when the application is not working and not there in the foreground.
Use addProximityAlert() on LocationManager, and then it will not matter whether your app is in the foreground or not.
I'm writing an android application which listens the phone calling events. What I want to do is, if there is a call incomes or outgoes, an activity shows with my customized info. I want to this screen keeps showing during the calling period. However, if a call is coming, the system UI which shows the contact always appears on top of my activity. I've found some apps already realized this function, but mine can't. :( Is there any way that I can achieve my goal? Any help will be appreciated.