I am trying to create a custom status bar notification in Android that has a button in addition to the text. The button can do a different thing than when you click the notification itself.
Is this possible at all? I'd also be ok putting an image of a button there instead. I know how to put an image, but not sure how to handle OnClick for an image embedded in RemoteViews. Your help is sincerely appreciated.
Thanks a lot in advance.
I don't think you can get a button on the status bar itself but you can certainly do it using a Custom Expanded View (see http://developer.android.com/guide/topics/ui/notifiers/notifications.html)
try use this way,the first is the view ID,
the second is a Pending intent..
RemoteViews.setOnClickPendingIntent(R.id.push_notifi_content, Pdit);
I have try it,but seems it just support in android4.0
I am working on this end as well. It is straightforward from HoneyComb onwards: look at the music app (it has a status bar control when playing). And you can implement yours with your_notification_remote_view_instance.setOnClickPendingIntent(R.id.a_button_in_notification, pending_intent_to_be_handled_by_a_service); while backing it with a service to handle the intent properly of course. While buttons can be embedded in earlier versions, they don't get focus or click when pressing.
Related
Is there a way to replace (or suppress and launch) with my own custom view or App?
Sure go full screen. If you want an example just create new activity and select "fullScreenActivity" then you can view the style and code to own the full screen. However, you can remove the timer delay and animation and just force it right away.
I feel obligated to mention though that building your own status bar sounds wildly out of place. Are you sure you didn't mean the Actionbar? Either way, that is how you accomplish removing the status bar if that really is what you want to do.
For another example of how to do it in XML or Manifest you can see styles here:
https://developer.android.com/training/system-ui/status.html
In my application, I want to provide the functionality similar to Next, Previous and Done button at the top of keyboard. It is somewhat similar to this
Please let me know how can I achieve this.
I do not want to exactly implement the next,previous and done options. But using this three button click, I want to make three separate web service calls and fetch the results. Like, Active,Inactive and All kind of filters.
The standard Android way would be to provide an input method action with imeOptions. With the standard keyboard this will change the bottom right virtual keyboard button to the specified action. There's little point in trying to mimic iOS input behavior with the buttons above.
Do you want to just put the layout above the keyboard,so as to stop next,previous,etc button when keyboard is displayed.
If so,you can try adding below code inside your activity in android manifest,
android:windowSoftInputMode="adjustResize"
If you are looking for something else,then please show your xml code of the same.
I have an AppWidget (part of my app). I want there to be no sound when the user clicks a button in the widget.
How do I do this?
CommonsWare answered it:
This is not a method on RemoteViews, and setSoundEffectsEnabled() is not a RemotableViewMethod, so the literal answer is incorrect. However, android:soundEffectsEnabled="false" in the layout file may work.
setting android:soundEffectsEnabled="false" in the xml layout file does indeed work!
As far as I know, you have to turn off notification sounds (pressing volume down, then selecting settings on it). The click sound is usually created by the OS (Samsung Android will have a click but google Nexus will not). The only other way I can think of is, if the widget is yours, create a custom button that overrides that particular functionality.
Add the following line of code to disable the click sound,
yourbutton.setSoundEffectsEnabled(false);
I do it like this:
RemoteViews views = new RemoteViews(..);
views.setOnClickPendingIntent(R.id.button1,pd);
noti.contentviews = views;
and then notify the notification.
I can see the button in the notification,
but the button can't be clicked.
When i click the button,the whole notification clicked!
How can i resolve this question?
I found everywhere for this,but nothing useful found.
someone said, some phones don't support the notification button,
but samsung galaxy s, the musicplayer's notification has button click event.
You cannot put interactive widgets, like a Button, in a Notification and get user input from them. These are for output display only.
We can made custom notification and put buttons into that and also can perform different functionality on that onClick function, recently I was stuck in the same problem but this link
Handling buttons inside android notifications
save my life.
You can also see my code here
Adding button action in custom notification
and it actually works on my HTC Sensation XE havent tried on other devices yet. So cheer and good luck
I want to create a custom OptionsMenu in my application. The default OptionsMenu display only three items in one row. Now i want to display five to six items having only icons. Also i want to change the background color of the OptionsMenu but not getting the appropriate way of doing this. If it is possible then please let me know about it.
Short answer
As an user it bothers me when the application changes my android's widgets. I wouldn't recommend changing that and android doesn't provide a way to do it.
Long answer
Even though Android doesn't provide a way to customize that you can always handle the key event and show a view from your own. Similar discussion in stackoverflow.