How to make a widget that doesn't drain the battery and updates often

by Chister Nordvik » Sun, 06 Jun 2010 02:38:47 GMT

Sponsored Links
 > Frankly, I don't know why the Genie... service sticks around for the

Neither do I, but it seems "everyone" is taking this approach. I
really really miss guidelines on Android development. Both GUI design
guidelines (toolbars at the bottom anyone?) and design guidelines for
widgets doing more advanced things than updating a clock. It must be
100 different toolbars out there at the moment in various sizes. Why
can't we have a proper toolbar in Android? Sorry, off-topic :-)

I would love to see some better suggestions :-)

No wake-locks. Only using the following code to make the widget change
am.set(AlarmManager.RTC,  System.currentTimeMillis() + 5000,

According to the documentation this should work just brilliant. But my
phone is dead every morning with my widget running. Uninstalled!

Well, people will blame my widget even if I try to tell them that they
have another application that has wake_locks so I must make my widget
behave nicely with the rest of the apps out there.

Well I have made a new service that runs all the time and receives
broadcast events for screen off and on and that works great, so maybe
I'll stick with this. When I have started 10 of my favourite apps I
have a lot of services running so I guess people are used to this.
Seems like services is a bit overused these days so no wonder everyone
complains about battery life with Android...



Other Threads

1. unable to hide window title using a theme.

yes, I know how to do it in the java code (requestWindowFeature
(Window.FEATURE_NO_TITLE)) -- but I would like to create a style that
does that.

    <style name="myStyle">
        <item name="android:windowNoTitle">true</item>
        <item name="android:background">@drawable/myBackground</item>
        <item name="android:layout_width">fill_parent</item>
        <item name="android:layout_height">fill_parent</item>
        <item name="android:orientation">vertical</item>

Then I would expect to be able to do this in my layout xml file --

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="
android" style="@style/myStyle">

I get the background and the vertical orientation and the layout width/
height, but I still get a title!



2. ping works but browser failed in cupcake

The GPRS over PPP in my board can work. I can ping website such as in the shell. But when I open browser and connect the
same website, the browser will report "The server failed to
communicate. Try again later.".

The ping result:
[r...@~]#ping ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=51 time=786 ms
64 bytes from icmp_seq=2 ttl=51 time=537 ms
64 bytes from icmp_seq=3 ttl=51 time=351 ms

What is wrong with my enviorment?

Any help will be appreciated.

Attached is my result of getprop:
[r...@~]## []: [0]
[ro.allow.mock.location]: [1]
[ro.debuggable]: [1]
[persist.service.adb.enable]: [1]
[ro.factorytest]: [0]
[ro.serialno]: []
[ro.bootmode]: [unknown]
[ro.baseband]: [unknown]
[ro.carrier]: [unknown]
[ro.bootloader]: [unknown]
[ro.hardware]: [marvell]
[ro.revision]: [0]
[]: [generic-eng 1.5 CUPCAKE eng.edwardlee.20090502.091712 te
[]: [eng.edwardlee.20090502.091712]
[]: [3]
[]: [1.5]
[]: [Sat May  2 10:38:13 PDT 2009]
[]: [1241285893]
[]: [eng]
[]: [edwardlee]
[]: [edwardlee-desktop]
[]: [test-keys]
[ro.product.model]: [generic]
[ro.product.brand]: [generic]
[]: [generic]
[ro.product.device]: [generic]
[ro.product.board]: []
[ro.product.manufacturer]: [unknown]
[ro.product.locale.language]: []
[ro.product.locale.region]: []
[ro.board.platform]: []
[]: [generic]
[]: [generic-eng 1.5 CUPCAKE eng.edwardlee.20090502.091712 t
[]: [generic/generic/generic/:1.5/CUPCAKE/eng.edwardlee.2009
[rild.libpath]: [/system/lib/]
[rild.libargs]: [-d /dev/ttyS2]
[]: [yes]
[ro.sf.lcd_density]: [128]
[ro.config.notification_sound]: [F1_New_SMS.ogg]
[]: [1]
[ro.config.sync]: [yes]
[]: [Android]
[net.change]: [net.dnschange]
[dalvik.vm.stack-trace-file]: [/data/anr/traces.txt]
[ro.HOME_APP_ADJ]: [4]
[ro.EMPTY_APP_ADJ]: [15]
[ro.VISIBLE_APP_MEM]: [2048]
[ro.HOME_APP_MEM]: [4096]
[ro.HIDDEN_APP_MEM]: [5120]
[ro.EMPTY_APP_MEM]: [6144]
[net.tcp.buffersize.default]: [4096,87380,110208,4096,16384,110208]
[net.tcp.buffersize.wifi]: [4095,87380,110208,4096,16384,110208]
[net.tcp.buffersize.umts]: [4094,87380,110208,4096,16384,110208]
[net.tcp.buffersize.edge]: [4093,26280,35040,4096,16384,35040]
[net.tcp.buffersize.gprs]: [4092,8760,11680,4096,8760,11680]
[keyguard.no_require_sim]: [1]
[ro.config.nocheckin]: [yes]
[init.svc.console]: [running]
[init.svc.servicemanager]: [running]
[init.svc.vold]: [running]
[{*filter*}d]: [running]
[init.svc.mux]: [running]
[]: [running]
[init.svc.zygote]: [running]
[]: [running]
[init.svc.dbus]: [running]
[init.svc.installd]: [running]
[init.svc.adbd]: [running]
[hw.keyboards.65536.devname]: [pxa27x-keypad]
[sys.settings_secure_version]: [2]
[dev.bootcomplete]: [1]
[sys.settings_system_version]: [7]
[]: [android reference-ril 1.0]
[gsm.sim.operator.numeric]: [46001]
[gsm.sim.operator.alpha]: [UNICOM   ]
[gsm.sim.operator.iso-country]: [cn]
[gsm.sim.state]: [READY]
[gsm.operator.alpha]: []
[gsm.operator.numeric]: []
[gsm.operator.iso-country]: []
[gsm.operator.isroaming]: [false]
[net.gprs.http-proxy]: []
[net.dnschange]: [1]
[net.gprs.ppp-exit]: []
[init.svc.pppd_gprs]: [running]
[net.interfaces.defaultroute]: [gprs]
[net.ppp0.dns1]: []
[net.ppp0.dns2]: []
[net.ppp0.local-ip]: []
[net.ppp0.remote-ip]: []
[net.gprs.dns1]: []
[net.gprs.dns2]: []
[net.dns1]: []
[net.dns2]: []
[]: [true]
[net.dns1.858]: []
[net.dns2.858]: []
[net.dns3]: []
[net.dns4]: []

website:  http://www.***.com/ 

3. Call path flow

4. MediaStore.EXTRA_OUTPUT

5. get current location after pressing button

6. OMG, this 325 character limit !

7. How to listen to " Back" key