Widget update with Context.sendBroadcast()

by Carl » Wed, 04 Nov 2009 17:53:07 GMT


Sponsored Links
 Hello all,


I would like to update my AppWidget only, without interfering with the
other widgets in the system.
I created the following code, but I am not sure it other widgets will
also update, since I am using Context.sendBroadcast().

Intent myWidgetUpdate= new Intent
("android.appwidget.action.APPWIDGET_UPDATE");
myWidgetUpdate.setClassName("com.package.name",
"com.package.name.mywidget");
sendBroadcast(myWidgetUpdate);

In the reference it is written:

sendBroadcast(Intent intent, String receiverPermission)
Broadcast the given intent to all interested BroadcastReceivers...

Does this means that even if I specify the exact class to send the
intent to, other unrelated widgets will also be udpated?

Thank you.

Carl

--



Widget update with Context.sendBroadcast()

by Justin Anderson » Thu, 05 Nov 2009 00:35:12 GMT


 I believe that "interested BroadcastReceivers" means the ones that match the
intent.

Given your sample code it seems to me that only your widget will be updated.

Thanks,
Justin

----------------------------------------------------------------------
There are only 10 types of people in the world...
Those who know binary and those who don't.
----------------------------------------------------------------------





>


Sponsored Links


Widget update with Context.sendBroadcast()

by Mark Murphy » Fri, 06 Nov 2009 06:47:08 GMT


 


Why not just:

-- bind to the IntentService that is supporting your widget and call a
method on there to update to widget? Or

-- create your own Intent that your AppWidgetProvider listens to in
addition to the official one, and broadcast that custom Intent?

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

_Android Programming Tutorials_ Version 1.0 Available!

--



Other Threads

1. How to delete file when file is created by another app

Hi,

I have this problem. Two apps: app_a and service_s. Service_S creates
file in /tmp. After create this file, service_s uses
FileUtils.setPermission to change file mode to 666. Then app_a tries
to delete this file. But I always failed when deleting. It seems the
files are private. One application cannot delete files which another
application creates.

Is there any way to delete this file?

Thanks a lot.

Regards,
Jiyu
--~--~---------~--~----~------------~-------~--~----~

2. Java heap outofmemory during dex

hi all, I've meeting a problem here:
When I use ant to package my program, in the dex step, it crash like
below:

dex:
     [echo] Converting compiled files and external libraries into
release/classes.dex...
    [apply] UNEXPECTED TOP-LEVEL ERROR:
    [apply] java.lang.OutOfMemoryError: Java heap space
    [apply]     at java.util.Arrays.copyOf(Unknown Source)
    [apply]     at java.util.Arrays.copyOf(Unknown Source)
    [apply]     at java.util.ArrayList.ensureCapacity(Unknown Source)
    [apply]     at java.util.ArrayList.add(Unknown Source)
    [apply]     at com.android.dx.ssa.SCCP.addUsersToWorklist(SCCP.java:
106)
    [apply]     at com.android.dx.ssa.SCCP.simulatePhi(SCCP.java:188)
    [apply]     at com.android.dx.ssa.SCCP.simulateBlock(SCCP.java:199)
    [apply]     at com.android.dx.ssa.SCCP.run(SCCP.java:402)
    [apply]     at com.android.dx.ssa.SCCP.process(SCCP.java:84)
    [apply]     at com.android.dx.ssa.Optimizer.runSsaFormSteps
(Optimizer.java:161)
    [apply]     at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:
101)
    [apply]     at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:
74)
    [apply]     at com.android.dx.dex.cf.CfTranslator.processMethods
(CfTranslator.java:269)
    [apply]     at com.android.dx.dex.cf.CfTranslator.translate0
(CfTranslator.java:131)
    [apply]     at com.android.dx.dex.cf.CfTranslator.translate
(CfTranslator.java:85)
    [apply]     at com.android.dx.command.dexer.Main.processClass
(Main.java:297)
    [apply]     at com.android.dx.command.dexer.Main.processFileBytes
(Main.java:276)
    [apply]     at com.android.dx.command.dexer.Main.access$100(Main.java:
56)
    [apply]     at com.android.dx.command.dexer.Main$1.processFileBytes
(Main.java:228)
    [apply]     at com.android.dx.cf.direct.ClassPathOpener.processOne
(ClassPathOpener.java:134)
    [apply]     at
com.android.dx.cf.direct.ClassPathOpener.processDirectory
(ClassPathOpener.java:190)
    [apply]     at com.android.dx.cf.direct.ClassPathOpener.processOne
(ClassPathOpener.java:122)
    [apply]     at
com.android.dx.cf.direct.ClassPathOpener.processDirectory
(ClassPathOpener.java:190)
    [apply]     at com.android.dx.cf.direct.ClassPathOpener.processOne
(ClassPathOpener.java:122)
    [apply]     at
com.android.dx.cf.direct.ClassPathOpener.processDirectory
(ClassPathOpener.java:190)
    [apply]     at com.android.dx.cf.direct.ClassPathOpener.processOne
(ClassPathOpener.java:122)
    [apply]     at
com.android.dx.cf.direct.ClassPathOpener.processDirectory
(ClassPathOpener.java:190)
    [apply]     at com.android.dx.cf.direct.ClassPathOpener.processOne
(ClassPathOpener.java:122)
    [apply]     at com.android.dx.cf.direct.ClassPathOpener.process
(ClassPathOpener.java:108)
    [apply]     at com.android.dx.command.dexer.Main.processOne(Main.java:
245)
    [apply]     at com.android.dx.command.dexer.Main.processAllFiles
(Main.java:183)
    [apply]     at com.android.dx.command.dexer.Main.run(Main.java:139)

BUILD FAILED
F:xxxx\build.xml:30: The following error occurred while executing this
line:
F:\xxxx\android_build.xml:185: apply returned: 3

the total size of all the .class files is about 1mpace 1.7m and
the biggest .class file is 87kb.

I've set the ANT-OPTS, but no matter what I try, it's invalid. Is
there a tag or something I can set to increase the heap?
Thank you.

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

3. Suggest a board

4. Search in Maps !

5. Something like onEmailReceived?

6. bring up display setting in my activity

7. Save Cyanogenmod Petition