Before your Android app can make requests to web-based resources you first need to add permissions to the app. You should also add code that checks whether network connectivity is available.
- [Voiceover] Once you've selected a way…to manage background threads,…you're ready to start communicating over the web.…Before your Android app can make requests…to web based resources, you first need to add permissions.…You should also add code…that checks whether network connectivity is available.…I'll start in the application manifest,…where I'll declare two permissions…with the uses-permission element.…The first will be access network state,…and the second one will be internet.…Both of these are what Android calls normal permissions.…
Starting in Android 6, permissions were separated…into normal permissions and dangerous permissions.…When you use dangerous permissions,…that can affect the state of the device,…you have to add code that asks the user…for that permission at run time.…With normal permissions like these though,…permission is granted automatically.…Next I'll add Java code to check for network connectivity.…I could place this code in my main activity class,…but that would restrict its reusability.…
IInstructor David Gassner starts with an overview discussion about available networking strategies, and then dives into how to declare networking permissions, make network requests, handle responses, parse data returned from a web service, and pass user credentials to services that support HTTP basic authentication. He also provides an overview of popular higher-level networking libraries, including OkHttp and Picasso, and offers recommendations for improving performance in network-connected apps. David also covers using static feeds, using dynamic PHP pages hosted on a public server web service, and integrating apps with network data storage.
- Integrating mobile apps
- Communicating with Android
- Preventing app freezes with background threads
- Preparing an app for network communication
- Declaring permissions
- Checking network connectivity
- Retrieving data over the web
- Using traditional APIs
- Using third-party libraries