android-appwidget

ListView in widget adds randomly items on scrolling and resizing (nested remoteviews)

♀尐吖头ヾ 提交于 2019-11-29 03:36:42
Update: I created a repository with less code to make it a bit easier to understand. I'm trying to create a widget. I made it like described here: https://stackoverflow.com/a/6093753/2180161 It works partially, but I have a really strange bug. I made a screencast , so it's easier to understand what I mean: http://c.maysi.de/c6H9 Screenshot : As you can see there are some items which were added randomly. ( RemoteViews which were added to another RemoteViews object) The same happens when I resize the widget. The things I printed out in the log are like expected. there is no wrong data. Also

Why is my android alarm manager firing instantly?

£可爱£侵袭症+ 提交于 2019-11-29 01:36:56
I am following sample code for sending an update notification every 10'seconds. The code follows and it is in an UpdateService for an AppWidgetProvider . If I put a Thread.sleep(10*1000); I can see the expected behavior of my servicing loop. I obviously have something fundamentally wrong that is triggering immediately. It is supposed to be a PendingIntent of an alarm that will broadcast update to my listener. long nextUpdate = 10*1000; Log.d(TAG, "Requesting next update in " + nextUpdate + " msec." ); Intent updateIntent = new Intent(ACTION_UPDATE_ALL); updateIntent.setClass(this,

Force Android widget to update

北慕城南 提交于 2019-11-29 01:34:19
问题 I respond to a button press on my appwidget in the onreceive method. When the button I pressed, I want to force the widget to call the onupdate method. How do I accomplish this? Thanks in advance! 回答1: Widget can't actually respond to clicks because it's not a separate process running. But it can start service to process your command: public class TestWidget extends AppWidgetProvider { public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { final int N =

How to disable Widget updatePeriodMillis?

半腔热情 提交于 2019-11-29 01:17:47
I'm trying to figure out how I can disable the update period on my widgets? I don't need this particular feature. I'm just fine with the widget calling onUpdate when added that's it... Just don't include it in your xml and it won't autoupdate, or set it to 0. 来源: https://stackoverflow.com/questions/5641134/how-to-disable-widget-updateperiodmillis

How to create an app widget with a configuration activity, and update it for the first time?

China☆狼群 提交于 2019-11-28 16:54:08
This is driving me crazy. I don't know how to update the app widget from the configuration activity, even with the recommended practises. Why the update method is not called on the app widget creation is beyond my understanding. What I'd like: an app widget containing a collection (with a listview) of items. But the user needs to select something, so I need a configuration activity. The configuration activity is a ListActivity : @TargetApi(Build.VERSION_CODES.HONEYCOMB) public class ChecksWidgetConfigureActivity extends SherlockListActivity { private List<Long> mRowIDs; int mAppWidgetId =

Appwidget size calculation

ⅰ亾dé卋堺 提交于 2019-11-28 16:07:28
It might be me, but when I calculate minimum app widget sizes according to the formula given on the android page I don't get the right widget widths; The formula is as follows : width(n) = (70 x n) - 30 When I want to have a 5x1 widget, the correct width would be (5 * 70) - 30 = 320dp. However when testing this on a motorola Xoom it resolves to being a 4x1 widget. I've tested different values and 400dp seems good for 5x1 on the motorola xoom with Honeycomb, but then I'd test it on a regular Galaxy Tab with Gingerbread and then it resolves to a 6x1 (like one would expect). So two questions here

How to launch activity from android home screen widget

百般思念 提交于 2019-11-28 12:18:36
I am desperately trying to get my head wrapped around how to implement home screen widgets. Right now, I (finally) was able to get a button on my widget respond to a button press setting up an intent filter in the manifest. However, I cannot for the life of me figure out how to launch an activity when the button is pressed. Basically, here's the code i have: @Override public void onReceive(Context context, Intent intent) { super.onReceive(context, intent); if(intent.getAction().equals("com.bic.search.searchWidget.CLICK")) { Toast.makeText(context, "It works!!", Toast.LENGTH_SHORT).show(); } }

onGetViewFactory only called once for multiple widgets

╄→尐↘猪︶ㄣ 提交于 2019-11-28 09:55:29
I have an appwidget which uses ListView . I have created a class that extends RemoteViewsService : public class AppWidgetService extends RemoteViewsService { @Override public RemoteViewsFactory onGetViewFactory(Intent intent) { return (new AppWidgetListFactory(this.getApplicationContext(), intent)); } } In my AppWidgetProvider , I call the following method for each instance of the widget (for each appWidgetId ): private static void fillInList(RemoteViews widget, Context context, int appWidgetId) { Intent intent = new Intent(context, AppWidgetService.class); intent.putExtra(AppWidgetManager

onDeleted method not firing up when appwidget is deleted

为君一笑 提交于 2019-11-28 09:24:02
问题 The onDeleted method is not firing when an appwidget is deleted from the home screen. What could be the problem? 回答1: This seems to be a somewhat common problem with Android widgets. If you are subclassing AppWidgetProvider, onDelete() is liable not to get called. In order to work around this, you can instead implement the onReceive() method and explicitly look for APPWIDGET_DELETED. References: - https://groups.google.com/forum/?fromgroups=#!topic/android-developers/Nl0e06rDCRY - http://blog

Android Widget Not Updating

主宰稳场 提交于 2019-11-28 06:13:10
I am trying to implement a simple widget for display on the home screen. The problem I am experiencing is that onUpdate is only being called once when I install the widget. The configuration is below. Note: I will not leave update period at 20 secs as I know that would kill battery (just testing). Configuration: <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" android:minWidth="294dp" android:minHeight="72dp" android:updatePeriodMillis="20000" android:initialLayout="@layout/my_custom_app_widget">` </appwidget-provider>` Manifest Excerpt: <receiver android:name=