Updating a unique AppWidgetProvider from a Service

by theSmith » Sat, 02 Jan 2010 11:12:47 GMT


Sponsored Links
 Here is my issue, I want to be able to update a specific
AppWidgetProvider (home screen widget) from a custom service class.  I
have to build the remote view in the service because I'm also doing
some networking in there, which takes some time.

The problem is that I can't figure out how to update a specific widget
(individual widgets can have different update intervals, using the
alarm manager).

If I wanted to do it from the onUpdate of the AppWidgetProvider I
could just call appWidgetManager.updateAppWidget(appWidgetId,
remoteView);

Does anyone have any experience with this or any suggestions?

-theSmith

--



Updating a unique AppWidgetProvider from a Service

by theSmith » Mon, 04 Jan 2010 00:17:57 GMT


 To follow up on my own question, heres how I did it.

I went from a service to an IntentService and in the onHandleIntent
(Intent intent) I handle the update requests.

To get the individual id's I put them as an extra in the intent in the
onRecieve() method in the widget, then fire them off to the
IntentService with context.startService(i).  Everything is working
perfectly now.

-theSmith




--


Sponsored Links


Updating a unique AppWidgetProvider from a Service

by Lyndon » Thu, 14 Jan 2010 00:54:22 GMT


 Hi

I have the same problem so thanks very much for the post...

Could you explain how the onHandleIntent method works please.

I have the appWidgetId in the service so I just need the way to update
that specific widget.

Any help would be very much appreciated.

Regards

Lyndon




> - Show quoted text -



Updating a unique AppWidgetProvider from a Service

by theSmith » Fri, 15 Jan 2010 06:58:20 GMT


 No problem, heres how I did it.

AppWidgetManager manager = AppWidgetManager.getInstance(this);
RemoteViews views = new RemoteViews(context.getPackageName(),
R.layout.widgetlayout);
views.setTextViewText(R.id.TextView_Body, "hello world");
appWidgetManager.updateAppWidget(appWidgetId, views);

onHandleIntent is called every time you use context.startService
(intent);  Just make sure to use that intent to send the appWidgetId
you need updated.  If the IntentService is not already running then
its onCreate() is called, other wise the intent is put into a FIFO
queue.  the onHandleIntent method runs on a seperate thread than the
rest of the app, even the IntentService's onCreate().  This allows you
to do time consuming processes like networking without android giving
the user a ANR dialog.

If you want to probe my brain some more feel free to ask.

-chris








> > - Show quoted text -



Other Threads

1. Why "MediaPlayer" Couldn't open file on client side, trying server side?

I use the mediaplayer to create an app and try to play rtsp on the
device .
I don't know why this could happen.I haven't modify the source code.So
I can not understand what  "couldn't open file on client side, trying
server side" meaning is.

