background preloader

Android development

Facebook Twitter

Ok Android, Broadcast my location! Introduction and Background So, I have got admission for my MCS classes in a (far off) university, and my parents always force me to send them a text or call them to notify them of my current location, where I am, what are the current stats, whether I got the bus or not and so on.

That was not a trouble, the trouble was that I usually keep listening to Eminem and so I forget to inform them where am I and so on. To solve the riddle, I thought I should make my Android a bit useful for myself and notify my parents by a text message, where currently am I! This article does not only focus on creating that one simple application, but also focused on the LocationManager, LocationListener, PendingIntent and a few other concepts in Android programming that you may want to understand to build other similar applications that require GPS or Network based location services and to notify the clients.

Construction and Concept Here it goes: Figure 1: Demonstration of our requirement and work around. 1. 2. Learn About Android Drawables Used By App Developers In Android App Development - World of Mobile Applications. Article 7 - Android Connectivity. Introduction This article is dediated in explaining various Android Connectivity options. Below are the topics covered in this article. Background Please find the below link for "Introduction to Android" Please refer the below mentioned article to setup your development environment. Basics of enabling connectivity in Android applications Let us try to understand some of the basic classes that are used as a part of the android network connectivity package.

ConnectivityManager The ConnectivityManager is the class which is used to monitor the status of the network connection for example WiFi, GPRS etc. 1. NetworkInfo The NetworkInfo as the name itself indicates, it’s used to get the status of the network interface. IsAvailable() – Returns true if the network connectivity is possible else this method returns false. BroadcastReceiver 1. Find All Elements By Tag Name : DOM Element « XML « Java. Parsing XML using DOM, SAX and StAX Parser in Java. I happen to read through a chapter on XML parsing and building APIs in Java. And I tried out the different parser available on a sample XML. Then I thought of sharing it on my blog so that I can have a reference to the code as well as a reference for anyone reading this. In this post I parse the same XML in different parsers to perform the same operation of populating the XML content into objects and then adding the objects to a list.

The sample XML considered in the examples is: And the obejct into which the XML content is to be extracted is defined as below: There are 3 main parsers for which I have given sample code: Using DOM Parser I am making use of the DOM parser implementation that comes with the JDK and in my example I am using JDK 7. The output for the above will be: Using SAX Parser Along with the XML source file, we also register a handler which extends the DefaultHandler class. The code for parsing the XML using SAX Parser is given below: The output for the above would be:

AsyncTask. Class Overview AsyncTask enables proper and easy use of the UI thread. This class allows to perform background operations and publish results on the UI thread without having to manipulate threads and/or handlers. AsyncTask is designed to be a helper class around Thread and Handler and does not constitute a generic threading framework.

AsyncTasks should ideally be used for short operations (a few seconds at the most.) An asynchronous task is defined by a computation that runs on a background thread and whose result is published on the UI thread. Developer Guides For more information about using tasks and threads, read the Processes and Threads developer guide. Usage Here is an example of subclassing: protected void onProgressUpdate(Integer... progress) { setProgressPercent(progress[0]); } protected void onPostExecute(Long result) { showDialog("Downloaded " + result + " bytes"); } } Once created, a task is executed very simply: new DownloadFilesTask().execute(url1, url2, url3); The 4 steps. Android : Connecting to Server (MySQL using PHP) | Zeeshan Arif.

To connect you android Application with the server Database MYSQL we will be using PHP files. When android application will execute, it will connect android device to PHP Script.PHP Script will fetch data from the database. It will encode it into json format and send it to the device.Now, android application will get these encoded data. It will parse the data and display it on android device. Implementation: First Create a php file and plce it to server. if you are using a localhost wamp server place this php file to www/folderName/myFile.php.

And then write code like this in that php file. In our Android application,use a HttpPost to get the data,convert response to stringparse JSON data, and use it as you want Following is the code for this: JSONArray jArray = null;String result = null;StringBuilder sb = null;InputStream is = null; ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); //http post try{ HttpClient httpclient = new DefaultHttpClient(); Zeeshan Arif: Android : Connecting to Server (MySQL using PHP) Programming Android: Android add data to remote database (MySql) Android | Cleaner HTTP AsyncTask | HMKCode. HTTP AsyncTask is a commonly needed function in most Android app. So it is better to have a generic and reusable piece of code that can take care of the HTTP AsyncTask process whenever you need it. This will save your time and make your business code cleaner.

Here we will see a suggested way to build such generic and reusable code. Objective: Building a generic & reusable HTTP AsyncTask code. Non-Reusable HTTP AsyncTask Code Reusable HTTP AsyncTask Code Here we have two classes that may save your time and make your code cleaner whenever HTTP AsyncTask is required. HttpHandlerAsyncHttpTaskcom.hmkcode.http.HttpHandler.java This is an abstract class which developers need to implement it anonymously & override its two abstract methods getHttpRequestMethod() and onResponse(). Com.hmkcode.http.AsyncHttpTask.java Using the Reusable Classes The only class that you need to add to your code is HttpHandler. Within the getHttpRequestMethod() you need to create & prepare the http request object e.g. Input Data to MySQL Database (Android forum at JavaRanch)

