remoteview

Glide: load image to push notifications

你。 提交于 2019-12-06 03:05:13
I am trying to load an image to a push notification using Glide but it says this: FATAL EXCEPTION: Thread-9730 Process: com.monkingme.monkingmeapp, PID: 24226 java.lang.IllegalArgumentException: You must call this method on the main thread at com.bumptech.glide.util.Util.assertMainThread(Util.java:135) And the code used: NotificationTarget notificationTarget = new NotificationTarget( context, rv, R.id.remoteview_notification_icon, notification, NOTIFICATION_ID); Glide.with(context.getApplicationContext()) .load(item.getString("cover_img")) .asBitmap() .placeholder(placeholder) .error

Adding TextViews to home screen widget programmatically

守給你的承諾、 提交于 2019-12-05 16:32:29
I want to programmatically add Text Views controls to my home screen widget. In the following example I populate Linearlayout with TextViews, but how should I use RemoteViews here? It only accepts xml resource layout as a parameter. public class MyWidget extends AppWidgetProvider { public void onUpdate(Context _context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { LinearLayout l = new LinearLayout(_context); for (int i = 0; i < 10; i++) { TextView t = new TextView(_context); t.setText("Hello"); l.addView(t); } } } All tutorials I saw explicitly populate RemoteViews object with

Is it safe to rely on the call to onDataSetChanged() after onCreated() in RemoteViewsFactory of an AppWidget

核能气质少年 提交于 2019-12-05 06:08:45
I developed my AppWidget according to the android doc, loading my cursor in onCreate() and reloading it in onDataSetChanged() , and everything worked fine, until I set some breakpoints in my RemoteViewsService.RemoteViewsFactory and surprisingly found that onDataSetChanged() is always called after the call to onCreate() , which made my cursor loaded twice when first created. I'm on Android 4.4.3. According to the Api doc , public abstract void onDataSetChanged () Added in API level 11 Called when notifyDataSetChanged() is triggered on the remote adapter. This allows a RemoteViewsFactory to

Retrieve text from a RemoteViews Object

无人久伴 提交于 2019-12-04 12:35:15
问题 I need to retrieve some text from a RemoteViews object. It is possible for me to get the LayoutId, but I have no idea how to retrieve text from a TextView that is in this RemoteView (namely a notification). Also the RemoteView only contains setters, but no getters, so I guess I have to use the LayoutId (somehow). Can you help me with that? Thanks! /edit: The reason why I am asking this, is because I have an AccessibilityService that retrieves the notification. Therefore this is the only way

Layout weight on dynamically added RemoteViews

只谈情不闲聊 提交于 2019-12-04 09:10:24
Within my widget, i'm using the following to dynamically add items (R.layout.widget_item) to a LinearLayout defined within my main widget layout: //-- Main widget layout RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_design); //-- Add to main layout RemoteViews newView = new RemoteViews(context.getPackageName(), R.layout.widget_item); views.addView(R.id.view_container, newView); My question is, how can I dynamically set the "android:layout_weight" attribute on the newView? See: http://developer.android.com/reference/android/widget/RemoteViews.html newView in your

AppWidget refresh Uri for RemoteViews

为君一笑 提交于 2019-12-04 04:59:27
问题 I have created an Appwidget that displays an image file (test.png) that is provided to it's RemoteViews via Uri. In onUpdate i run a service that changes the content of the file. I have also set an onClickListener for the image that will call onUpdate. -If I create an instance of the AppWidget it displays the most recently changed version of the Uri file. -If I click the widget, my service makes the approporaite changes to the file (which I can verify with a file explorer), but it does not

How to set custom ListAdapter to list view in appwidget?

强颜欢笑 提交于 2019-12-04 04:28:43
问题 I have a listView. I needed a custom view for each list item, so I've created a custom ListAdapter which gives the views, layout for which is given below. But how do I set this listAdapter to the ListView in the widget using RemoteViews ? <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@android:color

How to use Glide in remoteViews?

守給你的承諾、 提交于 2019-12-03 12:01:40
I'm using Glide for all loading images from server, but I'm having troubleshooting trying to set them in a correct way to notifications and RemoteControlClientCompat (that cool thing with lock screens). I am developing a music player, so every time that a song is changed the song cover from notifications has to change. I have this code and it works for the first time (althoug the image is load from url or from drawable), but not when it is called for second time. The image doesn't change! CustomNotification is invoked when a song is changed. And RegisterRemoteClient is invoked on start

Reliable way of retrieving StatusbarNotification details (title, notification text)

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 23:17:05
I'd like to get as much information out of a StatusBarNotification -object as possible. Right now, the only "reliable" information that can be accessed is the tickerText -property. I'm using the following code to get the notification's title and text via RemoteViews , but a lot of the time, the title and/or text will simply be null :-(: //Get the title and text String mTitle = ""; String mText = ""; try { RemoteViews remoteView = sbn.getNotification().contentView; LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); ViewGroup localView = (ViewGroup)

Android: update specific notification from multiple notifications which have remoteview

北城以北 提交于 2019-12-01 22:34:06
问题 I am creating application that contain notification which have play/pause icon , which. it works perfect when there have just only one notification which have just one notification id, it change play/pause icon through only one notificationid, but there have issue with multiple notification. When there have multiple notification, each notification have play/pause icon. when i click play/pause icon from one of the notification, than it only changing top notification icon from the stack of