the log.
I/ActivityManager( 1102): Starting activity: Intent
{ act=android.intent.action.VIEW dat=rtsp://125.76.233.38/h264.3gp
typ=video/* cmp=com.android.Test/.StreamTest.MovieViewTest }
I/ActivityManager( 1102): Starting activity: Intent
{ act=android.intent.action.VIEW dat=rtsp://125.76.233.38/h264.3gp
typ=video/* cmp=com.android.Test/.StreamTest.MovieViewTest }
I/WindowManager( 1102): Setting rotation to 1, animFlags=0
I/WindowManager( 1102): Setting rotation to 1, animFlags=0
I/WindowManager( 1102): Config changed: { scale=1.0 imsi=0/0 loc=en_US
touch=3 keys=1/1/2 nav=1 orien=2 layout=3}
I/WindowManager( 1102): Config changed: { scale=1.0 imsi=0/0 loc=en_US
touch=3 keys=1/1/2 nav=1 orien=2 layout=3}
W/WindowManager( 1102): performLayoutAndPlaceSurfacesLocked called
while in layout
W/WindowManager( 1102): performLayoutAndPlaceSurfacesLocked called
while in layout
W/WindowManager( 1102): performLayoutAndPlaceSurfacesLocked called
while in layout
W/WindowManager( 1102): performLayoutAndPlaceSurfacesLocked called
while in layout
D/StatusBar( 1102): updateResources
D/StatusBar( 1102): updateResources
V/VideoView( 1308): reset duration to -1 in openVideo
V/VideoView( 1308): reset duration to -1 in openVideo
D/MediaPlayer( 1308): Couldn't open file on client side, trying server
side
D/MediaPlayer( 1308): Couldn't open file on client side, trying server
side
I/ActivityManager( 1102): Displayed activity
com.android.Test/.StreamTest.MovieViewTest: 834 ms (total 834 ms)
I/ActivityManager( 1102): Displayed activity
com.android.Test/.StreamTest.MovieViewTest: 834 ms (total 834 ms)
W/BackupManagerService( 1102): dataChanged but no participant
pkg='com.android.providers.settings'
W/BackupManagerService( 1102): dataChanged but no participant
pkg='com.android.providers.settings'
W/QCvdec  ( 1061): get_parameter: unknown param 0ff7a347
W/QCvdec  ( 1061): get_parameter: unknown param 0ff7a347
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
E/MediaPlayer( 1308): stop called in state 4
E/MediaPlayer( 1308): stop called in state 4
E/MediaPlayer( 1308): error (-38, 0)
E/MediaPlayer( 1308): error (-38, 0)
--~--~---------~--~----~------------~-------~--~----~

2. Why "MediaPlayer" couldn't open file on client side, trying server side?

I use the mediaplayer to create an app and try to play rtsp in the
device .
I don't know why this could happen.I haven't modify the code in the
source code.So I can understand why "couldn't open file on client
side, trying server side"

the log.
I/ActivityManager( 1102): Starting activity: Intent
{ act=android.intent.action.VIEW dat=rtsp://125.76.233.38/h264.3gp
typ=video/* cmp=com.android.Test/.StreamTest.MovieViewTest }
I/ActivityManager( 1102): Starting activity: Intent
{ act=android.intent.action.VIEW dat=rtsp://125.76.233.38/h264.3gp
typ=video/* cmp=com.android.Test/.StreamTest.MovieViewTest }
I/WindowManager( 1102): Setting rotation to 1, animFlags=0
I/WindowManager( 1102): Setting rotation to 1, animFlags=0
I/WindowManager( 1102): Config changed: { scale=1.0 imsi=0/0 loc=en_US
touch=3 keys=1/1/2 nav=1 orien=2 layout=3}
I/WindowManager( 1102): Config changed: { scale=1.0 imsi=0/0 loc=en_US
touch=3 keys=1/1/2 nav=1 orien=2 layout=3}
W/WindowManager( 1102): performLayoutAndPlaceSurfacesLocked called
while in layout
W/WindowManager( 1102): performLayoutAndPlaceSurfacesLocked called
while in layout
W/WindowManager( 1102): performLayoutAndPlaceSurfacesLocked called
while in layout
W/WindowManager( 1102): performLayoutAndPlaceSurfacesLocked called
while in layout
D/StatusBar( 1102): updateResources
D/StatusBar( 1102): updateResources
V/VideoView( 1308): reset duration to -1 in openVideo
V/VideoView( 1308): reset duration to -1 in openVideo
D/MediaPlayer( 1308): Couldn't open file on client side, trying server
side
D/MediaPlayer( 1308): Couldn't open file on client side, trying server
side
I/ActivityManager( 1102): Displayed activity
com.android.Test/.StreamTest.MovieViewTest: 834 ms (total 834 ms)
I/ActivityManager( 1102): Displayed activity
com.android.Test/.StreamTest.MovieViewTest: 834 ms (total 834 ms)
W/BackupManagerService( 1102): dataChanged but no participant
pkg='com.android.providers.settings'
W/BackupManagerService( 1102): dataChanged but no participant
pkg='com.android.providers.settings'
W/QCvdec  ( 1061): get_parameter: unknown param 0ff7a347
W/QCvdec  ( 1061): get_parameter: unknown param 0ff7a347
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
I/MediaPlayerBuffering( 1308): Update buffering 0%
E/MediaPlayer( 1308): stop called in state 4
E/MediaPlayer( 1308): stop called in state 4
E/MediaPlayer( 1308): error (-38, 0)
E/MediaPlayer( 1308): error (-38, 0)

--~--~---------~--~----~------------~-------~--~----~

3. Margins acting wierd

4. AndroidManifest compile time checks

5. request data from mobile youtube

6. How to display an arraylist

7. Porting on beagle_Error