5 |
|
|
6 |
import android.appwidget.AppWidgetManager; |
import android.appwidget.AppWidgetManager; |
7 |
import android.appwidget.AppWidgetProvider; |
import android.appwidget.AppWidgetProvider; |
8 |
|
import android.appwidget.AppWidgetProviderInfo; |
9 |
import android.content.Context; |
import android.content.Context; |
10 |
import android.graphics.Bitmap; |
import android.graphics.Bitmap; |
11 |
import android.graphics.BitmapFactory; |
import android.graphics.BitmapFactory; |
21 |
|
|
22 |
final int N = appWidgetIds.length; // |
final int N = appWidgetIds.length; // |
23 |
|
|
24 |
Log.e("onUpdate", "onUpdate"); |
Log.e("onUpdate", "onUpdate:" + N); |
25 |
|
|
26 |
|
|
27 |
try { |
try { |
33 |
|
|
34 |
URLConnection conn = imgUrl.openConnection(); |
URLConnection conn = imgUrl.openConnection(); |
35 |
Bitmap image = BitmapFactory.decodeStream( conn.getInputStream() ); |
Bitmap image = BitmapFactory.decodeStream( conn.getInputStream() ); |
36 |
|
|
37 |
|
|
38 |
// Perform this loop procedure for each App Widget that belongs to this provider |
// Perform this loop procedure for each App Widget that belongs to this provider |
39 |
for (int i=0; i<N; i++) { |
for (int i=0; i<N; i++) { |
40 |
int appWidgetId = appWidgetIds[i]; |
int appWidgetId = appWidgetIds[i]; |
41 |
|
|
42 |
|
|
|
|
|
43 |
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.side9widget); |
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.side9widget); |
44 |
|
|
45 |
|
|
46 |
views.setImageViewBitmap(R.id.side9picture, image); |
views.setImageViewBitmap(R.id.side9picture, image); |
47 |
|
|
48 |
|
|
49 |
// Tell the AppWidgetManager to perform an update on the current App Widget |
// Tell the AppWidgetManager to perform an update on the current App Widget |
50 |
appWidgetManager.updateAppWidget(appWidgetId, views); |
appWidgetManager.updateAppWidget(appWidgetId, views); |
51 |
|
|
52 |
|
|
53 |
} |
} |
54 |
} catch (Exception e) { |
} catch (Exception e) { |