Multithreading For Performance
[This post is by Gilles Debunne, an engineer in the Android group who loves to get multitasked. — Tim Bray] A good practice in creating responsive applications is to make sure your main UI thread does the minimum amount of work. Any potentially long task that may hang your application should be handled in a different thread. Typical examples of such tasks are network operations, which involve unpredictable delays. Users will tolerate some pauses, especially if you provide feedback that something is in progress, but a frozen application gives them no clue. In this article, we will create a simple image downloader that illustrates this pattern. An Image downloader Downloading an image from the web is fairly simple, using the HTTP-related classes provided by the framework. static Bitmap downloadBitmap(String url) { final AndroidHttpClient client = AndroidHttpClient.newInstance("Android"); final HttpGet getRequest = new HttpGet(url); A client and an HTTP request are created. Demo Future work
java - Download a file with Android, and showing the progress in a ProgressDialog
CookieManager (Java Platform SE 6)
java.lang.Object java.net.CookieHandler java.net.CookieManager public class CookieManagerextends CookieHandler CookieManager provides a concrete implementation of CookieHandler, which separates the storage of cookies from the policy surrounding accepting and rejecting cookies. The HTTP cookie management in java.net package looks like: use CookieHandler <------- HttpURLConnection ^ | impl | use CookieManager -------> CookiePolicy | use |--------> HttpCookie | ^ | | use | use | |--------> CookieStore ^ | impl | Internal in-memory implementation CookieHandler is at the core of cookie management. There're various ways user can hook up his own HTTP cookie management behavior, e.g. The implementation conforms to RFC 2965, section 3.3. Since: See Also: CookiePolicy CookieManager public CookieManager() Create a new cookie manager. This constructor will create new cookie manager with default cookie store and accept policy. public CookieManager(CookieStore store, CookiePolicy cookiePolicy) Parameters: get put
Adobe Digital Enterprise Platform * Creating an Android application that invokes Data Services
Create the following three Java client-side classes in your Android project: TraderDesktop: Represents the main class that implements android.app.Activity. This class contains the onCreate method, which is the entry point for the Android application (the new project wizard creates this class). Most of the application logic in this class setups the user interface and does not contain application logic related to Data Services. The following illustration shows the Package Explorer view of the Android project that contains these classes. Note: In addition to creating the Java files, be sure to replace main.xml with content located in this section and create the traderdesktop.properties file. Creating the TraderDesktop class The TraderDesktop class represents the main class for the Android application that implements android.app.Activity. To set up the user interface, define an android.widget.TableLayout instance that displays data in a row and column format. Creating the Stock class
BlazeDS / Home / Java AMF Client
How to monitor network connectivity in Android | Thiranjith's Blog
Android devices have multiple network interfaces (e.g. WiFi and 3G/4G etc.) that allows them to go online and be connected to the outside world. At the same time, these network interfaces are prone to intermittent disconnection (for example, due to location, weather etc). Having knowledge of when the phone is connected (or disconnected) helps applications to act smartly when communicating over the internet. An example is automatically resuming pending downloads – without user intervention – when your network connection comes back online. The following guide shows how you can monitor the network connectivity in Android, so your application can respond better when the network connectivity changes. Android provides a system service called ConnectivityManager that allows us to subscribe to notifications when network state is changed.
Related:
Related: