android-appwidget

Appwidget size calculation

感情迁移 提交于 2019-11-27 09:33:18
问题 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

How to launch activity from android home screen widget

若如初见. 提交于 2019-11-27 06:56:26
问题 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

Android - how update widget often but only when it is visible?

◇◆丶佛笑我妖孽 提交于 2019-11-27 05:08:31
问题 I'm going to create widget which needs to update its content every minute (it shows time-related data). However, there is no need to update widget if it is currently invisible, which means: screen is turned off another app is running widget is placed on another (invisible) home screen tab What is the best way to update only visible widget every minute - without waking up device nor doing unnecessary computations? After widget becomes visible, small lag before update is acceptable. 回答1: To

onGetViewFactory only called once for multiple widgets

纵饮孤独 提交于 2019-11-27 03:17:57
问题 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

Android Widget Not Updating

若如初见. 提交于 2019-11-27 01:14:21
问题 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

How to observe contentprovider change? android

橙三吉。 提交于 2019-11-26 23:08:57
问题 I'v created a Contentprovide and implements it's update() method like this: @Override public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { final SQLiteDatabase db = mHelper.getWritableDatabase(); int count = db.update(InslideDB.FOLDER_TABLE, values, selection, selectionArgs); /* To notify the observer */ this.getContext().getContentResolver().notifyChange(URI, null); return count; } How can I get notified in my appwidget? Thanks! I'm trying this

Widget for turning on/off camera flashlight in android

烂漫一生 提交于 2019-11-26 17:58:23
问题 I am developing a widget for turning on/off camera led of phone. I have made a widget that can work like toggle button (on/off). Behavior is like follows : Sometimes the led light remains on when i enable the widget. But it doesnot turn on/off the camera led but it changes the icon. I am not able to figure out whats the actual problem. The same thing works fine in Activity (Torch Light Application). Can anyone please explain me how can i solve my problem ? Where i am going wrong ? You can

Removing AppWidgets programmatically

旧街凉风 提交于 2019-11-26 17:44:44
问题 I'm having the hardest time figuring out how to remove home screen AppWidget's programmatically (i.e. without the user actually dragging one into the trash). As an example, consider an app that can have multiple accounts, with any number of widgets for each account - once an account is removed, widget should be deleted as well. I've tried following an obscure example from http://www.netmite.com/android/mydroid/cupcake/frameworks/base/services/java/com/android/server/AppWidgetService.java, but

ACTION_BATTERY_CHANGED firing like crazy

半世苍凉 提交于 2019-11-26 16:27:53
问题 Okay, so I'm working on an AppWidget that checks the battery level and displays it on a TextView. My code looks like this: public class BattWidget extends AppWidgetProvider { private RemoteViews views = new RemoteViews("com.nickavv.cleanwidgets", R.layout.battlayout); @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int appWidgetIds[]) { final int N = appWidgetIds.length; context.getApplicationContext().registerReceiver(this,new IntentFilter(Intent.ACTION