android-appwidget

how to perform widget update by service after clicking a button?

送分小仙女□ 提交于 2019-12-10 17:43:29
问题 This is my Configure activity when I try to deploy the widget initially. public class WeatherAppWidgetConfigure extends PreferenceActivity{ private List<WeatherForecast> weatherData = new ArrayList<WeatherForecast>(); private String city_url; private String city_key; OnSharedPreferenceChangeListener listener; int mAppWidgetId; WeatherForecast wfObj; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set the result to CANCELED. This will cause

android AppWidget not adding to homescreen on Lollipop

冷暖自知 提交于 2019-12-10 17:17:16
问题 I developed an app that shows news feed on a home screen widget. Everything is OK on pre-Lollipop android devices as a result of the following scenario: A user enters their launchers' widget screen to choose/add a specific widget A user clicks on MyNewsWidget to add to their home screen A configuration activity is called so user can choose from different news sources A user clicks a "save" button inside the configuration activity, then the activity should finishes and MyNewsWidget should be

Extend LinearLayout for App Widget

蹲街弑〆低调 提交于 2019-12-10 11:55:56
问题 I extended the LinearLayout class to create my own custom layout. It works well when I put it on an Activity, but when I put in an appwidget I get: 02-11 13:16:36.906: W/AppWidgetHostView(6138): Error inflating AppWidget AppWidgetProviderInfo(provider=ComponentInfo{com/com.Provider}): android.view.InflateException: Binary XML file line #2: Error inflating class com.CustomLinaerLayout Is there a way to put a custom layout on an appwidget? Thanks. 回答1: taken from here http://developer.android

resolveUri failing on app private data file

南楼画角 提交于 2019-12-10 11:09:47
问题 I'm generating a bunch of image files when my app first runs, and then trying to use remoteViews.setImageViewUri() later to get these images into my ImageViews. However, when I run the app I'm seeing 01-03 15:05:11.252: W/ImageView(137): Unable to open content: file:///data/data/com.nickavv.cleanwidgets/files/batt_s_19.png 01-03 15:05:11.252: W/ImageView(137): java.io.FileNotFoundException: /data/data/com.nickavv.cleanwidgets/files/batt_s_19.png (Permission denied) Since the file was created

How can I get the correct DisplayMetrics from an AppWidget in Android?

社会主义新天地 提交于 2019-12-10 03:06:56
问题 I need to determine the screen density at runtime in an Android AppWidget. I've set up an HDPI emulator device (avd). If set up a regular executable project, and insert this code into the onCreate method: DisplayMetrics dm = getResources().getDisplayMetrics(); Log.d("MyTag", "screen density " + dm.densityDpi); This outputs "screen density 240" as expected. However, if I set up an AppWidget project, and insert this code into the onUpdate method: DisplayMetrics dm = context.getResources()

How to update App Widget with list view from an Activity

只谈情不闲聊 提交于 2019-12-09 14:29:10
问题 I know this has been asked for many times but I went through the documentation from top to bottom, read all answers here and none of them helped. To be honest, each answer says something different about how to aproach this. Now back to my question. I want to update the widget list view from some activity and I created WidgetProvider#sendUpdateBroadcastToAllWidgets() for this purpose which I call from the activity. It eventually calls the onUpdate() so the broadcast is received correctly. But

Android widget not responding to touches

左心房为你撑大大i 提交于 2019-12-09 07:35:25
I'm trying just some very simple code to get an Android widget going but with no luck. I've looked around everywhere and haven't found a good answer. All I want (for now) is to increment a counter when the widget is touched and display the current value. This is my AppWidgetProvider: public class WordWidget extends AppWidgetProvider { Integer touchCounter = 0; @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { //This is run when a new widget is added or when the update period expires. Log.v("wotd", "Updating " + appWidgetIds.length + "

android appwidget listview not updating

大城市里の小女人 提交于 2019-12-09 05:55:43
问题 I've written an AppWidget that displays some data in a ListView from a ContentProvider, but I have trouble having it update. When I first create the widget it gets populated correctly, but after the AlarmManager's PendingIntent arrives, no updates occurs on the ListView. Here's the code: Intent update = new Intent(context, MenuWidgetProvider.class); update.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE); update.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds); PendingIntent

App widget with listview

筅森魡賤 提交于 2019-12-08 07:18:54
问题 I have some problem. I'm working with Android 2.2 and now I want to create widget with ListView. But after a lot of time as I seeking answer, I was discovered that it's impossible for this version. But maybe anyone know how I can realise similar effect? How I can to realize the effect of scrolling in App Widget in Android 2.2? Thanks in advance. 回答1: I found solution for this question. I can use android-support library. 来源: https://stackoverflow.com/questions/8846743/app-widget-with-listview

How to update an Android widget every second … to draw a clock with a seconds hand?

时光总嘲笑我的痴心妄想 提交于 2019-12-08 00:52:04
问题 I have been reading much from various sources on ways to update a widget that is using ImageView Canvas and Draw method to display a clock with a seconds hand. It must be updated every second. What is the most efficient way to do this? Use a Service , the Alarm Manager, Handlers? It can be done, e.g., the Android app "Arc Clock Widget". Anyone with any ideas? Thanks, Tom 回答1: There are several solutions discussed on this page :) A Tutorial on Making an Analog Clock Widget for Android I have