I am writing an application in Vaadin that searches for results. A form is used to specify the criteria and a table is used to represent the results.
I also want to show the amount of results found in a Window.Notification of Vaadin.
My problem is that I want the notification to stay there until the user clicks on it so it does not disappear after a few seconds.
If you just enter a large delay time, then if you don't click on these notifications and do several searches, all result notifications will come over each other. So if you then click on them to remove them, you will see the amount of results from your previous search.
This is what I want to avoid.
Notifications are added to the Window and as far as I can see, you can't get a reference to them to update them. So you can't change the current notification if there is already one present. After it is painted it is removed from the LinkedList<Notification> notifications of com.vaadin.ui.Window
One of the things I was looking at is how Vaadin closes the notification after you click on it so that maybe I can do the same before each search so that the previous notification is removed and the new search adds a new notification.
But so far I am unable to find how it is done.
A notification in html is shown as a div. So maybe there is a javascript I could call in Vaadin to remove that div?
Does anyone know how the timer works for closing the notification after the defined delay? Will this call a javascript that I could also call?
If the delay on the notification is -1, it has to be clicked on by the user. Unless the notification is of type TYPE_ERROR_MESSAGE, you have to create a notification object yourself:
Notification message = new Notification("Message", Notification.TYPE_HUMANIZED_MESSAGE);
message.setDelayMsec(-1);
getWindow().showNotification(message);
There is no mechanism in Vaadin to listen for hide events of notifications. You could create your own widget derived from VNotification to transmit this condition back to the server.
Related
I'm trying to find out what happens when a user pushes the media button of headset. I know the phone recognizes holding the button, but when I test it myself and hold the button broadcast will send a ACTION_MEDIA_BUTTON. When I push the button down and release it, I get two broadcasts (one for ACTION_DOWN and one for ACTION_UP). But when I hold it doesn't send anything.
This is how most buttons work for anything. Almost no hardware will tell you when something is being pushed down, just when a change is made.
If you want to know how long a button is held down for, you want to start recording the time using something like System.currentTimeMillis when you receive an ACTION_DOWN message and when you receive an ACTION_UP you can record the end time and then calculate the difference.
I am developing an App that has a lock screen widget where it has a play, pause, prev and next. When I connect my phone to an Android wear, it automatically shows this buttons and it works fine. I would like to add a "Like" button that would automatically be shown on the lock screen and the android wear. I know that I can create a Notification and add action for the like. But I want to know if is it possible to achieve that using only RemoteControlClient?
Have you tried using rating with the flag FLAG_KEY_MEDIA_RATING ? It seems that it's the only way to maintain generic methods and avoid having to set custom code on the wear side (or through notifications).
This flag can be set with setTransportControlFlags
Flag indicating a RemoteControlClient supports ratings. This flag must
be set in order for components that display the RemoteControlClient
information, to display ratings information, and, if ratings are
declared editable (by calling addEditableKey(int) with the
RATING_KEY_BY_USER key), it will enable the user to rate the media,
with values being received through the interface set with
setMetadataUpdateListener(OnMetadataUpdateListener).
Unfortunately, few or not example exists on the web. I discovered only one (unanswered) question relative to this on SO :
Android 4.4 KitKat Rating API
i want to develop an android application to locate a mobile no.Obviously it cannot be done without user approval.
Basically i need the GPS coordinates of the other user.So my idea is to, after selecting a contact from the list,when i click on locate Button a automatic message/notifaction is sent to the other user asking for his/her permission to Allow/Deny.Once the user clicks on the allow button an automatic msg will be sent to the locator giving the longitudes,latitudes of the mobile which i can locate using GPS
If I understood you well, on the receiving end, a Service will be monitoring for Events (on Bluetooth or Wifi) and should popup a dialog requiring user to accept or deny a transaction.
You can quite easily make an Activity that polls for Event (or better, make a bounded background Service Message your Activity when a new Event has been detected) and display a popup AlertDialog. If you design it this way you will need your Activity to be active and running (i.e. displayed).
If you need your application to get user attention even when your application is not displayed, you will not be able to do so: you can not (nor should) directly start an Activity from within a Service. You will have to use Notifications and/or a Toast message to unintrusively notify your user that something requires his/her attention. Notifications appear in the status bar and can be used to launch your Accept/Deny Activity.
I have this app that originally has you take a picture, shows you a progress bar, and uploads it to a website.
What I want to add is something so that before the progress bar shows, an Intent starts an activity that loads a layout with a dropdown menu that allows you to choose a descriptor for the picture. Following this, once you hit the 'OK' button on this new layout, the program should return back to where it had left off and display the progress bar.
Does anyone have any ideas on how to achieve this?
It seems that all I really want is some way to tell the program to stall for a while to call an intent, and when the user hits 'OK', the code may resume.
You should be using OnActivityResult().. More information on the link below http://developer.android.com/reference/android/app/Activity.html#startActivityForResult(android.content.Intent, int)
I have an app which uses the ACTION_MEDIA_BUTTON intent with a BroadcastReceiver to control a music player. The user pushes a button on external hardware and it controls the in-app music player. The user can also HOLD DOWN the button and change the volume.
I recently downloaded another app which uses the headset button, and it takes over the media button intent from my app! So when this other app is open and I press the button, the other app will start running, but my app will think that the button is still pressed down so it will cycle the volume.
To summarize,
my app is open, supposed to be sole listener of media button intents
other app gets opened, it also wants to be sole listener of media button intents
button gets pressed with both apps open, control goes to other app
my app thinks the button is being held down, as it lost control as the button was pressed in down mode (I think). It then launches functions I don't want launched because it thinks the user has held down the button.
Is there any way I could make sure that while my app is open it's the sole receiver of this media button intent? Could I at least check to see if another app has taken over, so I can prevent unexpected behaviour?
Thank you for any help, I've never had apps not play nicely before!
You can alter your BroadcastReceiver's priority (make it something large, like 10000): it should then get the Intent first, and then you can pass it on to the other app.
I have a similiar issue. I believe, outside of the 'arms race' over the priorites mentioned, the only real solution is to close the other application. If you are releasing this application to other users, you could possibly give them a message telling them to close other media player apps and services.
In your manifest you can set the intent priority to the max value of an integer which is: 2147483647.
You should not however set your IntentFilter priority over 1000 as it tells you in the API docs. You can set the IntentFilter priority like so:
myIntentFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
I assume you should subtract one from the SYSTEM_HIGH_PRIORITY constant as the docs say the value must be less than SYSTEM_HIGH_PRIORITY.
Quote from docs about IntentFilter.setPriority(int):
Applications must use a value that is larger than SYSTEM_LOW_PRIORITY and smaller than SYSTEM_HIGH_PRIORITY.