Extend battery life-the impact of network data

Source: Internet
Author: User

Android devices typically have multiple data connections:

(1) Bluetooth

(2) Ethernet

(3) Wi-Fi

(4) WiMax

(5) mobile network (EDGE,UMTS,LTE)

Get Network information:

public class NetInfo extends Activity {private TextView netinfoshow,netinfoshows; @Overrideprotected void OnCreate ( Bundle savedinstancestate) {//TODO auto-generated method Stubsuper.oncreate (savedinstancestate); Setcontentview ( R.layout.net_info); netinfoshow = (TextView) Findviewbyid (r.id.net_show); netinfoshows = (TextView) Findviewbyid ( R.id.nets_show); Shownetworkinfotoast ();} private void Shownetworkinfotoast () {Connectivitymanager cm = (Connectivitymanager) getsystemservice ( Context.connectivity_service);//Show only active connections Networkinfo info = cm.getactivenetworkinfo (); if (info! = null) { Netinfoshow.settext (Info.tostring ());}       Show all connections networkinfo[] infos = Cm.getallnetworkinfo (), if (infos! = null) {StringBuilder SB = new StringBuilder ("All:"); (int i = 0; i < infos.length; i++) {sb.append (infos[i]+ "\ n");} Netinfoshows.settext (Sb.tostring ());}}}


To maximize battery life:

(1) Background data settings:

The user can specify in the settings whether to allow background data transfer.

(2) Frequency of data transmission:

If you can control the transmission type of the data, you can compress the data before transferring it to the device. The usual procedure is:

1. Use gzip to compress text data and use the Gzipinputstream class to access data

2. If possible, use JPEG instead of PNG format image file

3. Use a resource that matches the resolution of the device (for example, you do not have to download 1920x1080 images for a 96x54 size display space).



Extend battery life-the impact of network data

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.