This ppt will explain you about the network optimization best practice of making you app network more strong and stable which improve performance of the app as well
2. What is Android Network Optimization?
Android Network Optimization is about implementing best practices to
optimize android network performance for android apps. Mostly the requests
sent by apps to network turn on power intensive mobile radios. Some more
power is also consumed to keep mobile radio awake other than power required
to send and receive packets. Even a small network request can keep awake the
mobile radio for long periods
3. What is Android Network Optimization?
Proper optimization of network is possible after knowing the source of the
traffic. Network activity generated by the app is reasonable when it is
responding to user actions but, incase if app is not in the foreground or lying
idle inside user pocket then network activity is not required
4. Methods for Android Apps Network
Optimization
1) Data Compression
2) Cache Files Locally
3) Optimization of User-Initiated Network Use
Pre-fetch Network Data
1) Optimization of App-Initiated Network Use
Implement Effective Network Batching
1) Optimization of Server-Initiated Network Use
5. Data Compression
The very basic and effective step for network optimization is data compression.
GZIP compression is helpful compression technique to compress data smartly. A
smaller on-the-wire packet size and faster encoding and decoding time can be
ensured using binary serialization formats like Protocol Buffers or FlatBuffers
6. Cache Files Locally
Duplicate data download can be avoided with caching. Obviously, reading data
from device is quite faster than reading the same data from the network. If
data will be used multiple times then fetching it directly through network than
storing it on device is more effective. This will also ensure that upcoming
requests need not to re-download the file.
8. Cache Files Locally
HTTP responses is disabled in android application. By turning on the cache by
using the HTTP response cache class which will enable app to to decide a
location on the device for physical file storage as well as the max size for cache.
Enabling it means every HTTP response will be cached on file system for the
application.
10. Cache Files Locally
Caching is applicable to API like URL as well as HTTP URL connections and other
code snippets too. It is as well applicable to all those HTTP request made via
libraries that are bundled within the applications.
11. Optimization of User-Initiated
Network Use
When user action requires network access then quick handling of user requests
is imperative to ensure smooth user experience. Specially when network use is
dependent upon user action then low latency should be prioritized over power
consumption for providing quick and efficient handling of user request for good
user experience.
12. Pre-fetch Network Data
Pre-fetching the data will reduce the quantity of independent data transfer
session running on the app. Pre-fetch process is helpful in ensuring which data
will be required for the upcoming series of user actions when an action is taken
by user on the app and will fetch that data in bulk.
14. Pre-fetch Network Data
As the app will pre-fetch the data when mobile radio is awake due to user
actions hence no need to wake up the mobile radio additionally. This will limit
separate requests to wake mobile radio again and again and boost the battery
life
15. Optimization of App-Initiated Network Use
After the request the cellular radio wait for about a minute extra for server
response hence consumes more power and if there are multiple network
request it will keep radio alive for very long duration and this will consume
even greater battery power. Network data initiated by app can be optimized by
planning which network resources are needed and accordingly these can be
scheduled for accessing. Smart scheduling will ensure good number of rest
periods for device radio which will eventually save substantial amount of
power.
16. Optimization of App-Initiated Network Use
Implement Effective Network Batching
Batching is an effective way to combine these requests which will wake up and
keep radio alive only once.
Batching means to intercept the outbound requests and keep them under
pending list of actions which will be made in future. There are various
complexities in scheduling but, GCM network Manager is a Google Play Services
API to schedule network oriented tasks and handle batching as well. In this
manner batching will not only optimize network request for better battery
performance but will also improve the app performance for users.
18. Optimization of Server-Initiated Network Use
It is quite challenging to optimize the network traffic sent by the servers.
Although the app can periodically check for updates by polling the server but it
will result in significant loss of network connection and power whenever app
starts the radio of device.
An excellent solution to this problem is Google Cloud Messaging (GCM) which
enables servers to send notifications to instances of the app on installation
thereby ensuring better network efficiency and significantly lessening the
power usage.
19. Optimization of Server-Initiated Network Use
With GCM the app server will notify the app about availability of new data by
implementing the message-passing mechanism. In this manner app will not
have to perform any network traffic by contacting backend server for new data.
GCM service discards any not required connections where polling might not
return any updates at the same time it avoids running periodical network
request that will power up the device radio. Interestingly, GCM can be
implemented by multiple apps.