Android material design Programming Blog

With the power of three powerful words Android MySQL PHP, you can develop any Android application which involves the fetching of data from the back-end server. If you look at the AdSense Android application from Google, you like to see., earning statistics for days, months, and years in a subsequent row. In this tutorial, we going to develop a similar kind of application which involves fetching of statistic data from MySQL PHP. Let’s get started.

Android

Defining Array and Style

strings.xml

Define an array of all items where we need to populate into the spinner in strings.xml file

<resources><stringname="app_name">DateRangeExample</string><string-arrayname="date_array"><item>Today so far</item><item>Yesterday</item><item>This Week so far</item><item>This Month so far</item><item>Last Month</item><item>This Year so far</item><item>LifeTime</item><item>Custom</item></string-array></resources>

Creating Activity File

MainActivity.java

Initialize all variables and set Array from strings.xml to Spinner and populate the list.

Based on user item selection from the Spinner, make a call to AsyncRetrieve class with parameter as item position.

Make sure your URL address is accessible from a browser and define the same in AsyncRetrieve class(in place of http://192.168.1.7/). The AsyncRetrieve class is responsible for making a call to PHP and retrieving results.