Java - Inserting data into MySQL using http-post and AsyncTask doesn't work. Android: How to Send Request (POST) to the Server (Full Application) - strife's devLog. Hi, Like I said before I am new to Android and I don’t hide it but I’ve started to like it so far. And now I’d like to show you an application which enables sending data to the servers remotely. Before I give you the code, just look at the screens how it looks. But if you don’t care how it works just download the application from here: It should be compatibile with 2.3.3 API. Preview: Here you can easly send your data to server, just like that. That how looks settings page View after clicking on the button How it works? There is too many files to show, for that reason I decided to explain only few features. How to make a progress bar? It’s simple, in your Activity class you’ve got to create a class which will extends of AsyncTask it should look like that: ... private class postData extends AsyncTask<String, Void, String> { private final ProgressDialog dialog = ProgressDialog.show(sendToServerActivity, "", "Saving data to server.

As you see I execute this class using .execute method. Android Web Service | Android Restful Web Service. Creating web service application in android is not a difficult task. We can easily create a restful web service application in android to authenticate or save information into the external database such as oracle, mysql, postgre sql, sql server using other application developed in java, .net, php etc languages. That is what we are going to do. Android Restful Web Service Tutorial Before developing web services application, you must have basic knowledge of SOAP and Restful web services.

What is Web Service? A web service is a standard for exchanging information between different types of applications irrespective of language and platform. Android Restful Web Service Example File: activity_main.xml File: activity_register_user.xml MainActivity class File: MainActivity.java RegisterUser class File: RegisterUser.java File: AndroidManifest.xml You need to provide INTERNET permission in AndroidManifest.xml file. Output: Java Servlet Login and Register example using oracle database Login Servlet class. Android Data Storage. Index Introduction Data Storage is the important thing that you should to learn when you want to buil an application.

On the Android platform you can store the data in files, databases, or shared preferences in the device storage and you can also store the data in the cloud by using the external APIs such as Dropbox, Parse, etc. Background When you create the application you will found that you need to store some data such as user data, images, etc. that is the topic that we will learn in this article.

To learn this article you need to know the basic of Android Application Development. Let's Start Today the data is the most powerful fuel that drive your application ahead, you need to know that how can you manage the data? The Files Files is the simplest way to store the data. Files When you want to write something to the file you need to create a new one or open an existing one then write the data that you want and close it after use.

Sample of File operate in Java: Hide Copy Code For example: . Simple Sync Apps. About Download The download file is very bigger, the reason is there are two project contains inside the zip file. One is desktop application and the other one is android application. Introduction I begin to learn programming is still half of a years ago and I begin to write this application is about one months ago. Begin from 0 knowledge to network and server. How it works The picture above shows how the data is transferred. Develop Environment My development environment is Java JDK version 1.7.0_13, Eclipse SDK (Juno version 4.2.1), XAMPP 1.8.1, MySQL Connector/J 5.1.23, android 4.2. Program Flow Chart Request ask for read database PHP file to work.

Source Code mysqlAndroid is an android project. Asynchronous HTTP Post Android Tutorial and Example Code. Let’s make an Android application to send a value that you type in a text box to a server script via HTTP post. We will handle the HTTP request in an asynchronous fashion so that the application does not freeze while the request is happening. Our application, shown below, will have a text box, a button, and a progress view so that the user knows that the data is been sent.

Asynchronous HTTP application: sending data, a progress bar view shows the progress. After the value is sent a toast message will be displayed as shown below. message sent state of application The User Interface As shown above, it simply consists of a button, progress bar, text box, and label. res/layout/home_layout.xml Linking Layout to Activity Now let’s link each of our views in the layout to code in java.

Notice that we have turned off the visibility of our prograss, it will become visible only while the data is been sent. HTTP Posting Data receiver.php The Asynchronous Class When The Button I Clicked Full Code Related posts: Optimizing HttpURLConnection in Android - codeitive.com. Sample Program - Android MySQL DB, Insert Values from Android to MySQL Database, Select Values from MySQL Database to Android, Update Values from Android to MySQL Database, Delete Values from Android to MySQL Database.

NoteDownload ADT Plugin Here. Here I am using, OS : Linux (Ubuntu 12.04) Eclipse : Juno (Version 4.2.0) Android API Level : 3 to 'n' as per need Emulator API Level : It will be displayed in output image A. Insert Values from Android to MySQL Database Step 1 : Select File -> New -> Project -> Android Application Project (or) Android Project. Step 2 : Open res -> layout -> activity_main.xml (or) main.xml and add following code : Step 3 : Open src -> package -> MainActivity.java and add following code : Step 4 : Open AndroidManifest.xml and add following code : Step 5 : Open res ->values ->strings.xml and add following code : <resources><string name="app_name">MySql_insert</string><string name="hello_world">Hello world!

Step 6 : Create insert.php in File System -> var -> www (Ubuntu OS) / C drive -> wamp -> www (Windows OS) and add following code : Step 7 : Our output will be like this : B. <resources><string name="app_name">MySql_Select</string><string name="hello_world">Hello world! C. D. Android Development. Android Interaction Design Patterns | Android Example | Basics | Developer | Source Code | Tutorials | Advance | Apps. Downloading and Building | Android Developers. The Android build is routinely tested in-house on recent versions of Ubuntu LTS (12.04), but most distributions should have the required build tools available.

We welcome reports of successes or failures on other distributions. Before you download and build the Android source, ensure your system meets the following requirements: A Linux or Mac system. It is also possible to build Android in a virtual machine on unsupported systems such as Windows. If you are running Linux in a virtual machine, you need at least 16GB of RAM/swap and 50GB or more of disk space in order to build the Android tree. See disk size requirements below. A 64-bit environment is required for Gingerbread (2.3.x) and newer versions, including the master branch. ADT Plugin Release Notes. Android Development Tools (ADT) is a plugin for the Eclipse IDE that extends the capabilities of Eclipse to let you quickly set up new Android projects, create an application UI, add packages based on the Android Framework API, debug your applications using the Android SDK tools, and even export signed (or unsigned) .apk files in order to distribute your application.

Note: If you have been using Eclipse with ADT, be aware that Android Studio is now the official IDE for Android, so you should migrate to Android Studio to receive all the latest IDE updates. For help moving projects, see Migrating to Android Studio. Note that before you can install or use ADT, you must have compatible versions of both the Eclipse IDE and the Android SDK installed. For details, make sure to read Installing the Eclipse Plugin. Revisions The sections below provide notes about successive releases of the ADT Plugin, as denoted by revision number. ADT 23.0.4 (October 2014) Dependencies: General Notes: Known Issues: [Solved] Read/Write CSV in Android. Java doesn’t support parsing of CSV files natively, we have to rely on third party library. There was 3rd party library Opencsv is very good library to read and write CSV file in android platform. At first you need to download this library Download.

Then try...Reading CSV file in Java: String csvFilename = "C:\\sample.csv"; CSVReader csvReader = new CSVReader(new FileReader(csvFilename)); String[] row = null; while((row = csvReader.readNext()) ! = null) { System.out.println(row[0] + " # " + row[1] + " # " + row[2]); } csvReader.close(); Above code read csv file line by line. If you want to read full document once using below code: String[] row = null; String csvFilename = "C:\\work\\sample.csv"; CSVReader csvReader = new CSVReader(new FileReader(csvFilename)); List content = csvReader.readAll(); for (Object object : content) { row = (String[]) object; System.out.println(row[0] + " # " + row[1] + " # " + row[2]); } csvReader.close(); Writing CSV file in Java:

How to Publish Your Apps On Google Play For x86-based Android Devices Using Multiple APK Support. Android Tutorial 9: Integrating Web Services Into Your Android App. Tips for Optimizing Android Application Memory Usage. Android Forum at JavaRanch. Android Internet Connection Using HTTP GET (HttpClient) | HMKCode.

Android Network Connection Tutorial. Android App Development with Android Studio IDE. 8 (Login Form) A way to create "deathless" Android applications. How to Develop a Simple Android Service. Sample Program - Android MySQL DB, Insert Values from Android to MySQL Database, Select Values from MySQL Database to Android, Update Values from Android to MySQL Database, Delete Values from Android to MySQL Database. Navigation Drawer Android Example | JavatechIG.com.

Get a list of filenames in this folder. : File « File « Android. Android Hub 4 you : the free android programming tutorial: ListView into ScrollView in Android. Browse Files - Xamarin. Creating a Cloud Backend for Your Android App Using Parse. Android Simple XML Parsing using DOM Tutorial. Create a CRUD web app using JQuery Mobile and LocalStorage.

Android Hub 4 you : the free android programming tutorial: ListView into ScrollView in Android. Android WebView Loads all the urls but not only mine. Android - How do I use DownloadListener? Android DownloadManager Example | vogella blog. Java - Download a file with Android, and showing the progress in a ProgressDialog. Android WebView Loads all the urls but not only mine. Can we know when browser finish loading an URL from application on Android. Android!! Fetch database row in new activiy. Why does the OnDownloadStart Method from Downloadlistener never gets called? - Xamarin Forums. Android.webkit.DownloadListener - Android SDK. Java - Download a file with Android, and showing the progress in a ProgressDialog. How to run Hello World Android app.

Article 4 - Android UI Layout and Controls. Android Connectivity. Step by Step Method to Access Webservice from Android. Handling Input and Storage on Android. Android Services and More. Learn How to Develop Android Application. Android Development. Android apps (Live Connect) Android Arsenal. Android apps - OneDrive Dev Center. AndroidViews - Custom Android UI Views. Android WebView Example. ANDROID | CoderzHeaven. Android Example | Basics | Developer | Source Code | Tutorials | Advance | Apps.

Google Drive Android API. How to run Hello World Android app. REDCap | CTSI. Google Maps Android API v2. URL. Parsing - Get and Parse CSV file in android. Learn Java for Android Development: Working with Arrays - Tuts+ Code Tutorial. Android Studio Development Essentials. Getting Started.