FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

LoyolaChicagoCode/primenumbers-android-java at master · GitHub

 
 

Repository files navigation

1# Background

The goal of this example is to demonstrate the tradeoffs found in the mobile + cloud architecture, where one has a choice between doing work locally (on the mobile device) versus remotely (in the cloud) with different performance considerations in each case.

This is a very rough initial attempt and still needs significant work.

Learning Objectives

  • Show how CPU-intensive computation can be off-loaded from a mobile app to the cloud, by comparison to a mobile device, an unlimited resource for computation and storage.
  • synchronous local foreground tasks in Android (running directly in an event listener)
  • asynchronous local background tasks in Android using java.util.concurrent.ExecutorService + Handler (the recommended replacement for the now-deprecated AsyncTask)
  • asynchronous access of remote resources (usually RESTful web services) in Android using OkHttp

See also the corresponding web service.

Setting up the Environment

Check out the project using IntelliJ IDEA. This creates the local.properties file with the required line

sdk.dir=<root folder of IntelliJ's Android SDK installation>

Running the Application

In IntelliJ IDEA: Run > Run app

Sample prime numbers to try

The underlying links invoke the corresponding web service on the number.

A Tale of Two AsyncHttpClients (historical note)

This project originally used loopj's AsyncHttpClient, and this section used to warn against a different, unrelated AsyncHttpClient (the Sonatype/AsyncHttpClient one, which throws android.os.NetworkOnMainThreadException without explicit configuration and drags in an unnecessary slf4j logging dependency) that people sometimes confused it with.

As of the current version, this project no longer uses either: loopj's library has had no real maintenance in years and wraps a repackaged fork of Apache HttpClient (removed from the Android SDK itself at API 23). The remote-checking code now uses OkHttp, the current standard HTTP client for Android/Java, instead, so this historical confusion no longer applies either way.

References

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

4 watching

Forks

Releases

Packages

Contributors

Languages


Back | FazBrowse Home | New Git URL