Android JSON Parsing Tutorial

Size: px
Start display at page:

Download "Android JSON Parsing Tutorial"

Transcription

1 Android JSON Parsing Tutorial by Kapil - Thursday, May 19, YouTube Video JSON(JavaScript Object Notation), is a language independent data format that uses human-readable text to transmit data objects consisting of key-value pairs. In this tutorial we will explain the structure of JSON response and how to parse the response in order to get required Information. To explain the concept we would be using two sample JSON responses we have created and placed at below links. These links consist of sample JSON Responses for JSON Array and JSON Object respectively. Before starting to build app let's dig a bit into the structure of a JSON response. Consider following JSON Response : [ { "rom":"32gb", "screensize":"5.5 inch", "backcamera":"21mp", "companyname":"motorola", "name":"moto X Play", "frontcamera":"5mp", "battery":"3630mah", "operatingsystem":"android 5.1", "processor":"1.8ghz", "url":" "ram":"2gb", { 1 / 22

2 "rom":"8gb", "screensize":"4 inch", "backcamera":"5mp", "companyname":"samsung", "name":"galaxy S Duos 3", "frontcamera":"0.3mp", "battery":"1500mah", "operatingsystem":"android 4.4", "processor":"1.2ghz", "url":" "ram":"512mb",{"rom":"64gb", "screensize":"4.7 inch", "backcamera":"12mp", "companyname":"apple", "name":"iphone 6S", "frontcamera":"5mp", "battery":"1715mah", "operatingsystem":"ios 9", "processor":"1.84ghz", "url":" "ram":"2gb", { "rom":"16gb", "screensize":"5.2 inch", "backcamera":"12.3mp", "companyname":"lg", "name":"nexus 5X", "frontcamera":"5mp", "battery":"1500mah", "operatingsystem":"android 6", "processor":"1.8ghz", "url":" "ram":"2gb" ] As apparent from above a JSON Response can have the following elements. 1. JSON Array([): In a JSON file, square bracket ([) represents a JSON array. 2. JSON Objects({): In a JSON file, curly bracket ({) represents a JSON object. 3. Key: A JSON object contains a key that is just a string. Pairs of key/value make up a JSON object. 4. Value: Each key has a value that could be string, integer or double etc. 2 / 22

3 Android provides the following classes to manipulate a JSON response : JSONObject,JSONArray, JSONStringer and JSONTokener. We will be talking about org.json.jsonobject and org.json.jsonarray in this tutorial. To parse a JSON response first identify the fields in the JSON response that you are interested in. For example. In the JSON given above in the link, we will be using all the fields. We have to write our parse function accordingly. Let's go step by step to make a sample JSON parsing app. We will demonstrate how to parse a JSON Object and a JSON Array. In this app, we will retrieve the details of Mobile Phones from the JSON String provided at given URL and then display them as a list, on Clicking each individual Mobile, details of the mobile will be displayed. (adsbygoogle = window.adsbygoogle ).push({); Pre-requisites: 1. Android Studio installed on your PC (Unix or Windows). You can learn how to install it here. 2. A real time android device (Smartphone or Tablet) configured with Android Studio.. Creating new project 1. Open Android Studio and create a new project JSONParser and company domain application.example.com (We have used our company domain i.e androidtutorialpoint.com. Similarly you can use yours). 2. Click Next and choose Min SDK, we have kept the default value. Again Click Next and Choose Blank Activity. 3. Name the Activity JSONParseActivity and click next. 4. Leave all other things as default and Click Finish. A new project will be created and gradle will resolve all the dependencies. Next create a mobile class. Mobile class represents the model of a mobile I.e it contains all the fields and methods (getter and setter) required by a Mobile. So create a new Java class Mobile. and put following code in it. Mobile. package com.androidtutorialpoint.jsonparser; import.io.serializable; public class Mobile implements Serializable{ private String mname; private String mcompanyname; 3 / 22

4 private String moperatingsystem; private String mprocessor; private String mram; private String mrom; private String mfrontcamera; private String mbackcamera; private String mscreensize; private String mbattery; private String murl; public String getname() { return mname; public void setname(string mname) { this.mname = mname; public String getcompanyname() { return mcompanyname; public void setcompanyname(string mcompanyname) { this.mcompanyname = mcompanyname; public String getoperatingsystem() { return moperatingsystem; public void setoperatingsystem(string moperatingsystem) { this.moperatingsystem = moperatingsystem; public String getprocessor() { return mprocessor; public void setprocessor(string mprocessor) { this.mprocessor = mprocessor; public String getram() { return mram; public void setram(string mram) { this.mram = mram; public String getrom() { return mrom; public void setrom(string mrom) { this.mrom = mrom; public String getfrontcamera() { 4 / 22

5 return mfrontcamera; public void setfrontcamera(string mfrontcamera) { this.mfrontcamera = mfrontcamera; public String getbackcamera() { return mbackcamera; public void setbackcamera(string mbackcamera) { this.mbackcamera = mbackcamera; public String getscreensize() { return mscreensize; public void setscreensize(string mscreensize) { this.mscreensize = mscreensize; public String getbattery() { return mbattery; public void setbattery(string mbattery) { this.mbattery = mbattery; public String geturl() { return murl; public void seturl(string murl) { this.murl = murl; We are implementing Serializable interface as we will be passing Mobile object from one Activity to other. Next create two function parsefeed() and parsearrayfeed() to parse the JSONObject and JSONArray respectively. While parsing the JSON response we might get an org.json.jsonexception so we will write the parsing logic in a try/catch block. parsefeed() takes JSONObject as a parameter and sets all the attribute of the mobile object. JSONParser. package com.androidtutorialpoint.jsonparser; import org.json.jsonarray; import org.json.jsonexception; 5 / 22

6 import org.json.jsonobject; import.util.arraylist; public class JSONParser { public static ArrayList<Mobile> mmobiles = new ArrayList<>(); public static Mobile parsefeed(jsonobject obj) { try { Mobile mobile = new Mobile(); mobile.setname(obj.getstring("name")); mobile.setcompanyname(obj.getstring("companyname")); mobile.setoperatingsystem(obj.getstring("operatingsystem")); mobile.setprocessor(obj.getstring("processor")); mobile.setbackcamera(obj.getstring("backcamera")); mobile.setfrontcamera(obj.getstring("frontcamera")); mobile.setram(obj.getstring("ram")); mobile.setrom(obj.getstring("rom")); mobile.setscreensize(obj.getstring("screensize")); mobile.seturl(obj.getstring("url")); mobile.setbattery(obj.getstring("battery")); return mobile; catch (JSONException e1) { e1.printstacktrace(); return null; parsearrayfeed() takes JSONArray as a parameter and returns an ArrayList of Mobile. JSONParser. public static ArrayList<Mobile> parsearrayfeed(jsonarray arr) { JSONObject obj=null; Mobile mobile = null; mmobiles.clear(); try { for(int i = 0;i<arr.length();i++) { obj = arr.getjsonobject(i); mobile= new Mobile(); mobile.setname(obj.getstring("name")); mobile.setcompanyname(obj.getstring("companyname")); mobile.setoperatingsystem(obj.getstring("operatingsystem")); mobile.setprocessor(obj.getstring("processor")); 6 / 22

7 mobile.setbackcamera(obj.getstring("backcamera")); mobile.setfrontcamera(obj.getstring("frontcamera")); mobile.setram(obj.getstring("ram")); mobile.setrom(obj.getstring("rom")); mobile.setscreensize(obj.getstring("screensize")); mobile.seturl(obj.getstring("url")); mobile.setbattery(obj.getstring("battery")); mmobiles.add(mobile); return mmobiles; catch (JSONException e1) { e1.printstacktrace(); return null; Open AndroidManifest. and put the following code, always remember to change the package name according to your company domain. We have added the android.permission.internet since we will be requesting JSON Data over Network. AndroidManifest. <? version="1.0" encoding="utf-8"?> <manifest ns:android=" package="com.androidtutorialpoint.jsonparser" > <uses-permission android:name="android.permission.internet"/> <application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsrtl="true" android:theme="@style/apptheme" > <activity android:name=".jsonparseactivity" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <activity android:name=".parsejsonarray" > </activity> <activity android:name=".parsejsonobject" > </activity> 7 / 22

8 <activity android:name=".parsejsonarrayobject" > </activity> </application> </manifest> We create an activity JSONParseActivity which consist of two Buttons to decide whether to decode a JSONObject or a JSONArray as shown. Put following code in JSONParseActivity: JSONParseActivity. package com.androidtutorialpoint.jsonparser; import android.content.intent; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.view.view; import android.widget.button; public class JSONParseActivity extends AppCompatActivity { private Button button_getjsonobject; private Button button_getjsonarray; private final String EXTRA_JSON_OBJECT_INDEX = "com.androidtutorialpoint.jsonparser"; protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_jsonparse); button_getjsonobject = (Button) findviewbyid(r.id.button_jsonobject); button_getjsonarray = (Button) findviewbyid(r.id.button_jsonarray); button_getjsonobject.setonclicklistener(new View.OnClickListener() { public void onclick(view v) { Intent i = new Intent(getApplication(), ParseJSONObject.class); i.putextra(extra_json_object_index, 0); startactivity(i); ); button_getjsonarray.setonclicklistener(new View.OnClickListener() { 8 / 22

9 public void onclick(view v) { Intent i = new Intent(getApplication(), ParseJSONArray.class); startactivity(i); ); In above activity we have defined setonclicklistener for the two buttons and we are calling ParseJSONObject. and ParseJSONArray. on clicking them respectively.following is Layout file for JSONParseActivity: activity_jsonparse. <? version="1.0" encoding="utf-8"?> <LinearLayout ns:android=" ns:tools=" android:orientation="vertical" android:layout_height="match_parent" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:paddingbottom="@dimen/activity_vertical_margin" tools:context=".mainactivity" android:gravity="center"> <Button android:id="@+id/button_jsonobject" android:text="parse JSONObject!!!"/> <Button android:id="@+id/button_jsonarray" android:text="parse JSONArray!!!"/> </LinearLayout> Let's first talk about ParseJSONObject.. This activity shows the details of the mobile retrieved from the MobileJSONObject URL and shows all the specs of the mobile along with the image. Create a Java Class ParseJSONObject. and paste the following code. ParseJSONObject. 9 / 22

10 package com.androidtutorialpoint.jsonparser; import android.app.activity; import android.app.progressdialog; import android.os.bundle; import android.support.v7.app.appcompatactivity; import android.util.log; import android.widget.imageview; import android.widget.textview; import android.widget.textview; import com.android.volley.request.method; import com.android.volley.response; import com.android.volley.volleyerror; import com.android.volley.volleylog; import com.android.volley.toolbox.imageloader; import com.android.volley.toolbox.jsonobjectrequest; import com.android.volley.toolbox.volley; import org.json.jsonobject; public class ParseJSONObject extends AppCompatActivity { private static final String TAG ="ParseJSONObject"; private final String EXTRA_JSON_OBJECT_INDEX = "com.androidtutorialpoint.jsonparser"; private Mobile mmobile; private TextView nametextview; private TextView companynametextview; private TextView operatingsystemtextview; private TextView processortextview; private TextView ramtextview; private TextView romtextview; private TextView frontcameratextview; private TextView backcameratextview; private TextView screensizetextview; private TextView batterytextview; private ImageView photoimageview; private String photourl; String url = " protected void oncreate(bundle savedinstancestate) { 10 / 22

11 super.oncreate(savedinstancestate); setcontentview(r.layout.activity_parsejsonobject); nametextview =(TextView)findViewById(R.id.edit_text_name); companynametextview =(TextView)findViewById(R.id.edit_text_company_name); operatingsystemtextview =(TextView)findViewById(R.id.edit_text_operating_system); processortextview = (TextView)findViewById(R.id.edit_text_processor); ramtextview = (TextView)findViewById(R.id.edit_text_ram); romtextview = (TextView)findViewById(R.id.edit_text_rom); frontcameratextview = (TextView)findViewById(R.id.edit_text_front_camera); backcameratextview = (TextView)findViewById(R.id.edit_text_back_camera); screensizetextview = (TextView)findViewById(R.id.edit_text_screen_size); batterytextview = (TextView)findViewById(R.id.edit_text_battery); photoimageview = (ImageView)findViewById(R.id.image_view_mobile_picture); final ProgressDialog pdialog = new ProgressDialog(ParseJSONObject.this); pdialog.setmessage("loading..."); pdialog.show(); JsonObjectRequest jsonobjreq = new JsonObjectRequest(Method.GET,url, null,new Response.Listener<JSONObject>() { public void onresponse(jsonobject response) { mmobile = JSONParser.parseFeed(response); nametextview.settext("name :" + mmobile.getname()); companynametextview.settext("company :" + mmobile.getcompanyname()); operatingsystemtextview.settext(" OS :" + mmobile.getoperatingsystem()); processortextview.settext("processor :" + mmobile.getprocessor()); ramtextview.settext("ram :"+mmobile.getram()); romtextview.settext("memory :"+mmobile.getrom()); frontcameratextview.settext("front Camera :"+mmobile.getfrontcamera()); backcameratextview.settext("rear Camera :"+mmobile.getbackcamera()); screensizetextview.settext("screen Size :"+mmobile.getscreensize()); batterytextview.settext("battery :"+mmobile.getbattery()); photourl = (mmobile.geturl()); ImageLoader imageloader = new ImageLoader(Volley.newRequestQueue(getApplicationContext()), new LruBitmapCache()); // If you are using normal ImageView imageloader.get(photourl, new ImageLoader.ImageListener() { 11 / 22

12 public void onerrorresponse(volleyerror error) { Log.e(TAG, "Image Load Error: " + error.getmessage()); public void onresponse(imageloader.imagecontainer response, boolean arg1) { if (response.getbitmap()!= null) { // load image into imageview photoimageview.setimagebitmap(response.getbitmap()); pdialog.hide(); ); Log.d(TAG, response.tostring());, new Response.ErrorListener() { public void onerrorresponse(volleyerror error) { VolleyLog.d(TAG, "Error: " + error.getmessage()); // hide the progress dialog pdialog.hide(); ); // Adding request to request queue Volley.newRequestQueue(getApplicationContext()).add(jsonObjReq); The code is very simple. 1. We are referencing the layout elements in the OnCreate() method. 2. Then, We are submitting a network request using Volley Library to get the JSON response from the URL. To know more about how to use Volley Library, refer to the following tutorial => Android Volley Tutorial 3. On getting the response from the network request we are calling the JSON Parser and then setting the values for the TextView and ImageView widget. The Layout for the above activity is as follows: activity_parsejsonobject. 12 / 22

13 <? version="1.0" encoding="utf-8"?> <ScrollView android:layout_height="match_parent" ns:android=" > <LinearLayout ns:android=" ns:tools=" android:layout_height="match_parent" android:orientation="vertical" android:scrollbars="vertical" tools:context=".mainactivity" android:gravity="center"> <ImageView android:layout_width="200dp" android:layout_height="200dp" /> <TextView android:text="model :" android:layout_margintop="16dp" android:layout_centerhorizontal="true" /> <TextView android:text="company :" android:layout_margintop="16dp" android:layout_centerhorizontal="true" /> <TextView android:text="os :" android:layout_margintop="16dp" android:layout_centerhorizontal="true" /> 13 / 22

14 <TextView android:text="processor :" android:layout_margintop="16dp" android:layout_centerhorizontal="true" /> <TextView android:text="ram :" android:layout_margintop="16dp" android:layout_centerhorizontal="true" /> <TextView android:text="memory :" android:layout_margintop="16dp" android:layout_centerhorizontal="true" /> <TextView android:text="front Camera :" android:layout_margintop="16dp" android:layout_centerhorizontal="true" /> <TextView android:text="rear Camera :" android:layout_margintop="16dp" android:layout_centerhorizontal="true" /> <TextView android:text="screen Size :" android:layout_margintop="16dp" 14 / 22

15 android:layout_centerhorizontal="true" /> <TextView android:text="battery :" android:layout_margintop="16dp" android:layout_centerhorizontal="true" /> </LinearLayout> </ScrollView> Layout is also pretty simple we have LinearLayout enclosed within a ScrollView to allow scrolling.we have an ImageView and some TextView's as a child of the LinearLayout to show info about Mobile. Next create a Java class ParseJSONArray to host a Fragment that will list the mobile phones from JSON Array URL. Put following code in it: ParseJSONArray. package com.androidtutorialpoint.jsonparser; import android.os.bundle; import android.support.v4.app.fragment; import android.support.v4.app.fragmentmanager; import android.support.v7.app.appcompatactivity; public class ParseJSONArray extends AppCompatActivity { protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_parsejsonarray); FragmentManager fm = getsupportfragmentmanager(); Fragment fragment = fm.findfragmentbyid(r.id.fragmentcontainer); if (fragment == null) { fragment = new ListMobiles(); fm.begintransaction().add(r.id.fragmentcontainer, fragment).commit(); Create a layout resource file for ParseJsonArray activity. It consists of just a FrameLayout that will act as 15 / 22

16 a container for the Fragment activity_parsejsonarray. <? version="1.0" encoding="utf-8"?> <FrameLayout ns:android=" android:layout_height="match_parent" android:paddingbottom="50dp" /> Create a Java class ListMobiles that will display the list of mobiles. ListMobiles. package com.androidtutorialpoint.jsonparser; import android.app.progressdialog; import android.content.context; import android.content.intent; import android.os.bundle; import android.support.v4.app.fragment; import android.support.v4.app.listfragment; import android.util.log; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.arrayadapter; import android.widget.gridview; import android.widget.imageview; import android.widget.textview; import com.android.volley.response; import com.android.volley.volleyerror; import com.android.volley.volleylog; import com.android.volley.toolbox.jsonarrayrequest; import com.android.volley.toolbox.volley; 16 / 22

17 import org.json.jsonarray; import.util.arraylist; public class ListMobiles extends ListFragment { private final String TAG = "ListMobiles"; private ArrayList<Mobile> mmobilelist; String url = " private final String EXTRA_JSON_OBJECT = "mobileobject"; public void oncreate(bundle savedinstancestate){ super.oncreate(savedinstancestate); final ProgressDialog pdialog = new ProgressDialog(getActivity()); pdialog.setmessage("loading..."); pdialog.show(); JsonArrayRequest jsonarrayreq = new JsonArrayRequest(url, new Response.Listener<JSONArray>() { public void onresponse(jsonarray response) { Log.d(TAG,response.toString()); Log.d(TAG,"Len "+response.length()); mmobilelist = JSONParser.parseArrayFeed(response); pdialog.hide(); MobileAdapter adapter = new MobileAdapter(mMobileList); setlistadapter(adapter);, new Response.ErrorListener() { public void onerrorresponse(volleyerror error) { VolleyLog.d(TAG, "Error: " + error.getmessage()); // hide the progress dialog pdialog.hide(); ); // Adding request to request queue Volley.newRequestQueue(getActivity()).add(jsonArrayReq); private class MobileAdapter extends ArrayAdapter<Mobile> { public MobileAdapter(ArrayList<Mobile> mobiles) { super(getactivity(), 0, mobiles); 17 / 22

18 public View getview(final int position, View convertview, ViewGroup parent) { // If we weren't given a view, inflate one Log.d(TAG,"pos "+position); if (convertview == null) { convertview = getactivity().getlayoutinflater().inflate(r.layout.category_list_item_1, null); Mobile c = mmobilelist.get(position); TextView nametextview = (TextView) convertview.findviewbyid(r.id.textview_name); nametextview.settext(c.getname()); nametextview.setonclicklistener(new View.OnClickListener() { public void onclick(view v) { Intent i = new Intent(getActivity(),ParseJSONArrayObject.class); Bundle args = new Bundle(); //args.putserializable(extra_json_mobile_object, mmobilelist.get(position)); i.putextra(extra_json_object, mmobilelist.get(position)); startactivity(i); ); return convertview; In the Above code we have created a custom ArrayAdapter for listing Mobiles: 1. First we Override getview() method, in which we inflate category_list_item_1. file which we will be showing soon. Then we get Mobile item at corresponding position from the mmobilelist and return the View. 2. We have also created an OnClickListener that will start the ParseJSONArrayObject class and pass it the mobile phone you have clicked. We will be talking about this class shortly. 3. In the oncreate method we do a Network request through Volley Library to get the JSONArray Request from the JSONArray URL.On receiving the response we parse it to get MobileList and then set the MobileAdapter on it. We will be inflating following layout to show the entries. So create a layout resource file category_list_item_1..to avoid complexity we have kept this layout and we are just using a TextView inside a LinearLayout. 18 / 22

19 category_list_item_1. <? version="1.0" encoding="utf-8"?> <LinearLayout ns:android=" ns:tools=" android:layout_height="match_parent" android:orientation="vertical" android:gravity="center"> <TextView ns:android=" android:padding="10dp" android:textstyle="bold" ></TextView> </LinearLayout> Now let's talk about the ParseJSONArrayObject class which get's called on clicking an item in the MobileList. Create a class ParseJSONArrayObject and put following code. ParseJSONArrayObject. package com.androidtutorialpoint.jsonparser; import android.app.progressdialog; import android.os.bundle; import android.support.v7.app.appcompatactivity; import android.util.log; import android.widget.imageview; import android.widget.textview; import com.android.volley.volleyerror; import com.android.volley.toolbox.imageloader; import com.android.volley.toolbox.volley; public class ParseJSONArrayObject extends AppCompatActivity{ private static final String TAG ="ParseJSONObject"; private Mobile mmobile; private TextView nametextview; private TextView companynametextview; private TextView operatingsystemtextview; private TextView processortextview; private TextView ramtextview; private TextView romtextview; private TextView frontcameratextview; 19 / 22

20 private TextView backcameratextview; private TextView screensizetextview; private TextView batterytextview; private ImageView photoimageview; private String photourl; private final String EXTRA_JSON_OBJECT = "mobileobject"; protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_parsejsonobject); mmobile = (Mobile)getIntent().getSerializableExtra(EXTRA_JSON_OBJECT); nametextview =(TextView)findViewById(R.id.edit_text_name); companynametextview =(TextView)findViewById(R.id.edit_text_company_name); operatingsystemtextview =(TextView)findViewById(R.id.edit_text_operating_system); processortextview = (TextView)findViewById(R.id.edit_text_processor); ramtextview = (TextView)findViewById(R.id.edit_text_ram); romtextview = (TextView)findViewById(R.id.edit_text_rom); frontcameratextview = (TextView)findViewById(R.id.edit_text_front_camera); backcameratextview = (TextView)findViewById(R.id.edit_text_back_camera); screensizetextview = (TextView)findViewById(R.id.edit_text_screen_size); batterytextview = (TextView)findViewById(R.id.edit_text_battery); photoimageview = (ImageView)findViewById(R.id.image_view_mobile_picture); final ProgressDialog pdialog = new ProgressDialog(ParseJSONArrayObject.this); pdialog.setmessage("loading..."); pdialog.show(); nametextview.settext("name :" + mmobile.getname()); companynametextview.settext("company :" + mmobile.getcompanyname()); operatingsystemtextview.settext(" OS :" + mmobile.getoperatingsystem()); processortextview.settext("processor :" + mmobile.getprocessor()); ramtextview.settext("ram :"+mmobile.getram()); romtextview.settext("memory :"+mmobile.getrom()); frontcameratextview.settext("front Camera :"+mmobile.getfrontcamera()); backcameratextview.settext("rear Camera :"+mmobile.getbackcamera()); screensizetextview.settext("screen Size :"+mmobile.getscreensize()); batterytextview.settext("battery :"+mmobile.getbattery()); photourl = (mmobile.geturl()); ImageLoader imageloader = new ImageLoader(Volley.newRequestQueue(getApplicationContext()), new LruBitmapCache()); imageloader.get(photourl, new ImageLoader.ImageListener() { public void onerrorresponse(volleyerror error) { Log.e(TAG, "Image Load Error: " + error.getmessage()); public void onresponse(imageloader.imagecontainer response, boolean arg1) { if (response.getbitmap()!= null) { 20 / 22

21 // load image into imageview photoimageview.setimagebitmap(response.getbitmap()); pdialog.hide(); ); This Activity is similar to ParseJSONObject Activity however here we are receiving the Mobile Object in a Bundle. In the oncreate method: 1. We extract the Mobile Object from the intent. 2. Reference the Layout elements from the Layout. 3. Finally we set the TextView and create a network request for setting the ImageView Additionally create the new class LruBitmapCache.. This class is used as cache for Image Loader in Volley, For more details please refer to our Volley Tutorial -> Android Volley Tutorial LruBitmapCache. package com.androidtutorialpoint.jsonparser; import android.graphics.bitmap; import android.support.v4.util.lrucache; import com.android.volley.toolbox.imageloader.imagecache; public class LruBitmapCache extends LruCache<String, Bitmap> implements ImageCache { public static int getdefaultlrucachesize() { final int maxmemory = (int) (Runtime.getRuntime().maxMemory() / 1024); final int cachesize = maxmemory / 8; return cachesize; public LruBitmapCache() { this(getdefaultlrucachesize()); public LruBitmapCache(int sizeinkilobytes) { super(sizeinkilobytes); 21 / 22

22 Powered by TCPDF ( Android JSON Parsing Tutorial protected int sizeof(string key, Bitmap value) { return value.getrowbytes() * value.getheight() / 1024; public Bitmap getbitmap(string url) { return get(url); public void putbitmap(string url, Bitmap bitmap) { put(url, bitmap); Now run the app on an Android Device or an Emulator, Do remember to turn on the Internet using Wifi or mobile data, since we have not added any logic to Check for Internet Connection in our android app. And that's pretty much it. We hope now you get the complete idea of JSON Parsing in android. Please comment if you have any doubts or suggestions. (adsbygoogle = window.adsbygoogle ).push({); What's Next? Check our other tutorial, and create cool apps. Don't forget to subscribe our blog for latest android tutorials. Also Like our Facebook Page or Add us on Twitter. Click on the Download Now button to download the full code. PDF generated by Kalin's PDF Creation Station 22 / 22

Android Volley Tutorial

Android Volley Tutorial Android Volley Tutorial by Kapil - Monday, May 16, 2016 http://www.androidtutorialpoint.com/networking/android-volley-tutorial/ YouTube Video Volley is an HTTP library developed by Google to ease networking

More information

Android CardView Tutorial

Android CardView Tutorial Android CardView Tutorial by Kapil - Wednesday, April 13, 2016 http://www.androidtutorialpoint.com/material-design/android-cardview-tutorial/ YouTube Video We have already discussed about RecyclerView

More information

Android - JSON Parser Tutorial

Android - JSON Parser Tutorial Android - JSON Parser Tutorial JSON stands for JavaScript Object Notation.It is an independent data exchange format and is the best alternative for XML. This chapter explains how to parse the JSON file

More information

Fragment Example Create the following files and test the application on emulator or device.

Fragment Example Create the following files and test the application on emulator or device. Fragment Example Create the following files and test the application on emulator or device. File: AndroidManifest.xml

More information

Android Navigation Drawer for Sliding Menu / Sidebar

Android Navigation Drawer for Sliding Menu / Sidebar Android Navigation Drawer for Sliding Menu / Sidebar by Kapil - Tuesday, December 15, 2015 http://www.androidtutorialpoint.com/material-design/android-navigation-drawer-for-sliding-menusidebar/ YouTube

More information

MAD ASSIGNMENT NO 3. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept.

MAD ASSIGNMENT NO 3. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept. MAD ASSIGNMENT NO 3 Submitted by: Rehan Asghar BSSE 7 15126 AUGUST 25, 2017 SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept. MainActivity.java File package com.example.tutorialspoint; import android.manifest;

More information

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Switching UIs

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Switching UIs EMBEDDED SYSTEMS PROGRAMMING 2015-16 Application Tip: Switching UIs THE PROBLEM How to switch from one UI to another Each UI is associated with a distinct class that controls it Solution shown: two UIs,

More information

M.A.D ASSIGNMENT # 2 REHAN ASGHAR BSSE 15126

M.A.D ASSIGNMENT # 2 REHAN ASGHAR BSSE 15126 M.A.D ASSIGNMENT # 2 REHAN ASGHAR BSSE 15126 Submitted to: Sir Waqas Asghar MAY 23, 2017 SUBMITTED BY: REHAN ASGHAR Intent in Android What are Intent? An Intent is a messaging object you can use to request

More information

Tabel mysql. Kode di PHP. Config.php. Service.php

Tabel mysql. Kode di PHP. Config.php. Service.php Tabel mysql Kode di PHP Config.php Service.php Layout Kode di Main Activity package com.example.mini.webandroid; import android.app.progressdialog; import android.os.asynctask; import android.support.v7.app.appcompatactivity;

More information

CSE 660 Lab 7. Submitted by: Arumugam Thendramil Pavai. 1)Simple Remote Calculator. Server is created using ServerSocket class of java. Server.

CSE 660 Lab 7. Submitted by: Arumugam Thendramil Pavai. 1)Simple Remote Calculator. Server is created using ServerSocket class of java. Server. CSE 660 Lab 7 Submitted by: Arumugam Thendramil Pavai 1)Simple Remote Calculator Server is created using ServerSocket class of java Server.java import java.io.ioexception; import java.net.serversocket;

More information

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation EMBEDDED SYSTEMS PROGRAMMING 2016-17 Application Tip: Managing Screen Orientation ORIENTATIONS Portrait Landscape Reverse portrait Reverse landscape ON REVERSE PORTRAIT Android: all four orientations are

More information

LAMPIRAN. byte bcdtodec(byte val) { return( (val/16*10) + (val%16) ); } void setup() {

LAMPIRAN. byte bcdtodec(byte val) { return( (val/16*10) + (val%16) ); } void setup() { 60 LAMPIRAN 1. Source code Arduino. #include "Wire.h" #include #include #define DS3231_I2C_ADDRESS 0x68 SoftwareSerial sim800l(11, 10); int dline[28]; byte *cacah=0; String

More information

Basic GUI elements - exercises

Basic GUI elements - exercises Basic GUI elements - exercises https://developer.android.com/studio/index.html LIVE DEMO Please create a simple application, which will be used to calculate the area of basic geometric figures. To add

More information

Mobile Application Development Lab [] Simple Android Application for Native Calculator. To develop a Simple Android Application for Native Calculator.

Mobile Application Development Lab [] Simple Android Application for Native Calculator. To develop a Simple Android Application for Native Calculator. Simple Android Application for Native Calculator Aim: To develop a Simple Android Application for Native Calculator. Procedure: Creating a New project: Open Android Stdio and then click on File -> New

More information

CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015

CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015 CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015 Comment and Evaluation: This lab introduces us about Android SDK and how to write a program for Android platform. The calculator is pretty easy, everything

More information

Create a local SQL database hosting a CUSTOMER table. Each customer includes [id, name, phone]. Do the work inside Threads and Asynctasks.

Create a local SQL database hosting a CUSTOMER table. Each customer includes [id, name, phone]. Do the work inside Threads and Asynctasks. CIS 470 Lesson 13 Databases - Quick Notes Create a local SQL database hosting a CUSTOMER table. Each customer includes [id, name, phone]. Do the work inside Threads and Asynctasks. package csu.matos; import

More information

SMAATSDK. NFC MODULE ON ANDROID REQUIREMENTS AND DOCUMENTATION RELEASE v1.0

SMAATSDK. NFC MODULE ON ANDROID REQUIREMENTS AND DOCUMENTATION RELEASE v1.0 SMAATSDK NFC MODULE ON ANDROID REQUIREMENTS AND DOCUMENTATION RELEASE v1.0 NFC Module on Android Requirements and Documentation Table of contents Scope...3 Purpose...3 General operating diagram...3 Functions

More information

Intents. Your first app assignment

Intents. Your first app assignment Intents Your first app assignment We will make this. Decidedly lackluster. Java Code Java Code XML XML Preview XML Java Code Java Code XML Buttons that work

More information

<uses-permission android:name="android.permission.internet"/>

<uses-permission android:name=android.permission.internet/> Chapter 11 Playing Video 11.1 Introduction We have discussed how to play audio in Chapter 9 using the class MediaPlayer. This class can also play video clips. In fact, the Android multimedia framework

More information

LAMPIRAN PROGRAM. public class ListArrayAdapterPost extends ArrayAdapter<ModelDataPost> {

LAMPIRAN PROGRAM. public class ListArrayAdapterPost extends ArrayAdapter<ModelDataPost> { 1 LAMPIRAN PROGRAM JAVA ListArrayAdapterPost.java package com.example.win.api.adapter; import android.content.context; import android.support.annotation.nonnull; import android.view.layoutinflater; import

More information

PROGRAMMING APPLICATIONS DECLARATIVE GUIS

PROGRAMMING APPLICATIONS DECLARATIVE GUIS PROGRAMMING APPLICATIONS DECLARATIVE GUIS DIVING RIGHT IN Eclipse? Plugin deprecated :-( Making a new project This keeps things simple or clone or clone or clone or clone or clone or clone Try it

More information

EMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches

EMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches EMBEDDED SYSTEMS PROGRAMMING 2016-17 UI Specification: Approaches UIS: APPROACHES Programmatic approach: UI elements are created inside the application code Declarative approach: UI elements are listed

More information

Android development. Outline. Android Studio. Setting up Android Studio. 1. Set up Android Studio. Tiberiu Vilcu. 2.

Android development. Outline. Android Studio. Setting up Android Studio. 1. Set up Android Studio. Tiberiu Vilcu. 2. Outline 1. Set up Android Studio Android development Tiberiu Vilcu Prepared for EECS 411 Sugih Jamin 15 September 2017 2. Create sample app 3. Add UI to see how the design interface works 4. Add some code

More information

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State EMBEDDED SYSTEMS PROGRAMMING 2016-17 Application Tip: Saving State THE PROBLEM How to save the state (of a UI, for instance) so that it survives even when the application is closed/killed The state should

More information

Arrays of Buttons. Inside Android

Arrays of Buttons. Inside Android Arrays of Buttons Inside Android The Complete Code Listing. Be careful about cutting and pasting.

More information

Android Workshop: Model View Controller ( MVC):

Android Workshop: Model View Controller ( MVC): Android Workshop: Android Details: Android is framework that provides java programmers the ability to control different aspects of smart devices. This interaction happens through the Android SDK (Software

More information

Diving into Android. By Jeroen Tietema. Jeroen Tietema,

Diving into Android. By Jeroen Tietema. Jeroen Tietema, Diving into Android By Jeroen Tietema Jeroen Tietema, 2015 1 Requirements 4 Android SDK 1 4 Android Studio (or your IDE / editor of choice) 4 Emulator (Genymotion) or a real device. 1 See https://developer.android.com

More information

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 2

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 2 Workshop 1. Compare different layout by using Change Layout button (Page 1 5) Relative Layout Linear Layout (Horizontal) Linear Layout (Vertical) Frame Layout 2. Revision on basic programming skill - control

More information

EMBEDDED SYSTEMS PROGRAMMING Application Basics

EMBEDDED SYSTEMS PROGRAMMING Application Basics EMBEDDED SYSTEMS PROGRAMMING 2015-16 Application Basics APPLICATIONS Application components (e.g., UI elements) are objects instantiated from the platform s frameworks Applications are event driven ( there

More information

Lampiran Program : Res - Layout Activity_main.xml

More information

Fragments. Lecture 11

Fragments. Lecture 11 Fragments Lecture 11 Situational layouts Your app can use different layouts in different situations Different device type (tablet vs. phone vs. watch) Different screen size Different orientation (portrait

More information

Practical 1.ListView example

Practical 1.ListView example Practical 1.ListView example In this example, we show you how to display a list of fruit name via ListView. Android Layout file File : res/layout/list_fruit.xml

More information

LAMPIRAN PROGRAM. public class Listdata_adiktif extends ArrayAdapter<ModelData_adiktif> {

LAMPIRAN PROGRAM. public class Listdata_adiktif extends ArrayAdapter<ModelData_adiktif> { 1 LAMPIRAN PROGRAM JAVA Listdata_adiktif.java package com.example.win.api.adapter; import android.content.context; import android.support.annotation.nonnull; import android.view.layoutinflater; import

More information

PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE)

PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE) PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE) Network Connection Web Service K Candra Brata andra.course@gmail.com Mobille App Lab 2015-2016 Network Connection http://developer.android.com/training/basics/network-ops/connecting.html

More information

Android Application Model I

Android Application Model I Android Application Model I CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr. Rajiv Ramnath Reading: Big Nerd Ranch Guide, Chapters 3, 5 (Activities);

More information

Android UI Development

Android UI Development Android UI Development Android UI Studio Widget Layout Android UI 1 Building Applications A typical application will include: Activities - MainActivity as your entry point - Possibly other activities (corresponding

More information

Vienos veiklos būsena. Theory

Vienos veiklos būsena. Theory Vienos veiklos būsena Theory While application is running, we create new Activities and close old ones, hide the application and open it again and so on, and Activity can process all these events. It is

More information

Mobile Computing Fragments

Mobile Computing Fragments Fragments APM@FEUP 1 Fragments (1) Activities are used to define a full screen interface and its functionality That s right for small screen devices (smartphones) In bigger devices we can have more interface

More information

EMBEDDED SYSTEMS PROGRAMMING Android Services

EMBEDDED SYSTEMS PROGRAMMING Android Services EMBEDDED SYSTEMS PROGRAMMING 2016-17 Android Services APP COMPONENTS Activity: a single screen with a user interface Broadcast receiver: responds to system-wide broadcast events. No user interface Service:

More information

Applied Cognitive Computing Fall 2016 Android Application + IBM Bluemix (Cloudant NoSQL DB)

Applied Cognitive Computing Fall 2016 Android Application + IBM Bluemix (Cloudant NoSQL DB) Applied Cognitive Computing Fall 2016 Android Application + IBM Bluemix (Cloudant NoSQL DB) In this exercise, we will create a simple Android application that uses IBM Bluemix Cloudant NoSQL DB. The application

More information

Android SQLite Database Tutorial - CRUD Operations

Android SQLite Database Tutorial - CRUD Operations Android SQLite Database Tutorial - CRUD Operations by Kapil - Monday, March 21, 2016 http://www.androidtutorialpoint.com/storage/android-sqlite-database-tutorial/ YouTube Video Android SQLite Introduction

More information

Android Application Model I. CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr.

Android Application Model I. CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr. Android Application Model I CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr. Rajiv Ramnath 1 Framework Support (e.g. Android) 2 Framework Capabilities

More information

COMP61242: Task /04/18

COMP61242: Task /04/18 COMP61242: Task 2 1 16/04/18 1. Introduction University of Manchester School of Computer Science COMP61242: Mobile Communications Semester 2: 2017-18 Laboratory Task 2 Messaging with Android Smartphones

More information

Create Parent Activity and pass its information to Child Activity using Intents.

Create Parent Activity and pass its information to Child Activity using Intents. Create Parent Activity and pass its information to Child Activity using Intents. /* MainActivity.java */ package com.example.first; import android.os.bundle; import android.app.activity; import android.view.menu;

More information

Coding Menggunakan software Eclipse: Mainactivity.java (coding untuk tampilan login): package com.bella.pengontrol_otomatis;

Coding Menggunakan software Eclipse: Mainactivity.java (coding untuk tampilan login): package com.bella.pengontrol_otomatis; Coding Menggunakan software Eclipse: Mainactivity.java (coding untuk tampilan login): package com.bella.pengontrol_otomatis; import android.app.activity; import android.os.bundle; import android.os.countdowntimer;

More information

Creating a Custom ListView

Creating a Custom ListView Creating a Custom ListView References https://developer.android.com/guide/topics/ui/declaring-layout.html#adapterviews Overview The ListView in the previous tutorial creates a TextView object for each

More information

Statistics http://www.statista.com/topics/840/smartphones/ http://www.statista.com/topics/876/android/ http://www.statista.com/statistics/271774/share-of-android-platforms-on-mobile-devices-with-android-os/

More information

MAD ASSIGNMENT NO 2. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept.

MAD ASSIGNMENT NO 2. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept. MAD ASSIGNMENT NO 2 Submitted by: Rehan Asghar BSSE 7 15126 AUGUST 25, 2017 SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept. Android Widgets There are given a lot of android widgets with simplified

More information

Manifest.xml. Activity.java

Manifest.xml. Activity.java Dr.K.Somasundaram Ph.D Professor Department of Computer Science and Applications Gandhigram Rural Institute, Gandhigram, Tamil Nadu-624302, India ka.somasundaram@gmail.com Manifest.xml

More information

Software Practice 3 Before we start Today s lecture Today s Task Team organization

Software Practice 3 Before we start Today s lecture Today s Task Team organization 1 Software Practice 3 Before we start Today s lecture Today s Task Team organization Prof. Hwansoo Han T.A. Jeonghwan Park 43 2 Lecture Schedule Spring 2017 (Monday) This schedule can be changed M A R

More information

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar Mobile Application Development Higher Diploma in Science in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology

More information

Mobile Software Development for Android - I397

Mobile Software Development for Android - I397 1 Mobile Software Development for Android - I397 IT COLLEGE, ANDRES KÄVER, 2015-2016 EMAIL: AKAVER@ITCOLLEGE.EE WEB: HTTP://ENOS.ITCOLLEGE.EE/~AKAVER/2015-2016/DISTANCE/ANDROID SKYPE: AKAVER Timetable

More information

LifeStreet Media Android Publisher SDK Integration Guide

LifeStreet Media Android Publisher SDK Integration Guide LifeStreet Media Android Publisher SDK Integration Guide Version 1.12.0 Copyright 2015 Lifestreet Corporation Contents Introduction... 3 Downloading the SDK... 3 Choose type of SDK... 3 Adding the LSM

More information

Android Basics. Android UI Architecture. Android UI 1

Android Basics. Android UI Architecture. Android UI 1 Android Basics Android UI Architecture Android UI 1 Android Design Constraints Limited resources like memory, processing, battery à Android stops your app when not in use Primarily touch interaction à

More information

Android Coding. Dr. J.P.E. Hodgson. August 23, Dr. J.P.E. Hodgson () Android Coding August 23, / 27

Android Coding. Dr. J.P.E. Hodgson. August 23, Dr. J.P.E. Hodgson () Android Coding August 23, / 27 Android Coding Dr. J.P.E. Hodgson August 23, 2010 Dr. J.P.E. Hodgson () Android Coding August 23, 2010 1 / 27 Outline Starting a Project 1 Starting a Project 2 Making Buttons Dr. J.P.E. Hodgson () Android

More information

Android - Widgets Tutorial

Android - Widgets Tutorial Android - Widgets Tutorial A widget is a small gadget or control of your android application placed on the home screen. Widgets can be very handy as they allow you to put your favourite applications on

More information

Getting Started. Dr. Miguel A. Labrador Department of Computer Science & Engineering

Getting Started. Dr. Miguel A. Labrador Department of Computer Science & Engineering Getting Started Dr. Miguel A. Labrador Department of Computer Science & Engineering labrador@csee.usf.edu http://www.csee.usf.edu/~labrador 1 Goals Setting up your development environment Android Framework

More information

Appendix A : Android Studio Code For Android

Appendix A : Android Studio Code For Android Appendix A : Android Studio Code For Android Monitoring : ` public Pubnub pubnub; public static final String PUBLISH_KEY = "pub-c-798bd0f6-540b-48af-9e98-7d0028a5132a"; public static final String SUBSCRIBE_KEY

More information

Android Layout Types

Android Layout Types Android Layout Types Android Linear Layout Android LinearLayout is a view group that aligns all children in either vertically or horizontally. android:divider - This is drawable to use as a vertical divider

More information

Android/Java Lightning Tutorial JULY 30, 2018

Android/Java Lightning Tutorial JULY 30, 2018 Android/Java Lightning Tutorial JULY 30, 2018 Java Android uses java as primary language Resource : https://github.mit.edu/6178-2017/lec1 Online Tutorial : https://docs.oracle.com/javase/tutorial/java/nutsandbolts/inde

More information

Chapter 8 Positioning with Layouts

Chapter 8 Positioning with Layouts Introduction to Android Application Development, Android Essentials, Fifth Edition Chapter 8 Positioning with Layouts Chapter 8 Overview Create user interfaces in Android by defining resource files or

More information

Java & Android. Java Fundamentals. Madis Pink 2016 Tartu

Java & Android. Java Fundamentals. Madis Pink 2016 Tartu Java & Android Java Fundamentals Madis Pink 2016 Tartu 1 Agenda» Brief background intro to Android» Android app basics:» Activities & Intents» Resources» GUI» Tools 2 Android» A Linux-based Operating System»

More information

When programming in groups of people, it s essential to version the code. One of the most popular versioning tools is git. Some benefits of git are:

When programming in groups of people, it s essential to version the code. One of the most popular versioning tools is git. Some benefits of git are: ETSN05, Fall 2017, Version 1.0 Software Development of Large Systems Lab 2 preparations Read through this document carefully. In order to pass lab 2, you will need to understand the topics presented in

More information

Produced by. Mobile Application Development. Eamonn de Leastar

Produced by. Mobile Application Development. Eamonn de Leastar Mobile Application Development Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie A First

More information

Introduction. Who Should Read This Book. Key Topics That This Book Covers

Introduction. Who Should Read This Book. Key Topics That This Book Covers Introduction Android is Google s open source and free Java-based platform for mobile development. Tablets are getting more popular every day. They are gadgets that fall between smartphones and personal

More information

Getting Started With Android Feature Flags

Getting Started With Android Feature Flags Guide Getting Started With Android Feature Flags INTRO When it comes to getting started with feature flags (Android feature flags or just in general), you have to understand that there are degrees of feature

More information

Agenda. Overview of Xamarin and Xamarin.Android Xamarin.Android fundamentals Creating a detail screen

Agenda. Overview of Xamarin and Xamarin.Android Xamarin.Android fundamentals Creating a detail screen Gill Cleeren Agenda Overview of Xamarin and Xamarin.Android Xamarin.Android fundamentals Creating a detail screen Lists and navigation Navigating from master to detail Optimizing the application Preparing

More information

package import import import import import import import public class extends public void super new this class extends public super public void new

package import import import import import import import public class extends public void super new this class extends public super public void new Android 2-D Drawing Android uses a Canvas object to host its 2-D drawing methods. The program below draws a blue circle on a white canvas. It does not make use of the main.xml layout but draws directly

More information

User Interface Development in Android Applications

User Interface Development in Android Applications ITU- FAO- DOA- TRCSL Training on Innovation & Application Development for E- Agriculture User Interface Development in Android Applications 11 th - 15 th December 2017 Peradeniya, Sri Lanka Shahryar Khan

More information

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar Mobile Application Development Higher Diploma in Science in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology

More information

Wireless Vehicle Bus Adapter (WVA) Android Library Tutorial

Wireless Vehicle Bus Adapter (WVA) Android Library Tutorial Wireless Vehicle Bus Adapter (WVA) Android Library Tutorial Revision history 90001431-13 Revision Date Description A October 2014 Original release. B October 2017 Rebranded the document. Edited the document.

More information

Our First Android Application

Our First Android Application Mobile Application Development Lecture 04 Imran Ihsan Our First Android Application Even though the HelloWorld program is trivial in introduces a wealth of new ideas the framework, activities, manifest,

More information

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar Mobile Application Development Higher Diploma in Science in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology

More information

Tutorial: Setup for Android Development

Tutorial: Setup for Android Development Tutorial: Setup for Android Development Adam C. Champion CSE 5236: Mobile Application Development Autumn 2017 Based on material from C. Horstmann [1], J. Bloch [2], C. Collins et al. [4], M.L. Sichitiu

More information

M.A.D Assignment # 1

M.A.D Assignment # 1 Submitted by: Rehan Asghar Roll no: BSSE (7) 15126 M.A.D Assignment # 1 Submitted to: Sir Waqas Asghar Submitted by: M. Rehan Asghar 4/25/17 Roll no: BSSE 7 15126 XML Code: Calculator Android App

More information

Adapter.

Adapter. 1 Adapter An Adapter object acts as a bridge between an AdapterView and the underlying data for that view The Adapter provides access to the data items The Adapter is also responsible for making a View

More information

EMBEDDED SYSTEMS PROGRAMMING Android NDK

EMBEDDED SYSTEMS PROGRAMMING Android NDK EMBEDDED SYSTEMS PROGRAMMING 2014-15 Android NDK WHAT IS THE NDK? The Android NDK is a set of cross-compilers, scripts and libraries that allows to embed native code into Android applications Native code

More information

1. Location Services. 1.1 GPS Location. 1. Create the Android application with the following attributes. Application Name: MyLocation

1. Location Services. 1.1 GPS Location. 1. Create the Android application with the following attributes. Application Name: MyLocation 1. Location Services 1.1 GPS Location 1. Create the Android application with the following attributes. Application Name: MyLocation Project Name: Package Name: MyLocation com.example.mylocation 2. Put

More information

1 카메라 1.1 제어절차 1.2 관련주요메서드 1.3 제작철차 서피스뷰를생성하고이를제어하는서피스홀더객체를참조해야함. 매니페스트에퍼미션을지정해야한다.

1 카메라 1.1 제어절차 1.2 관련주요메서드 1.3 제작철차 서피스뷰를생성하고이를제어하는서피스홀더객체를참조해야함. 매니페스트에퍼미션을지정해야한다. 1 카메라 1.1 제어절차 서피스뷰를생성하고이를제어하는서피스홀더객체를참조해야함. 매니페스트에퍼미션을지정해야한다. 1.2 관련주요메서드 setpreviewdisplay() : startpreview() : stoppreview(); onpicturetaken() : 사진을찍을때자동으로호출되며캡처한이미지가전달됨 1.3 제작철차 Step 1 프로젝트를생성한후매니페스트에퍼미션들을설정한다.

More information

TextView Control. EditText Control. TextView Attributes. android:id - This is the ID which uniquely identifies the control.

TextView Control. EditText Control. TextView Attributes. android:id - This is the ID which uniquely identifies the control. A TextView displays text to the user. TextView Attributes TextView Control android:id - This is the ID which uniquely identifies the control. android:capitalize - If set, specifies that this TextView has

More information

EMBEDDED SYSTEMS PROGRAMMING Android NDK

EMBEDDED SYSTEMS PROGRAMMING Android NDK EMBEDDED SYSTEMS PROGRAMMING 2015-16 Android NDK WHAT IS THE NDK? The Android NDK is a set of cross-compilers, scripts and libraries that allows to embed native code into Android applications Native code

More information

Dynamically Create Admob Banner and Interstitial Ads

Dynamically Create Admob Banner and Interstitial Ads Dynamically Create Admob Banner and Interstitial Ads activity_main.xml file 0 0 0

More information

Android Beginners Workshop

Android Beginners Workshop Android Beginners Workshop at the M O B IL E M O N D AY m 2 d 2 D E V E L O P E R D A Y February, 23 th 2010 Sven Woltmann, AndroidPIT Sven Woltmann Studied Computer Science at the TU Ilmenau, 1994-1999

More information

Data Persistence. Chapter 10

Data Persistence. Chapter 10 Chapter 10 Data Persistence When applications create or capture data from user inputs, those data will only be available during the lifetime of the application. You only have access to that data as long

More information

COMP4521 EMBEDDED SYSTEMS SOFTWARE

COMP4521 EMBEDDED SYSTEMS SOFTWARE COMP4521 EMBEDDED SYSTEMS SOFTWARE LAB 1: DEVELOPING SIMPLE APPLICATIONS FOR ANDROID INTRODUCTION Android is a mobile platform/os that uses a modified version of the Linux kernel. It was initially developed

More information

android-espresso #androidespresso

android-espresso #androidespresso android-espresso #androidespresso Table of Contents About 1 Chapter 1: Getting started with android-espresso 2 Remarks 2 Examples 2 Espresso setup instructions 2 Checking an Options Menu items (using Spoon

More information

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar Mobile Application Development Higher Diploma in Science in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology

More information

ActionBar. import android.support.v7.app.actionbaractivity; public class MyAppBarActivity extends ActionBarActivity { }

ActionBar. import android.support.v7.app.actionbaractivity; public class MyAppBarActivity extends ActionBarActivity { } Android ActionBar import android.support.v7.app.actionbaractivity; public class MyAppBarActivity extends ActionBarActivity { Layout, activity.xml

More information

Embedded Systems Programming - PA8001

Embedded Systems Programming - PA8001 Embedded Systems Programming - PA8001 http://goo.gl/ydeczu Lecture 8 Mohammad Mousavi m.r.mousavi@hh.se Center for Research on Embedded Systems School of Information Science, Computer and Electrical Engineering

More information

Solving an Android Threading Problem

Solving an Android Threading Problem Home Java News Brief Archive OCI Educational Services Solving an Android Threading Problem Introduction by Eric M. Burke, Principal Software Engineer Object Computing, Inc. (OCI) By now, you probably know

More information

CS 370 Android Basics D R. M I C H A E L J. R E A L E F A L L

CS 370 Android Basics D R. M I C H A E L J. R E A L E F A L L CS 370 Android Basics D R. M I C H A E L J. R E A L E F A L L 2 0 1 5 Activity Basics Manifest File AndroidManifest.xml Central configuration of Android application Defines: Name of application Icon for

More information

Android Programs Day 5

Android Programs Day 5 Android Programs Day 5 //Android Program to demonstrate the working of Options Menu. 1. Create a New Project. 2. Write the necessary codes in the MainActivity.java to create OptionMenu. 3. Add the oncreateoptionsmenu()

More information

MVC Apps Basic Widget Lifecycle Logging Debugging Dialogs

MVC Apps Basic Widget Lifecycle Logging Debugging Dialogs Overview MVC Apps Basic Widget Lifecycle Logging Debugging Dialogs Lecture: MVC Model View Controller What is an App? Android Activity Lifecycle Android Debugging Fixing Rotations & Landscape Layouts Localization

More information

... 1... 2... 2... 3... 3... 4... 4... 5... 5... 6... 6... 7... 8... 9... 10... 13... 14... 17 1 2 3 4 file.txt.exe file.txt file.jpg.exe file.mp3.exe 5 6 0x00 0xFF try { in.skip(9058); catch (IOException

More information

Fragments. Lecture 10

Fragments. Lecture 10 Fragments Lecture 10 Situa2onal layouts Your app can use different layouts in different situa2ons Different device type (tablet vs. phone vs. watch) Different screen size Different orienta2on (portrait

More information

LISTING PROGRAM APLIKASI ANDROID

LISTING PROGRAM APLIKASI ANDROID 1 LISTING PROGRAM APLIKASI ANDROID AboutFragment.java package tia.restodj; import android.app.fragment; import android.os.bundle; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup;

More information