Skip to content
Branch: master
Find file History
Jeremy Walker
Jeremy Walker Adds NetworkConnect sample to repo.
Change-Id: I44965185dc786728c2b226f1297b5a1d86463bdc
Latest commit b10acb8 Jul 30, 2019
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
.google Adds NetworkConnect sample to repo. Jul 30, 2019
Application Adds NetworkConnect sample to repo. Jul 30, 2019
gradle/wrapper Adds NetworkConnect sample to repo. Jul 30, 2019
screenshots Adds NetworkConnect sample to repo. Jul 30, 2019
README.md
build.gradle Adds NetworkConnect sample to repo. Jul 30, 2019
gradle.properties Adds NetworkConnect sample to repo. Jul 30, 2019
gradlew Adds NetworkConnect sample to repo. Jul 30, 2019
gradlew.bat Adds NetworkConnect sample to repo. Jul 30, 2019
settings.gradle Adds NetworkConnect sample to repo. Jul 30, 2019

README.md

Android NetworkConnect Sample

This sample demonstrates how to connect to the network and fetch raw HTML using HttpsURLConnection. AsyncTask is used to perform the fetch on a background thread.

Introduction

This sample demonstrates how to connect to the network and fetch raw HTML using HttpsURLConnection. Since API 11, it is required by default that all network operations run on a background thread in order to avoid hanging on the UI thread. Only when the network response is ready should the work return to the main thread to update the UI. An AsyncTask is a viable background task manager that is used to perform the network operation and return to the UI thread upon completion.

The sample also utilizes the ConnectivityManager to determine if you have a network connection, and if so, what type of connection it is.

Using an AsyncTaskLoader or an IntentService are two common alternatives for managing longer running background work.

Pre-requisites

  • Android SDK 28
  • Android Build Tools v28.0.3
  • Android Support Repository

Screenshots

Screenshot

Getting Started

This sample uses the Gradle build system. To build this project, use the "gradlew build" command or use "Import Project" in Android Studio.

Support

If you've found an error in this sample, please file an issue: https://github.com/android/connectivity

Patches are encouraged, and may be submitted by forking this project and submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.

You can’t perform that action at this time.