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
headline:
...
am.set(AlarmManager.RTC,  System.currentTimeMillis() + 5000,
pendingIntent);
...

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...

-Christer


--



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>
    </style>

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="http://schemas.android.com/apk/res/
android" style="@style/myStyle">
    ...
    ...
    ...
</LinearLayout>

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

tia.

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

2. ping works but browser failed in cupcake

The GPRS over PPP in my board can work. I can ping website such as
www.baidu.com 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 www.a.shifen.com (119.75.213.51) 56(84) bytes of data.
64 bytes from 119.75.213.51: icmp_seq=1 ttl=51 time=786 ms
64 bytes from 119.75.213.51: icmp_seq=2 ttl=51 time=537 ms
64 bytes from 119.75.213.51: 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...@~]## [ro.secure]: [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]
[ro.build.id]: [CUPCAKE]
[ro.build.display.id]: [generic-eng 1.5 CUPCAKE eng.edwardlee.20090502.091712 te
st-keys]
[ro.build.version.incremental]: [eng.edwardlee.20090502.091712]
[ro.build.version.sdk]: [3]
[ro.build.version.release]: [1.5]
[ro.build.date]: [Sat May  2 10:38:13 PDT 2009]
[ro.build.date.utc]: [1241285893]
[ro.build.type]: [eng]
[ro.build.user]: [edwardlee]
[ro.build.host]: [edwardlee-desktop]
[ro.build.tags]: [test-keys]
[ro.product.model]: [generic]
[ro.product.brand]: [generic]
[ro.product.name]: [generic]
[ro.product.device]: [generic]
[ro.product.board]: []
[ro.product.manufacturer]: [unknown]
[ro.product.locale.language]: []
[ro.product.locale.region]: []
[ro.board.platform]: []
[ro.build.product]: [generic]
[ro.build.description]: [generic-eng 1.5 CUPCAKE eng.edwardlee.20090502.091712 t
est-keys]
[ro.build.fingerprint]: [generic/generic/generic/:1.5/CUPCAKE/eng.edwardlee.2009
0502.091712:eng/test-keys]
[rild.libpath]: [/system/lib/libreference-ril.so]
[rild.libargs]: [-d /dev/ttyS2]
[ro.radio.use-ppp]: [yes]
[ro.sf.lcd_density]: [128]
[ro.config.notification_sound]: [F1_New_SMS.ogg]
[ro.kernel.android.checkjni]: [1]
[ro.config.sync]: [yes]
[net.bt.name]: [Android]
[net.change]: [net.dnschange]
[dalvik.vm.stack-trace-file]: [/data/anr/traces.txt]
[ro.FOREGROUND_APP_ADJ]: [0]
[ro.VISIBLE_APP_ADJ]: [1]
[ro.SECONDARY_SERVER_ADJ]: [2]
[ro.HOME_APP_ADJ]: [4]
[ro.HIDDEN_APP_MIN_ADJ]: [7]
[ro.CONTENT_PROVIDER_ADJ]: [14]
[ro.EMPTY_APP_ADJ]: [15]
[ro.FOREGROUND_APP_MEM]: [1536]
[ro.VISIBLE_APP_MEM]: [2048]
[ro.SECONDARY_SERVER_MEM]: [4096]
[ro.HOME_APP_MEM]: [4096]
[ro.HIDDEN_APP_MEM]: [5120]
[ro.CONTENT_PROVIDER_MEM]: [5632]
[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]
[init.svc.de{*filter*}d]: [running]
[init.svc.mux]: [running]
[init.svc.ril-daemon]: [running]
[init.svc.zygote]: [running]
[init.svc.media]: [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]
[gsm.version.ril-impl]: [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]: [211.95.1.97]
[net.ppp0.dns2]: [211.90.216.129]
[net.ppp0.local-ip]: [172.18.15.52]
[net.ppp0.remote-ip]: [192.200.1.21]
[net.gprs.dns1]: [211.95.1.97]
[net.gprs.dns2]: [211.90.216.129]
[net.dns1]: [211.95.1.97]
[net.dns2]: [211.90.216.129]
[gsm.defaultpdpcontext.active]: [true]
[net.dns1.858]: []
[net.dns2.858]: []
[net.dns3]: [211.95.1.97]
[net.dns4]: [211.90.216.129]

--~--~---------~--~----~------------~-------~--~----~
unsubscribe: android-porting+unsubscr...@googlegroups.com
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