I am trying to access the text on each button on a notification - and do further processing on the same.
I have the RemoteView object :
RemoteView rView = mStatusBarNotification.getNotification().contentView;
is it possible to get the text on each button using this RemoteView Object? If yes, how?
For example, in the following notification i need the text "Speaker" "End"
See Create custom notification, android or http://developer.android.com/guide/topics/ui/notifiers/notifications.html
Related
How can I retrieve Notification list of status bar programmatically on android?
I found some ways like NotificationListenerService, but I would be happy to know any methods or apis that I can retrieve every StatusBarNotification s in one method call.
public List<StatusBarNotification> getNotifications()
{
//...
}
EDIT
Thanks to comment I found some way. I'll post it later when I am finished, for further users.
I am using MPAndroidChart to draw some charts on my Android application and I would like to change the default message that appears when the data is not available.
I am using a CombinedChart and a BarChart and in none of them I am able to change the text when data is not available.
I know that there are few questions on Stackoverflow related with this theme. For example:
MPAndroidChart - Change message "No chart data available"
MPAndroidChart -Use multiple text instead of "No Chart Data available" depends on the data
but all of them make reference to one or more of these methods:
.setDescription("");
.setNoDataTextDescription("Custom message.");
.setNoDataTextDescription("Custom message");
.setNoDataText("Custom message");
Any of them worked for me.
My snippet of code in which I try to change the text is the following:
combinedChart.setDescription(null);
combinedChart.setNoDataText("No data");
combinedChart.setData(data);
combinedChart.animateXY(2500,2500);
How can I provide a different text message to the user when data is not available?
EDIT: I have added .invalidate method as #SudhakarRaju suggested but it also does not work. My actual code is:
combinedChart.setDescription(null);
combinedChart.setNoDataText("No data");
combinedChart.setNoDataTextDescription("No data");
combinedChart.setNoDataTextDescription("No data");
combinedChart.invalidate();
combinedChart.setData(data);
combinedChart.animateXY(2500,2500);
//I also tried to put combinedChart.invalidate(); here but it also does not work.
Thanks in advance!
The same way above you mentioned but you have to add one extra line. combinedChart.invalidate(); This will work.
This code allows you to style the chart if no data:
mChart.setNoDataText(getResources().getString(R.string.no_data_available));
mChart.setNoDataTextColor(BaseActivity.getAppColor(R.color.black));
// from: https://github.com/PhilJay/MPAndroidChart/issues/89
Paint p = mChart.getPaint(Chart.PAINT_INFO);
if (p != null) {
p.setTextSize(getResources().getInteger(R.integer.no_data_text_size));
}
Remove the combinedChart.setData(data) call.
For some reason, if you send an empty Data object that contains an empty data set, the "no data" text will not be displayed.
I had the same problem and I resolved it by simply not setting the data if it's empty, or using combinedChart.clear() for that matter.
I'm looking for a way to get the instructions from Maps Navigation.
Currently I think the only possible way is to read the notification data that is placed at the top by Maps Navigation. My reason for beleving that this is the only way comes from this post.
I tried getting the data with the OnNotificationPosted method, but i cant find directions data in the StatusBarNotification object...
Does anyone have a solution or better idea on how to achieve this
You can implement a NotificationListenerService in order to retrieve the content of google maps route direction. Unfortunately Maps is not using the common attributes within the StatusBarNotification. However maps uses RemoteViews to display content.
You can send this data via Broadcast to the activity and eventually add the content to an existing view:
RemoteViews remoteView = intent.getParcelableExtra(id);
if (remoteView != null) {
ViewGroup frame = (ViewGroup) findViewById(R.id.layout_navi);
frame.removeAllViews();
View newView = remoteView.apply(getApplicationContext(), frame);
newView.setBackgroundColor(Color.TRANSPARENT);
frame.addView(newView);
}
I am trying to do a chat application. In my activity I have a ListView and at bottom EditText with a Button "Send"
Like in chat after writing in EditText and press the Send Button the text will appear in ListView. Two users are there. If the last user is same then that text should add to the previous list.
How can i do that ?
here is my code below,
http://pastebin.com/hghj1fBJ
i don't want in this structure,
me: hi (after send button click)
me: h r u (after send button click)
i want in this structure,
its taking two list item but i want
me: hi (after send button click)
h r u (after send button click)
friend: fine
public void sendMessage(String message)
{
messageAdapter.add("me :"+message);
messageAdapter.notifyDataSetChanged();
}
}
Since you are trying to build chat kind of application, you should check transcript mode of listview too.
check here,
http://www.mubasheralam.com/tutorials/android/listview-transcript-mode
I don't see that you call notifyDataSetChanged() on your ArrayAdapter.
setAdpater().. method should be called after the new text is beeing added.. and the String[] array should be updated with new values..
or
refer this http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/List12.html
On an Android 2.3.3 I want to update my Notification.
Today, I create a new Notification object, and fill it with stuff. That makes the ticker text show again, which I don't want. I just want to update the number in the Notification (and sometimes the contentText) without making a new Notification, and without replacing the current "contentText".
So:
How do I just update the number, without replacing any text (whatever text is in the notification now should be left untouched)
How do I get info on what text/data is in the current Notification?
Use custom notification and then update like this:
progressNotification.contentView.setProgressBar(R.id.PGB_UPLOAD, 100, percentage, false);
progressNotification.contentView.setTextViewText(R.id.TXV_UPLOAD_PROGRESS, String.valueOf(percentage)+"%");
objNotificationManager.notify(1, progressNotification);
You need to post the notification again, just as you said. To suppress the ticker, set the tickerText field to null.