<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Birjesh Gupta &#8211; MaXEster Technologies  | Technical Blog</title>
	<atom:link href="https://www.maxester.com/blog/author/birjesh/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.maxester.com/blog</link>
	<description>Tutorials, Examples and Implementation code for Developers Help</description>
	<lastBuildDate>Mon, 17 Feb 2025 09:17:48 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.0.22</generator>
	<item>
		<title>How to make camera follow the player in Unity 3d?</title>
		<link>https://www.maxester.com/blog/2020/02/24/how-do-you-make-the-camera-follow-the-player-in-unity-3d/</link>
		<comments>https://www.maxester.com/blog/2020/02/24/how-do-you-make-the-camera-follow-the-player-in-unity-3d/#comments</comments>
		<pubDate>Mon, 24 Feb 2020 08:07:37 +0000</pubDate>
		<dc:creator><![CDATA[Birjesh Gupta]]></dc:creator>
				<category><![CDATA[Unity]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Unity3D]]></category>

		<guid isPermaLink="false">https://www.maxester.com/blog/?p=830</guid>
		<description><![CDATA[<p>In this article we will learn about. How do you make the camera follow the player in Unity 3d? And, we&#8217;ll enable the camera to follow the player around the play field by writing a simple C# script. Create a&#8230;</p>
<p><a href="https://www.maxester.com/blog/2020/02/24/how-do-you-make-the-camera-follow-the-player-in-unity-3d/" class="btn-more">Read More<span class="arrow-more">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2020/02/24/how-do-you-make-the-camera-follow-the-player-in-unity-3d/">How to make camera follow the player in Unity 3d?</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[
<p>In this article we will learn about. <strong>How do you make the camera follow the player in Unity 3d?</strong></p>



<p>And, we&#8217;ll enable the camera to follow the player around the play field by writing a simple C# script.</p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<h3> Create a script for Camera.</h3>



<p>click on Main Camera &#8211;&gt; go to Inspector window &#8211;&gt; click on Add components &#8211;&gt;new Script &#8211;&gt;Name the script(CameraController).</p>



<p><strong>OR</strong></p>



<p>Go to inside the Project Window.</p>



<p>right-click&#8211;&gt; create &#8211;&gt; C# Script </p>



<p>Rename the file as CameraController</p>



<p>Now, paste the following code into your script.</p>



<pre class="wp-block-code"><code>using UnityEngine;
using System.Collections;

public class CameraController : MonoBehaviour {

    public GameObject player;        //Public variable to store a reference to the player game object


    private Vector3 offset;            //Private variable to store the offset distance between the player and camera

    // Use this for initialization
    void Start () 
    {
        //Calculate and store the offset value by getting the distance between the player's position and camera's position.
        offset = transform.position - player.transform.position;
    }

    // LateUpdate is called after Update each frame
    void LateUpdate () 
    {
        // Set the position of the camera's transform to be the same as the player's, but offset by the calculated offset distance.
        transform.position = player.transform.position + offset;
    }
}</code></pre>



<p>If you were created script  from Project window then drag and drop the script on Main Camera. It will add the script to main Camera.</p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<figure class="wp-block-image"><img src="https://www.maxester.com/blog/wp-content/uploads/2020/02/Capture.png" alt="" class="wp-image-832" srcset="https://www.maxester.com/blog/wp-content/uploads/2020/02/Capture.png 300w, https://www.maxester.com/blog/wp-content/uploads/2020/02/Capture-145x300.png 145w" sizes="(max-width: 300px) 100vw, 300px" /></figure>



<p>Now, Drag and Drop the Player into Player field inside on CameraController script inside the Main Camera Inspector window.</p>



<p>Now, Run the project and you will get the camera follow the Player movement.</p>



<p>Hope this will be helpfull for  you.</p>



<p>Thank You.</p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2020/02/24/how-do-you-make-the-camera-follow-the-player-in-unity-3d/">How to make camera follow the player in Unity 3d?</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.maxester.com/blog/2020/02/24/how-do-you-make-the-camera-follow-the-player-in-unity-3d/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Method Reference In Java 8.</title>
		<link>https://www.maxester.com/blog/2020/01/03/method-reference-in-java-8/</link>
		<comments>https://www.maxester.com/blog/2020/01/03/method-reference-in-java-8/#respond</comments>
		<pubDate>Fri, 03 Jan 2020 07:37:19 +0000</pubDate>
		<dc:creator><![CDATA[Birjesh Gupta]]></dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[Lambda Expression]]></category>
		<category><![CDATA[Method Reference]]></category>

		<guid isPermaLink="false">https://www.maxester.com/blog/?p=817</guid>
		<description><![CDATA[<p>One of the most welcome changes in Java 8 was the introduction of&#160;Lambda Expression and Method Reference In java 8.. Method references in java are a special type of lambda expressions. because they&#8217;re often used to create simple lambda expressions&#8230;</p>
<p><a href="https://www.maxester.com/blog/2020/01/03/method-reference-in-java-8/" class="btn-more">Read More<span class="arrow-more">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2020/01/03/method-reference-in-java-8/">Method Reference In Java 8.</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[
<p> One of the most welcome changes in Java 8 was the introduction of&nbsp;Lambda Expression and Method Reference In java 8..</p>



<p>Method references in java are a special type of lambda expressions. because they&#8217;re often used to create simple lambda expressions by referencing existing methods. </p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<p> It is compact and easy form of lambda expression. Each time when you are using lambda expression to just referring a method, you can replace your lambda expression with method reference. </p>



<p>So in this , we are explaining method reference in java concept in detail. </p>



<h2>Types of method reference in java.</h2>



<ol><li> Method Reference to a static method. </li><li> Reference to a instance method. </li><li> Reference to a constructor. </li></ol>



<h3>1. Method Reference to a static method.</h3>



<p><em><strong>syntax :-</strong></em> <br></p>



<pre class="wp-block-preformatted"><strong>ContainingClass::staticMethodName</strong></pre>



<h4>Example:-</h4>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<p> In the below example, we have defined a functional interface and referring a static method to it&#8217;s functional method max(). </p>



<pre class="wp-block-code"><code>interface Maxester{  
    void max();  
}  
public class MethodReference {  
    public static void welcome(){  
        System.out.println("Welcome, this is static method.");  
    }  
    public static void main(String[] args) {  
        // Referring static method  
        Maxester maxester = MethodReference::welcome;  
        // Calling interface method  
        maxester.max();  
    }  
}  </code></pre>



<p><strong>Output:-</strong></p>



<p>Welcome, this is static method.</p>



<h3>2.  Reference to a instance method.</h3>



<p><strong><em>syntax</em>:-</strong></p>



<pre class="wp-block-preformatted"><strong> containingObject::instanceMethodName </strong></pre>



<h4><strong>Example</strong>:-</h4>



<p> In the below example, we are referring non-static methods. we can refer methods by class object and also an anonymous object. </p>



<pre class="wp-block-code"><code>interface Maxester{  
    void max();  
}  
public class InstanceMethodReference {  
    public void welcome(){  
        System.out.println("Welcome, this is instance method.");  
    }  
    public static void main(String[] args) {  
        InstanceMethodReference methodReference = new InstanceMethodReference(); // Creating object  
        // Referring non-static method using reference  
            Maxester maxester = methodReference::welcome;  
        // Calling interface method  
            Maxester.max();  
            // Referring non-static method using anonymous object  
            Maxester maxester_first = new InstanceMethodReference()::welcome; // You can use anonymous object also  
            // Calling interface method  
            maxester_first.max();  
    }  
}  
</code></pre>



<p><strong>Output</strong>:-</p>



<p>Welcome, this is instance method.</p>



<p>Welcome, this is instance method. </p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<h3>3. Reference to a constructor.</h3>



<p><strong><em>syntax</em></strong>:-</p>



<pre class="wp-block-preformatted"><strong> ClassName::new</strong></pre>



<h4>Example:-</h4>



<pre class="wp-block-code"><code>Interface Maxester{
      NewMaxester max(String value);
}
class NewMaxester{
      NewMaxester(String value){
         System.out.prinln(value);
     }
}
public class ConstrutorRefrenceMethod{
      public static void main(String[] args){
             Maxester maxester = NewMaxester::new;
             maxester.max("Welcome to maxester constructor");
        }
}</code></pre>



<p><strong><em>output</em></strong>:-</p>



<p> Welcome to maxester constructor. </p>



<p><strong><em>External Link:-</em></strong></p>



<p>You can also read much more about Method Reference from below link.</p>



<p><a href="https://docs.oracle.com/javase/tutorial/java/javaOO/methodreferences.html">https://docs.oracle.com/javase/tutorial/java/javaOO/methodreferences.html</a></p>



<p>So i hope, This will be helpful for you.</p>



<p>ThankYou.</p>



<p></p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2020/01/03/method-reference-in-java-8/">Method Reference In Java 8.</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.maxester.com/blog/2020/01/03/method-reference-in-java-8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Can we Overload the main() method in Java?</title>
		<link>https://www.maxester.com/blog/2019/12/19/can-we-overload-the-main-method-in-java/</link>
		<comments>https://www.maxester.com/blog/2019/12/19/can-we-overload-the-main-method-in-java/#comments</comments>
		<pubDate>Thu, 19 Dec 2019 09:15:45 +0000</pubDate>
		<dc:creator><![CDATA[Birjesh Gupta]]></dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">https://www.maxester.com/blog/?p=795</guid>
		<description><![CDATA[<p>One of the common doubts among Java beginners while learning to overload and overriding is, whether it&#8217;s possible to overload main() in Java? Can you overload the main() method in Java? How will JVM find if you change the signature&#8230;</p>
<p><a href="https://www.maxester.com/blog/2019/12/19/can-we-overload-the-main-method-in-java/" class="btn-more">Read More<span class="arrow-more">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2019/12/19/can-we-overload-the-main-method-in-java/">Can we Overload the main() method in Java?</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[
<p> One of the common doubts among Java beginners while learning to overload and overriding is, whether it&#8217;s possible to overload main() in Java? Can you overload the main() method in Java? How will JVM find if you change the signature of the main method as part of the method overloading? etc. </p>



<p>So, the answer is <strong>Yes</strong>, We can overload the main() method in java but JVM only calls the original main method, it will never call our overloaded main method. </p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<h2>Overload Main() Method in Java.</h2>



<p> This is just one way, you can create as many versions of main as you want, but you must make sure that the method signature of each main is different. You can change the method signature by changing the type of argument, number of arguments or order of arguments. Best practice to overload a method is by changing the number of arguments, or types of arguments.  In Java, it&#8217;s not possible to overload the method by just changing return type. </p>



<h2>Example:-</h2>



<pre class="wp-block-code"><code>public class Maxester { 


// Overloaded main method 1  
    // Should be executed when character is passed 
    public static void main(char value) 
    { 
        System.out.println("Inside main(char value) method"); 
    } 
  
    // Overloaded main method 2 
   // Should be executed when int value is passed 
    public static void main(int value) 
    { 
        System.out.println("Inside main(int value) method"); 
    } 
    // Overloaded main method 3  
    // Should be executed when double value is passed 
    public static void main(Double[] value) 
    { 
        System.out.println("Inside main(Double[] value) method"); 
    } 
  
    // Original main() 
    public static void main(String[] args) 
    { 
        System.out.println("Inside original main(String[] args) method "); 
    } 
} </code></pre>



<h3>Output:-</h3>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>



<p><em><strong>Inside original main(Strings[] args) method.</strong></em></p>



<p> As from the above example, it is clear that every time the original main method executes but not the overloaded methods because JVM only executes the original main method by default but not the overloaded one.</p>



<p>we can overload the main() method in java<br>But, to execute overloaded methods of main, we must call them from the original main method. </p>



<p>I hope this will be helpful to you.</p>



<p>Thank you.</p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2019/12/19/can-we-overload-the-main-method-in-java/">Can we Overload the main() method in Java?</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.maxester.com/blog/2019/12/19/can-we-overload-the-main-method-in-java/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Setting Preference Activity In Android Q.</title>
		<link>https://www.maxester.com/blog/2019/12/18/setting-preference-activity-in-android-q/</link>
		<comments>https://www.maxester.com/blog/2019/12/18/setting-preference-activity-in-android-q/#comments</comments>
		<pubDate>Wed, 18 Dec 2019 08:13:40 +0000</pubDate>
		<dc:creator><![CDATA[Birjesh Gupta]]></dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[#Preferences activity deprecated]]></category>
		<category><![CDATA[PreferenceFragmentCompat]]></category>

		<guid isPermaLink="false">https://www.maxester.com/blog/?p=783</guid>
		<description><![CDATA[<p>PreferenceFragmentCompat</p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2019/12/18/setting-preference-activity-in-android-q/">Setting Preference Activity In Android Q.</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[
<p>In this article, we are going to learn how we can use setting preference activity in Android. When we need certain settings in our app.<br>  </p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<h2>What is Setting Preference Activity?</h2>



<p>

A&nbsp;<strong>Setting Activity</strong>&nbsp;is an activity in the android studio which makes it easy to integrate the functionality and user interface in the application.

</p>



<h2>Use of Setting Preference Activity in Android.</h2>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<p> Many times we need certain settings in our app, like setting default language, theme(light or dark), customizing notifications, etc.</p>



<p> In this tutorial, we will be creating a simple app with settings to change Image visibility. </p>



<p>But, For this, we will be using&nbsp;<strong>Shared Preferences</strong>. </p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<p> In this article, we will be creating the first setting that is making the image visible or invisible by&nbsp;<strong>CheckBoxPreference.</strong></p>



<h2>Example For Setting Preference Activity in Android.</h2>



<h3><strong> 1:-&nbsp;Create&nbsp;a&nbsp;new&nbsp;android&nbsp;project.</strong></h3>



<p>File &#8211;&gt; New &#8211;&gt; Activity &#8211;&gt; EmptyActivity &#8211;&gt; name the project(SettingPrefrence) &#8211;&gt;finish.</p>



<h3><strong> 2:-</strong> In<strong> res/menu</strong> create a .xml file.</h3>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<p>Right-click on the menu &#8211;&gt; New &#8211;&gt; menu resource file &#8211;&gt; name the file(menu_item.xml) &#8211;&gt;ok.</p>



<h3> 3:- In <strong>menu_item.xml </strong>copy the below code.</h3>



<pre class="wp-block-code"><code>//menu_item.xml

&lt;?xml version="1.0" encoding="utf-8"?>
&lt;menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    &lt;item
        android:id="@+id/action_settings"
        android:orderInCategory="100"
        android:title="setting"
        app:showAsAction="never" />
&lt;/menu></code></pre>



<h3><strong> 4:-</strong> In <strong>MainActivity.java</strong> write the below code for creating and selection of menu items.</h3>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<p>when we click on settings then the following methods will be called.</p>



<pre class="wp-block-code"><code>@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_item, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();

        if (id == R.id.action_settings) {
            // launch settings activity
            startActivity(new Intent(MainActivity.this, SettingsActivity.class));
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

</code></pre>



<h3><strong> 5:-&nbsp;&nbsp;</strong>Now&nbsp;in&nbsp;<strong>activity_main.xml</strong>&nbsp;write&nbsp;below&nbsp;code&nbsp;for&nbsp;text view&nbsp;and&nbsp;image view.</h3>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<pre class="wp-block-code"><code>&lt;?xml version="1.0" encoding="utf-8"?>
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingTop="10dp"
    tools:context=".MainActivity">

    &lt;TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="Setting Prefrence"
        android:textColor="#000000"
        android:textSize="25dp"
        android:gravity="center_horizontal"/>

    &lt;ImageView
        android:id="@+id/image"
        android:layout_width="250dp"
        android:layout_height="wrap_content"
        android:src="@drawable/image"
        android:layout_centerInParent="true"/>



&lt;/RelativeLayout></code></pre>



<h3><strong> 6:-</strong> Now for <strong>Setting activity.</strong></h3>



<p>Right-click on the app &#8211;&gt; new &#8211;&gt; activity &#8211;&gt; setting activity &#8211;&gt;finish.</p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<pre class="wp-block-code"><code>public class SettingsActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.settings_activity);
        getSupportFragmentManager()
                .beginTransaction()
                .replace(R.id.settings, new SettingsFragment())
                .commit();
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(true);
        }
    }

    public static class SettingsFragment extends PreferenceFragmentCompat {
        @Override
        public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
            setPreferencesFromResource(R.xml.root_preferences, rootKey);
        }
    }
}</code></pre>



<p>And, you will get the above code in setting activity by default.</p>



<h3><strong> </strong>7:- Now, In rex/xml/root_preferences.xml copy the below code in your file for SwitchPreferenceCompat.</h3>



<pre class="wp-block-code"><code>&lt;PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">

    &lt;SwitchPreferenceCompat
        app:key="display_image"
        app:defaultValue="true"
        app:summary="Visible/Invisible Image"
        app:title="Display Image" />

&lt;/PreferenceScreen></code></pre>



<p><strong>Attributes define:-</strong></p>



<p>key = used for the id of the view.</p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<p>defaultValue =  true/false for making switch initially on/off. By default it is true.</p>



<p>summary = to provide a short description of the switch button.</p>



<p>title = to provide title/name of the switch button.</p>



<h3><strong> 8:- </strong> In MainActivity file.</h3>



<p> Now, <strong>implements</strong> your <strong>MainActivity</strong> file with <strong>SharedPreferences.OnSharedPreferenceChangeListener</strong> and copy the below code in your file.</p>



<pre class="wp-block-code"><code>public class MainActivity extends AppCompatActivity implements SharedPreferences.OnSharedPreferenceChangeListener {

    ImageView image;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        image = findViewById(R.id.image);
        ActionBar actionBar = this.getSupportActionBar();

        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(true);
        }
        setupSharedPreferences();
    }

    private void setImageVisible(boolean display_image) {
        if (display_image == true) {
            image.setVisibility(View.VISIBLE);
        } else {
            image.setVisibility(View.INVISIBLE);
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_item, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();

        if (id == R.id.action_settings) {
            // launch settings activity
            startActivity(new Intent(MainActivity.this, SettingsActivity.class));
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

    @Override
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {


        if (key.equals("display_image")) {
            setImageVisible(sharedPreferences.getBoolean("display_image",true));
        }

    }
    private void setupSharedPreferences() {
        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
        sharedPreferences.registerOnSharedPreferenceChangeListener(this);
    }
</code></pre>



<p>Here, the description of the above methods uses in the <strong>MainActivity</strong> file.</p>



<pre class="wp-block-code"><code>private void setupSharedPreferences() {
        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
        sharedPreferences.registerOnSharedPreferenceChangeListener(this);
    }
</code></pre>



<p>Here, the Above method is used to set the switch button preference. It set true when on and false when off.</p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<pre class="wp-block-code"><code>@Override
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {


        if (key.equals("display_image")) {
            setTextVisible(sharedPreferences.getBoolean("display_image",true));
        }

    }</code></pre>



<p>Now, The above method is used to getting the preference data on switch button status changed.  <br>It gets true when on and false when off. </p>



<p>and now,</p>



<pre class="wp-block-code"><code>private void setImageVisible(boolean display_image) {
        if (display_image) {
            image.setVisibility(View.VISIBLE);
        } else {
            image.setVisibility(View.INVISIBLE);
        }
    }</code></pre>



<p>This method is used to set the visibility of the image. The image will visible when the switch button in on.</p>



<p>But,</p>



<p> The image will invisible when the switch button is off.</p>



<p>Now, you can run your project and you will get the following output.</p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<h2>Output:-</h2>



<figure class="wp-block-image"><img src="https://www.maxester.com/blog/wp-content/uploads/2019/12/first-473x1024.png" alt="" class="wp-image-784" srcset="https://www.maxester.com/blog/wp-content/uploads/2019/12/first-473x1024.png 473w, https://www.maxester.com/blog/wp-content/uploads/2019/12/first-138x300.png 138w, https://www.maxester.com/blog/wp-content/uploads/2019/12/first-768x1664.png 768w, https://www.maxester.com/blog/wp-content/uploads/2019/12/first.png 1080w" sizes="(max-width: 473px) 100vw, 473px" /></figure>



<figure class="wp-block-image"><img src="https://www.maxester.com/blog/wp-content/uploads/2019/12/second-473x1024.png" alt="" class="wp-image-785" srcset="https://www.maxester.com/blog/wp-content/uploads/2019/12/second-473x1024.png 473w, https://www.maxester.com/blog/wp-content/uploads/2019/12/second-138x300.png 138w, https://www.maxester.com/blog/wp-content/uploads/2019/12/second-768x1664.png 768w, https://www.maxester.com/blog/wp-content/uploads/2019/12/second.png 1080w" sizes="(max-width: 473px) 100vw, 473px" /></figure>



<figure class="wp-block-image"><img src="https://www.maxester.com/blog/wp-content/uploads/2019/12/third-473x1024.png" alt="" class="wp-image-786" srcset="https://www.maxester.com/blog/wp-content/uploads/2019/12/third-473x1024.png 473w, https://www.maxester.com/blog/wp-content/uploads/2019/12/third-138x300.png 138w, https://www.maxester.com/blog/wp-content/uploads/2019/12/third-768x1664.png 768w, https://www.maxester.com/blog/wp-content/uploads/2019/12/third.png 1080w" sizes="(max-width: 473px) 100vw, 473px" /></figure>



<figure class="wp-block-image"><img src="https://www.maxester.com/blog/wp-content/uploads/2019/12/fourth-473x1024.png" alt="" class="wp-image-787" srcset="https://www.maxester.com/blog/wp-content/uploads/2019/12/fourth-473x1024.png 473w, https://www.maxester.com/blog/wp-content/uploads/2019/12/fourth-138x300.png 138w, https://www.maxester.com/blog/wp-content/uploads/2019/12/fourth-768x1664.png 768w, https://www.maxester.com/blog/wp-content/uploads/2019/12/fourth.png 1080w" sizes="(max-width: 473px) 100vw, 473px" /></figure>



<figure class="wp-block-image"><img src="https://www.maxester.com/blog/wp-content/uploads/2019/12/fifth-473x1024.png" alt="" class="wp-image-788" srcset="https://www.maxester.com/blog/wp-content/uploads/2019/12/fifth-473x1024.png 473w, https://www.maxester.com/blog/wp-content/uploads/2019/12/fifth-138x300.png 138w, https://www.maxester.com/blog/wp-content/uploads/2019/12/fifth-768x1664.png 768w, https://www.maxester.com/blog/wp-content/uploads/2019/12/fifth.png 1080w" sizes="(max-width: 473px) 100vw, 473px" /></figure>



<p>Now, when you turn on the switch button image will be visible. </p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<p>And, I hope this article will helpful for you.</p>



<p>Thank you.</p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2019/12/18/setting-preference-activity-in-android-q/">Setting Preference Activity In Android Q.</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.maxester.com/blog/2019/12/18/setting-preference-activity-in-android-q/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Lambda Expressions in Java.</title>
		<link>https://www.maxester.com/blog/2019/11/29/lambda-expressions-in-java/</link>
		<comments>https://www.maxester.com/blog/2019/11/29/lambda-expressions-in-java/#respond</comments>
		<pubDate>Fri, 29 Nov 2019 11:24:00 +0000</pubDate>
		<dc:creator><![CDATA[Birjesh Gupta]]></dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[Lambda Expression]]></category>

		<guid isPermaLink="false">https://www.maxester.com/blog/?p=754</guid>
		<description><![CDATA[<p>Lambda expression in java is a new and important feature of Java which was included in Java SE 8. And, Lambda expression in java also provides a clear and concise way to represent one method interface using an expression. It&#8230;</p>
<p><a href="https://www.maxester.com/blog/2019/11/29/lambda-expressions-in-java/" class="btn-more">Read More<span class="arrow-more">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2019/11/29/lambda-expressions-in-java/">Lambda Expressions in Java.</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[
<p>Lambda expression in java is a new and important feature of Java which was included in Java SE 8. </p>



<p>And,  Lambda expression in java also provides a clear and concise way to represent one method interface using an expression.</p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<p>It is also very useful in the collection library. It helps to iterate, filter and extract data from the collection.</p>



<h2>Functional Interface</h2>



<p> An interface that has only one abstract method is called a functional interface. </p>



<p>But,</p>



<p>Lambda Expressions in Java also provides an annotation <strong>@</strong><em><strong>FunctionalInterface</strong></em>, which is used to declare an interface as a functional interface. </p>



<h2>Important Characteristics of a lambda expression. </h2>



<p><strong>1.Optional type declaration:</strong></p>



<p>No need to declare the type of a parameter.</p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<p> Also, The compiler can inference the same from the value of the parameter.</p>



<p><strong>2.</strong>  <strong>The optional parenthesis around parameter</strong> :</p>



<p>No need to declare a single parameter in parenthesis.  </p>



<p>But, For multiple parameters, parentheses are required.</p>



<p><strong>3.</strong>  <strong>Optional curly braces</strong> </p>



<p>No need to use curly braces in the expression body if the body contains a single statement. Then, it is  optional to return keyword</p>



<p><strong>4. Optional return keyword</strong></p>



<p>The compiler automatically returns the value if the body has a single expression to return the value. </p>



<p>Also, Curly braces are required to indicate that expression returns a value.</p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<h2>Why We Use Lambda Expression?</h2>



<ol><li>To provide the implementation of a Functional interface.</li><li>Less coding.</li></ol>



<h2>Syntax Of Lambda Expression</h2>



<ul><li><strong>no parameter syntax</strong></li></ul>



<pre class="wp-block-code"><code>() -> {  
//Body of no parameter lambda  
}
//Lambda Expressions in Java.</code></pre>



<ul><li><strong>one parameter syntax</strong></li></ul>



<pre class="wp-block-code"><code>(s1) -> {  
//Body of one parameter lambda  
}

//Lambda Expressions in Java.</code></pre>



<ul><li><strong>two-parameter syntax</strong></li></ul>



<pre class="wp-block-code"><code>(s1,s2) -> {  
//Body of two parameter lambda  
}

//Lambda Expressions in Java.</code></pre>



<h2>Example:-</h2>



<h2>Without using Lambda Expression:</h2>



<p></p>



<pre class="wp-block-code"><code>//Lambda Expressions in Java.

interface MyLambda{  
    public void lambda();  
}  
public class LambdaExample {  
    public static void main(String[] args) {  
        String name = "XYZ";  
  
        //without lambda, MyLambdaimplementation using anonymous class  
        MyLambda ml=new MyLambda(){  
            public void lambda(){System.out.println("Hello,  "+name);}  
        };  
        ml.lambda();  
    }  
}  

//Lambda Expressions in Java.</code></pre>



<p><strong>Output:&nbsp;&nbsp;</strong></p>



<p>Hello, XYZ</p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<h2>Using Lambda Expression:</h2>



<pre class="wp-block-code"><code>//Lambda Expressions in Java.

@FunctionalInterface  //It is optional 
interface MyLambda{  
    public String lambda(String name);  
}  
  
public class LambdaExample{  
    public static void main(String[] args) {  
      
        // Lambda expression with single parameter.  
        MyLambda my1=(name)->{  
            return "Hello, "+name;  
        };  
        System.out.println(my1.lambda("XYZ"));  
          
        // You can omit function parentheses    
        MyLambda my2= name ->{  
            return "Hello, "+name;  
        };  
        System.out.println(my2.lambda("ABC"));  
    }  
}

//Lambda Expressions in Java. </code></pre>



<p><strong>Output:&nbsp;</strong></p>



<pre class="wp-block-preformatted">Hello, XYZ<br>Hello, ABC</pre>



<p>You can also use no parameter and multiple parameters lambda expression as in the above example.</p>



<p>Then, you can see How Lambda Expression is very useful.</p>



<p>Also, I hope, this will be helpful for you.</p>



<p>You can also visit on below link for a brief Introduction about Lambda Expressions in Java.</p>



<p><a href="https://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html">https://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html</a></p>



<p>ThankYou.</p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2019/11/29/lambda-expressions-in-java/">Lambda Expressions in Java.</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.maxester.com/blog/2019/11/29/lambda-expressions-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Edit Text for OTP Using different boxes in Android.</title>
		<link>https://www.maxester.com/blog/2019/11/18/edit-text-for-otp-using-different-boxes-in-android/</link>
		<comments>https://www.maxester.com/blog/2019/11/18/edit-text-for-otp-using-different-boxes-in-android/#comments</comments>
		<pubDate>Mon, 18 Nov 2019 05:11:48 +0000</pubDate>
		<dc:creator><![CDATA[Birjesh Gupta]]></dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">https://www.maxester.com/blog/?p=729</guid>
		<description><![CDATA[<p>Edit Text for OTP Using different boxes in Android. The below solution takes into consideration: Auto focusing to the next edit text on entering one digit of OTP in the focussed edit text. Auto focusing to the previous edit text&#8230;</p>
<p><a href="https://www.maxester.com/blog/2019/11/18/edit-text-for-otp-using-different-boxes-in-android/" class="btn-more">Read More<span class="arrow-more">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2019/11/18/edit-text-for-otp-using-different-boxes-in-android/">Edit Text for OTP Using different boxes in Android.</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[
<p><strong> Edit Text for OTP Using different boxes in Android</strong>. </p>



<p>The below solution takes into consideration:</p>



<ol><li>Auto focusing to the next edit text on entering one digit of OTP in the focussed edit text.</li><li>Auto focusing to the previous edit text on deleting one digit of OTP in the focussed edit text.</li></ol>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<p>We can achieve this by <strong>TextWatcher</strong> interaface and by make it more generic.</p>



<p>1. Create a new project &#8220;<strong>OtpWithBoxes</strong>&#8220;.</p>



<p>2. In<strong> res/drawabl</strong>e right click on drawble and create a new <strong>.xml</strong> file name<strong> edittext_curve_bg.xml</strong> for making edit text background curved and attractive and Copy below code in your <strong>.xml</strong> file.</p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<pre class="wp-block-code"><code>&lt;?xml version="1.0" encoding="utf-8"?>
&lt;shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

    &lt;solid android:color="#f2f2f2" />

    &lt;corners
        android:bottomLeftRadius="10dp"
        android:bottomRightRadius="10dp"
        android:topLeftRadius="10dp"
        android:topRightRadius="10dp" />


    &lt;stroke
        android:width="3dp"
        android:color="#DA6464" />

&lt;/shape></code></pre>



<p>3. Now, Copy the below code to your <strong>activity_main.xml</strong>                    file.</p>



<pre class="wp-block-code"><code>

&lt;?xml version="1.0" encoding="utf-8"?>
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="20dp"
    android:paddingRight="20dp"
    tools:context=".MainActivity">
    &lt;LinearLayout
        android:id="@+id/root_otp_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="100dp"
        android:padding="10dp"
        android:orientation="horizontal"
        android:weightSum="4">

        &lt;EditText
            android:id="@+id/otp_edit_box1"
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="60dp"
            android:layout_marginRight="20dp"
            android:gravity="center"
            android:inputType="number"
            android:maxLength="1"
            android:textSize="30sp"
            android:background="@drawable/edittext_curve_bg"/>

        &lt;EditText
            android:id="@+id/otp_edit_box2"
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="60dp"
            android:layout_marginRight="20dp"
            android:gravity="center"
            android:textSize="30sp"
            android:inputType="number"
            android:maxLength="1"
            android:background="@drawable/edittext_curve_bg"/>

        &lt;EditText
            android:id="@+id/otp_edit_box3"
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="60dp"
            android:layout_marginRight="20dp"
            android:gravity="center"
            android:textSize="30sp"
            android:inputType="number"
            android:maxLength="1"
            android:background="@drawable/edittext_curve_bg"/>

        &lt;EditText
            android:id="@+id/otp_edit_box4"
            android:layout_width="0dp"
            android:layout_height="60dp"
            android:gravity="center"
            android:textSize="30sp"
            android:layout_weight="1"
            android:inputType="number"
            android:maxLength="1"
            android:background="@drawable/edittext_curve_bg" />


    &lt;/LinearLayout>

    &lt;RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/root_otp_layout"
        android:layout_centerHorizontal="true"
        >

        &lt;Button
            android:id="@+id/verify_otp_btn"
            android:background="@color/colorAccent"
            android:layout_width="wrap_content"
            android:layout_height="40dp"
            android:textSize="20sp"
            android:paddingLeft="10dp"
            android:paddingRight="10dp"
            android:layout_marginTop="30dp"
            android:textColor="#ffffff"
            android:text="Verify"
            android:layout_centerHorizontal="true"/>

    &lt;/RelativeLayout>

&lt;/RelativeLayout></code></pre>



<p>4.Now, Create a java class name <strong>GenericTextWatcher.java</strong> and implements with <strong>TextWatcher</strong> interface then copy the below code in your class.</p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<pre class="wp-block-code"><code>public class GenericTextWatcher implements TextWatcher {
    private final EditText[] editText;
    private View view;
    public GenericTextWatcher(View view, EditText editText[])
    {
        this.editText = editText;
        this.view = view;
    }

    @Override
    public void afterTextChanged(Editable editable) {
            String text = editable.toString();
            switch (view.getId()) {

                case R.id.otp_edit_box1:
                    if (text.length() == 1)
                        editText[1].requestFocus();
                    break;
                case R.id.otp_edit_box2:

                    if (text.length() == 1)
                        editText[2].requestFocus();
                    else if (text.length() == 0)
                        editText[0].requestFocus();
                    break;
                case R.id.otp_edit_box3:
                    if (text.length() == 1)
                        editText[3].requestFocus();
                    else if (text.length() == 0)
                        editText[1].requestFocus();
                    break;
                case R.id.otp_edit_box4:
                    if (text.length() == 0)
                        editText[2].requestFocus();
                    break;
            }
    }

    @Override
    public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
    }

    @Override
    public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
    }
}</code></pre>



<p>In this class <strong>requestFocus()</strong> method is used to send the transfer focus to next field.</p>



<p>5. Then, In <strong>MainActivity</strong> copy the below code and add your on own feature on<strong> verify</strong> button.</p>



<pre class="wp-block-code"><code>public class MainActivity extends AppCompatActivity {

    EditText otp_textbox_one, otp_textbox_two, otp_textbox_three, otp_textbox_four;
    Button verify_otp;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        otp_textbox_one = findViewById(R.id.otp_edit_box1);
        otp_textbox_two = findViewById(R.id.otp_edit_box2);
        otp_textbox_three = findViewById(R.id.otp_edit_box3);
        otp_textbox_four = findViewById(R.id.otp_edit_box4);
        verify_otp = findViewById(R.id.verify_otp_btn);


        EditText[] edit = {otp_textbox_one, otp_textbox_two, otp_textbox_three, otp_textbox_four};

        otp_textbox_one.addTextChangedListener(new GenericTextWatcher(otp_textbox_one, edit));
        otp_textbox_two.addTextChangedListener(new GenericTextWatcher(otp_textbox_two, edit));
        otp_textbox_three.addTextChangedListener(new GenericTextWatcher(otp_textbox_three, edit));
        otp_textbox_four.addTextChangedListener(new GenericTextWatcher(otp_textbox_four, edit));


        verify_otp.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(getApplicationContext(), "Login Successfull", Toast.LENGTH_SHORT).show();

            }
        });


    }

}
</code></pre>



<p>Now you can run your application and you will get desired output.</p>



<p>Hope this will Helpful for you.</p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2019/11/18/edit-text-for-otp-using-different-boxes-in-android/">Edit Text for OTP Using different boxes in Android.</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.maxester.com/blog/2019/11/18/edit-text-for-otp-using-different-boxes-in-android/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Upload File/Image to the server using Volley in Android.</title>
		<link>https://www.maxester.com/blog/2019/10/04/upload-file-image-to-the-server-using-volley-in-android/</link>
		<comments>https://www.maxester.com/blog/2019/10/04/upload-file-image-to-the-server-using-volley-in-android/#comments</comments>
		<pubDate>Fri, 04 Oct 2019 08:44:21 +0000</pubDate>
		<dc:creator><![CDATA[Birjesh Gupta]]></dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">https://www.maxester.com/blog/?p=683</guid>
		<description><![CDATA[<p>Upload file/image to the server using volley in Android is a very frequently used thing. In most of the apps, we need user avatar, i.e. user profile image. In this article, we are going to see an example to Android&#8230;</p>
<p><a href="https://www.maxester.com/blog/2019/10/04/upload-file-image-to-the-server-using-volley-in-android/" class="btn-more">Read More<span class="arrow-more">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2019/10/04/upload-file-image-to-the-server-using-volley-in-android/">Upload File/Image to the server using Volley in Android.</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[
<p> Upload file/image to the server using volley in Android is a very frequently used thing. In most of the apps, we need user avatar, i.e. user profile image.</p>



<center>
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads" style="display:inline-block;" data-ad-client="ca-pub-3804472713147276" data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>



<p>  In this article, we are going to see an example to Android upload a file/image to the server with a Multipart using volley.</p>



<h2>What is a MultiPart Request?</h2>



<p> <a href="https://source.android.com/reference/tradefed/com/android/tradefed/util/net/HttpMultipartPost">https://source.android.com/reference/tradefed/com/android/tradefed/util/net/HttpMultipartPost</a> </p>



<p> HttpMultipart requests are used to send heavy data or files like audio and video to the server.</p>



<center>
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads" style="display:inline-block;" data-ad-client="ca-pub-3804472713147276" data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>



<p> Android Volley gives you a very faster and optimized environment to send heavy data or files to the server. Here I post an image&nbsp;file selected&nbsp;from the gallery.</p>



<h2>Using Restful API</h2>



<p>Here, I am going to use the below API URL to upload the file/image.</p>



<p>ROOT_URL =<strong>&#8220;http://seoforworld.com/api/v1/file-upload.php&#8221;</strong></p>



<p>Please Check PHP code using this URL <a href="https://www.maxester.com/blog/2020/07/28/php-code-for-upload-image-to-server-using-volley-in-android/">https://www.maxester.com/blog/2020/07/28/php-code-for-upload-image-to-server-using-volley-in-android/</a></p>



<h2>Example of upload file/image to a server with the multipart request using volley.</h2>



<h2>1. Creating an Android project.</h2>



<ul><li> Open Android Studio and create a new project (I created UploadFile)</li></ul>



<h2>2. Add Dependency.</h2>



<p style="text-align:left"> Add&nbsp;Volley&nbsp;to your project. You can quickly add it using Gradle.&nbsp;Extract Gradle Scripts and open build.gradle (Module: app) </p>



<center>
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads" style="display:inline-block;" data-ad-client="ca-pub-3804472713147276" data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>



<pre class="wp-block-code"><code> implementation 'com.android.volley:volley:1.1.1'
//Add this dependency to your project.</code></pre>



<p>

So your dependencies block will look like

</p>



<pre class="wp-block-code"><code>dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.volley:volley:1.1.1'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}</code></pre>



<h2>3. Sync Project.</h2>



<p> Now click on Sync Project With Gradle Icon from the top menu and it will automatically download and add volley library to your project. </p>



<h2>4. Adding Permission in AndroidMainfest.xml file.</h2>



<center>
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads" style="display:inline-block;" data-ad-client="ca-pub-3804472713147276" data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>



<p> We also need the Internet and Read and Write Storage permission. So inside&nbsp;<strong>AndroidManifest.xml</strong>&nbsp;add these permissions. </p>



<pre class="wp-block-code"><code>&lt;uses-permission android:name="android.permission.INTERNET" />
    &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /></code></pre>



<p>your AndroidManifest.xml file will look like as below:-</p>



<pre class="wp-block-code"><code>&lt;?xml version="1.0" encoding="utf-8"?>
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.uploadfile">
    &lt;uses-permission android:name="android.permission.INTERNET" />
    &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />


    &lt;application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:usesCleartextTraffic="true"
        android:theme="@style/AppTheme">

        &lt;activity android:name=".MainActivity">
            &lt;intent-filter>
                &lt;action android:name="android.intent.action.MAIN" />

                &lt;category android:name="android.intent.category.LAUNCHER" />
            &lt;/intent-filter>
        &lt;/activity>
    &lt;/application>

&lt;/manifest></code></pre>



<h2>5. User Interface</h2>



<p> Now inside&nbsp;<strong>activity_main.xml</strong>&nbsp;and write the following XML code into your activity_main.xml. </p>



<pre class="wp-block-code"><code>&lt;?xml version="1.0" encoding="utf-8"?>
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    &lt;LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:orientation="vertical">
        &lt;ImageView
            android:id="@+id/imageView"
            android:layout_width="match_parent"
            android:layout_height="200dp" />

        &lt;TextView
            android:id="@+id/textview"
            android:hint="NO Image Slected"
            android:layout_gravity="center"
            android:gravity="center_horizontal"
            android:textStyle="bold"
            android:textSize="20sp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        &lt;Button
            android:id="@+id/buttonUploadImage"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:text="Upload Image" />



    &lt;/LinearLayout>

&lt;/RelativeLayout>
</code></pre>



<h2>6. VolleyMultipartRequest</h2>



<center>
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads" style="display:inline-block;" data-ad-client="ca-pub-3804472713147276" data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>



<p> Here, we need to perform a multipart request. But the problem is volley doesn’t support multipart requests directly. So that is why we need to create our Custom Volley Request. </p>



<p>Create a java class with VolleyMultipartRequest and write the below code in that file.</p>



<pre class="wp-block-code"><code>// VolleyMultipartRequest.java

public class VolleyMultipartRequest extends Request&lt;NetworkResponse> {


    private final String twoHyphens = "--";
    private final String lineEnd = "\r\n";
    private final String boundary = "apiclient-" + System.currentTimeMillis();

    private Response.Listener&lt;NetworkResponse> mListener;
    private Response.ErrorListener mErrorListener;
    private Map&lt;String, String> mHeaders;


    public VolleyMultipartRequest(int method, String url,
                                  Response.Listener&lt;NetworkResponse> listener,
                                  Response.ErrorListener errorListener) {
        super(method, url, errorListener);
        this.mListener = listener;
        this.mErrorListener = errorListener;
    }

    @Override
    public Map&lt;String, String> getHeaders() throws AuthFailureError {
        return (mHeaders != null) ? mHeaders : super.getHeaders();
    }

    @Override
    public String getBodyContentType() {
        return "multipart/form-data;boundary=" + boundary;
    }

    @Override
    public byte[] getBody() throws AuthFailureError {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        DataOutputStream dos = new DataOutputStream(bos);

        try {
            // populate text payload
            Map&lt;String, String> params = getParams();
            if (params != null &amp;&amp; params.size() > 0) {
                textParse(dos, params, getParamsEncoding());
            }

            // populate data byte payload
            Map&lt;String, DataPart> data = getByteData();
            if (data != null &amp;&amp; data.size() > 0) {
                dataParse(dos, data);
            }

            // close multipart form data after text and file data
            dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);

            return bos.toByteArray();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * Custom method handle data payload.
     *
     * @return Map data part label with data byte
     * @throws AuthFailureError
     */
    protected Map&lt;String, DataPart> getByteData() throws AuthFailureError {
        return null;
    }

    @Override
    protected Response&lt;NetworkResponse> parseNetworkResponse(NetworkResponse response) {
        try {
            return Response.success(
                    response,
                    HttpHeaderParser.parseCacheHeaders(response));
        } catch (Exception e) {
            return Response.error(new ParseError(e));
        }
    }

    @Override
    protected void deliverResponse(NetworkResponse response) {
        mListener.onResponse(response);
    }

    @Override
    public void deliverError(VolleyError error) {
        mErrorListener.onErrorResponse(error);
    }

    /**
     * Parse string map into data output stream by key and value.
     *
     * @param dataOutputStream data output stream handle string parsing
     * @param params           string inputs collection
     * @param encoding         encode the inputs, default UTF-8
     * @throws IOException
     */
    private void textParse(DataOutputStream dataOutputStream, Map&lt;String, String> params, String encoding) throws IOException {
        try {
            for (Map.Entry&lt;String, String> entry : params.entrySet()) {
                buildTextPart(dataOutputStream, entry.getKey(), entry.getValue());
            }
        } catch (UnsupportedEncodingException uee) {
            throw new RuntimeException("Encoding not supported: " + encoding, uee);
        }
    }

    /**
     * Parse data into data output stream.
     *
     * @param dataOutputStream data output stream handle file attachment
     * @param data             loop through data
     * @throws IOException
     */
    private void dataParse(DataOutputStream dataOutputStream, Map&lt;String, DataPart> data) throws IOException {
        for (Map.Entry&lt;String, DataPart> entry : data.entrySet()) {
            buildDataPart(dataOutputStream, entry.getValue(), entry.getKey());
        }
    }

    /**
     * Write string data into header and data output stream.
     *
     * @param dataOutputStream data output stream handle string parsing
     * @param parameterName    name of input
     * @param parameterValue   value of input
     * @throws IOException
     */
    private void buildTextPart(DataOutputStream dataOutputStream, String parameterName, String parameterValue) throws IOException {
        dataOutputStream.writeBytes(twoHyphens + boundary + lineEnd);
        dataOutputStream.writeBytes("Content-Disposition: form-data; name=\"" + parameterName + "\"" + lineEnd);
        dataOutputStream.writeBytes(lineEnd);
        dataOutputStream.writeBytes(parameterValue + lineEnd);
    }

    /**
     * Write data file into header and data output stream.
     *
     * @param dataOutputStream data output stream handle data parsing
     * @param dataFile         data byte as DataPart from collection
     * @param inputName        name of data input
     * @throws IOException
     */
    private void buildDataPart(DataOutputStream dataOutputStream, DataPart dataFile, String inputName) throws IOException {
        dataOutputStream.writeBytes(twoHyphens + boundary + lineEnd);
        dataOutputStream.writeBytes("Content-Disposition: form-data; name=\"" +
                inputName + "\"; filename=\"" + dataFile.getFileName() + "\"" + lineEnd);
        if (dataFile.getType() != null &amp;&amp; !dataFile.getType().trim().isEmpty()) {
            dataOutputStream.writeBytes("Content-Type: " + dataFile.getType() + lineEnd);
        }
        dataOutputStream.writeBytes(lineEnd);

        ByteArrayInputStream fileInputStream = new ByteArrayInputStream(dataFile.getContent());
        int bytesAvailable = fileInputStream.available();

        int maxBufferSize = 1024 * 1024;
        int bufferSize = Math.min(bytesAvailable, maxBufferSize);
        byte[] buffer = new byte[bufferSize];

        int bytesRead = fileInputStream.read(buffer, 0, bufferSize);

        while (bytesRead > 0) {
            dataOutputStream.write(buffer, 0, bufferSize);
            bytesAvailable = fileInputStream.available();
            bufferSize = Math.min(bytesAvailable, maxBufferSize);
            bytesRead = fileInputStream.read(buffer, 0, bufferSize);
        }

        dataOutputStream.writeBytes(lineEnd);
    }

    class DataPart {
        private String fileName;
        private byte[] content;
        private String type;

        public DataPart() {
        }

        DataPart(String name, byte[] data) {
            fileName = name;
            content = data;
        }

        String getFileName() {
            return fileName;
        }

        byte[] getContent() {
            return content;
        }

        String getType() {
            return type;
        }

    }
}
</code></pre>



<center>
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads" style="display:inline-block;" data-ad-client="ca-pub-3804472713147276" data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>



<h2>7. Upload file/image to the server.</h2>



<p>Now, the main thing to upload files/images to the server. We will do it inside the MainActivity.java file. </p>



<p>write the below code to your MainActivity.java file.</p>



<pre class="wp-block-code"><code>//MainActivity.java

public class MainActivity extends AppCompatActivity {


    private static final String ROOT_URL = "http://seoforworld.com/api/v1/file-upload.php";
    private static final int REQUEST_PERMISSIONS = 100;
    private static final int PICK_IMAGE_REQUEST =1 ;
    private Bitmap bitmap;
    private String filePath;
    ImageView imageView;
    TextView textView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //initializing views
        imageView =  findViewById(R.id.imageView);
        textView =  findViewById(R.id.textview);

        //adding click listener to button
        findViewById(R.id.buttonUploadImage).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if ((ContextCompat.checkSelfPermission(getApplicationContext(),
                        Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) &amp;&amp; (ContextCompat.checkSelfPermission(getApplicationContext(),
                        Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)) {
                    if ((ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this,
                            Manifest.permission.WRITE_EXTERNAL_STORAGE)) &amp;&amp; (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this,
                            Manifest.permission.READ_EXTERNAL_STORAGE))) {

                    } else {
                        ActivityCompat.requestPermissions(MainActivity.this,
                                new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE},
                                REQUEST_PERMISSIONS);
                    }
                } else {
                    Log.e("Else", "Else");
                    showFileChooser();
                }


            }
        });
    }

    private void showFileChooser() {
        Intent intent = new Intent();
        intent.setType("image/*");
        intent.setAction(Intent.ACTION_GET_CONTENT);
        startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST);
    }

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (requestCode == PICK_IMAGE_REQUEST &amp;&amp; resultCode == RESULT_OK &amp;&amp; data != null &amp;&amp; data.getData() != null) {
            Uri picUri = data.getData();
            filePath = getPath(picUri);
            if (filePath != null) {
                try {

                    textView.setText("File Selected");
                    Log.d("filePath", String.valueOf(filePath));
                    bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), picUri);
                    uploadBitmap(bitmap);
                    imageView.setImageBitmap(bitmap);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            else
            {
                Toast.makeText(
                       MainActivity.this,"no image selected",
                                 Toast.LENGTH_LONG).show();
            }
        }

    }
    public String getPath(Uri uri) {
        Cursor cursor = getContentResolver().query(uri, null, null, null, null);
        cursor.moveToFirst();
        String document_id = cursor.getString(0);
        document_id = document_id.substring(document_id.lastIndexOf(":") + 1);
        cursor.close();

        cursor = getContentResolver().query(
                android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                null, MediaStore.Images.Media._ID + " = ? ", new String[]{document_id}, null);
        cursor.moveToFirst();
        String path = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA));
        cursor.close();

        return path;
    }


    public byte[] getFileDataFromDrawable(Bitmap bitmap) {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        bitmap.compress(Bitmap.CompressFormat.PNG, 80, byteArrayOutputStream);
        return byteArrayOutputStream.toByteArray();
    }

    private void uploadBitmap(final Bitmap bitmap) {

        VolleyMultipartRequest volleyMultipartRequest = new VolleyMultipartRequest(Request.Method.POST, ROOT_URL,
                new Response.Listener&lt;NetworkResponse>() {
                    @Override
                    public void onResponse(NetworkResponse response) {
                        try {
                            JSONObject obj = new JSONObject(new String(response.data));
                            Toast.makeText(getApplicationContext(), obj.getString("message"), Toast.LENGTH_SHORT).show();
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_LONG).show();
                        Log.e("GotError",""+error.getMessage());
                    }
                }) {

          
            @Override
            protected Map&lt;String, DataPart> getByteData() {
                Map&lt;String, DataPart> params = new HashMap&lt;>();
                long imagename = System.currentTimeMillis();
                params.put("image", new DataPart(imagename + ".png", getFileDataFromDrawable(bitmap)));
                return params;
            }
        };

        //adding the request to volley
        Volley.newRequestQueue(this).add(volleyMultipartRequest);
    }

}
</code></pre>



<h2>8. Above code explanation.</h2>



<p>The below code is used to take permission from the device for access gallery on Button click.</p>



<pre class="wp-block-code"><code>findViewById(R.id.buttonUploadImage).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if ((ContextCompat.checkSelfPermission(getApplicationContext(),
                        Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) &amp;&amp; (ContextCompat.checkSelfPermission(getApplicationContext(),
                        Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)) {
                    if ((ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this,
                            Manifest.permission.WRITE_EXTERNAL_STORAGE)) &amp;&amp; (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this,
                            Manifest.permission.READ_EXTERNAL_STORAGE))) {

                    } else {
                        ActivityCompat.requestPermissions(MainActivity.this,
                                new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE},
                                REQUEST_PERMISSIONS);
                    }
                } else {
                    Log.e("Else", "Else");
                    showFileChooser();
                }


            }
        });</code></pre>



<p>In the MainActivity.java file, Function <strong>showFileChooser()</strong> is used to choose an image from the device gallery. </p>



<p>And, To complete the&nbsp;image choosing process we need to override the <strong>onActivityResult()</strong> method. </p>



<p><strong>getPath()</strong> method is used to get the absolute path of the file/image.</p>



<p> And, <strong>uploadBitmap()</strong> method is used to upload file/image to the server.</p>



<center>
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads" style="display:inline-block;" data-ad-client="ca-pub-3804472713147276" data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>



<h2>9. Run the Project</h2>



<p>On running the project you will get the following output.</p>



<p>a. Open the App</p>



<figure class="wp-block-image"><img src="https://www.maxester.com/blog/wp-content/uploads/2019/10/image-473x1024.png" alt="" class="wp-image-684" srcset="https://www.maxester.com/blog/wp-content/uploads/2019/10/image-473x1024.png 473w, https://www.maxester.com/blog/wp-content/uploads/2019/10/image-138x300.png 138w, https://www.maxester.com/blog/wp-content/uploads/2019/10/image-768x1664.png 768w, https://www.maxester.com/blog/wp-content/uploads/2019/10/image.png 1080w" sizes="(max-width: 473px) 100vw, 473px" /><figcaption>www.maxester.com</figcaption></figure>



<p>b. Click on the upload image button and give permission.</p>



<figure class="wp-block-image"><img src="https://www.maxester.com/blog/wp-content/uploads/2019/10/image2-473x1024.png" alt="" class="wp-image-686" srcset="https://www.maxester.com/blog/wp-content/uploads/2019/10/image2-473x1024.png 473w, https://www.maxester.com/blog/wp-content/uploads/2019/10/image2-138x300.png 138w, https://www.maxester.com/blog/wp-content/uploads/2019/10/image2-768x1664.png 768w, https://www.maxester.com/blog/wp-content/uploads/2019/10/image2.png 1080w" sizes="(max-width: 473px) 100vw, 473px" /></figure>



<p>c. Image/File Uploaded</p>



<figure class="wp-block-image"><img src="https://www.maxester.com/blog/wp-content/uploads/2019/10/image3-473x1024.png" alt="" class="wp-image-687" srcset="https://www.maxester.com/blog/wp-content/uploads/2019/10/image3-473x1024.png 473w, https://www.maxester.com/blog/wp-content/uploads/2019/10/image3-138x300.png 138w, https://www.maxester.com/blog/wp-content/uploads/2019/10/image3-768x1664.png 768w, https://www.maxester.com/blog/wp-content/uploads/2019/10/image3.png 1080w" sizes="(max-width: 473px) 100vw, 473px" /></figure>



<a href="https://www.maxester.com/zip/Upload-File-04-10-2019.zip">Download Source Code</a>



<p>Please Check PHP code using this URL <a href="https://www.maxester.com/blog/2020/07/28/php-code-for-upload-image-to-server-using-volley-in-android/">https://www.maxester.com/blog/2020/07/28/php-code-for-upload-image-to-server-using-volley-in-android/</a></p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2019/10/04/upload-file-image-to-the-server-using-volley-in-android/">Upload File/Image to the server using Volley in Android.</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.maxester.com/blog/2019/10/04/upload-file-image-to-the-server-using-volley-in-android/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>JSON Parsing In Android</title>
		<link>https://www.maxester.com/blog/2019/09/20/json-parsing-in-android/</link>
		<comments>https://www.maxester.com/blog/2019/09/20/json-parsing-in-android/#respond</comments>
		<pubDate>Fri, 20 Sep 2019 07:50:32 +0000</pubDate>
		<dc:creator><![CDATA[Birjesh Gupta]]></dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">https://www.maxester.com/blog/?p=652</guid>
		<description><![CDATA[<p>JSON (Javascript Object Notation) is very light-weight, structured, easy to parse and much human-readable. JSON is the best alternative to XML when your android app needs to interchange data with your server. The JSON format was originally specified and developed&#8230;</p>
<p><a href="https://www.maxester.com/blog/2019/09/20/json-parsing-in-android/" class="btn-more">Read More<span class="arrow-more">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2019/09/20/json-parsing-in-android/">JSON Parsing In Android</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[
<p> JSON (Javascript Object Notation) is very light-weight, structured, easy to parse and much human-readable. JSON is the best alternative to XML when your android app needs to interchange data with your server. </p>



<p><br>The JSON format was originally specified and developed by&nbsp;<strong>Douglas Crockford</strong>&nbsp;and is described in RFC 4627 license. <br>The JSON filename extension is&nbsp;.json.</p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<h3>Advantage of JSON over XML</h3>



<p> 1) JSON is faster and easier than XML for AJAX applications.<br>&nbsp;2) Unlike XML, it is shorter and quicker to read and write.  <br>3) It uses array. </p>



<p>JSON notation contains these basic elements: <br></p>



<h2> <br><strong>1. JSON Objects:</strong>&nbsp;  </h2>



<p>

A JSON object contains key/value pairs like a map. The keys are strings and the values are the JSON types. Keys and values are separated by a comma. The curly braces ({ }) represents the JSON object.

</p>



<p><a href="https://developer.android.com/reference/org/json/JSONObject">https://developer.android.com/reference/org/json/JSONObject</a></p>



<pre class="wp-block-code"><code>{  
    "employee": {  
        "firstname": "birjesh",   
        "lastname": "gupta",   
        "email": "XXXXXX@mail.com" 
    }  
}  
</code></pre>



<p>Here, &#8220;employee&#8221; is the JSON Object name.</p>



<p></p>



<h2> <br><strong>2. JSON Arrays:</strong></h2>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<p> <br><a href="https://developer.android.com/reference/org/json/JSONArray">https://developer.android.com/reference/org/json/JSONArray</a> <br> </p>



<p>The square bracket ([ ]) represents the JSON array. &nbsp;  </p>



<pre class="wp-block-code"><code>"Employee" :  
    [  
     {"id":"101","name":"Ravi","salary":"50000"},  
     {"id":"102","name":"Vimal","salary":"60000"}  
    ]   </code></pre>



<p>Here, &#8220;Employee&#8221; is the JSON Array Name.</p>



<pre class="wp-block-code"><code></code></pre>



<h2> <br>Example of Android JSON Parsing:- </h2>



<p>now, we are going to see an example of JSON parsing in Android:  </p>



<p><strong>1</strong>. Create a new project in Android Studio from&nbsp;</p>



<p><strong>File &#8211;&gt;New Project</strong>&nbsp;and fill out the required details.</p>



<p><strong>2</strong>. As we are fetching the JSON, we need to add&nbsp;<em>INTERNET</em>&nbsp;permission in AndroidManifest.xml file. Open&nbsp;<strong>AndroidManifest.xml</strong>&nbsp;and add the following permission.</p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<pre class="wp-block-code"><code>&lt;uses-permission android:name="android.permission.INTERNET" /></code></pre>



<pre class="wp-block-code"><code>
//AndroidManifest.xml

&lt;?xml version="1.0" encoding="utf-8"?>
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.jsonparsing">
    &lt;uses-permission android:name="android.permission.INTERNET" />

    &lt;application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        &lt;activity android:name=".MainActivity">
            &lt;intent-filter>
                &lt;action android:name="android.intent.action.MAIN" />

                &lt;category android:name="android.intent.category.LAUNCHER" />
            &lt;/intent-filter>
        &lt;/activity>
    &lt;/application>

&lt;/manifest></code></pre>



<p>3. Create Assets folder inside your project like below.</p>



<p>Right-click on the app<br><strong>app</strong>&nbsp;<strong>&#8211;&gt;new&#8211;&gt;folder&#8211;&gt;Assets folder&#8211;&gt;Finish</strong><br>Assets Folder Created.</p>



<p>4. Create a local JSON file in the Assets folder named <strong>sample.json&nbsp;</strong>like&nbsp;below.</p>



<p>Now Right-click on&nbsp;assets folder<br><strong>assets folder&#8211;&gt;new&#8211;&gt;file&#8211;&gt;filename.json&#8211;&gt;ok</strong><br>New JSON File Created.<br>write the below code in your JSON file</p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<pre class="wp-block-code"><code>//JSON Example:
//sample.json
{"employee":[{
  "firstname": "birjesh",
  "lastname" : "gupta",
  "email": "XXXXXX@gmail.com",
  "gender": "male",
  "phone": "89XXXXXX98"
},
  {
    "firstname": "suresh",
    "lastname" : "singh",
    "email": "XXXXXX@gmail.com",
    "gender": "male",
    "phone": "87XXXXXX87"
  },
  {
    "firstname": "manish",
    "lastname" : "sharma",
    "email": "XXXXXX@gmail.com",
    "gender": "male",
    "phone": "96XXXXXX69"
  },
  {
    "firstname": "gourav",
    "lastname" : "ganguly",
    "email": "XXXXXX@gmail.com",
    "gender": "male",
    "phone": "90XXXXXX09"
  },
  {
    "firstname": "mohan",
    "lastname" : "batra",
    "email": "XXXXXX@gmail.com",
    "gender": "male",
    "phone": "87XXXXXX87"
  }
]
}


</code></pre>



<p>5. Open the layout file of the main activity (<strong>activity_main.xml</strong>) and add a ListView element like below.</p>



<pre class="wp-block-code"><code>//activity_main.xml

&lt;?xml version="1.0" encoding="utf-8"?>
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".activity.MainActivity">

    &lt;ListView
        android:id="@+id/list_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

&lt;/LinearLayout></code></pre>



<p>6. Create another layout file named&nbsp;<strong>list_view_item.xml</strong>&nbsp;with the following content. This will be used to render a single list item view.</p>



<pre class="wp-block-code"><code>//list_view_item.xml

&lt;?xml version="1.0" encoding="utf-8"?>
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:padding="10dp"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    &lt;TextView
        android:id="@+id/person_name"
        android:layout_width="wrap_content"
        android:text="Name"
        android:layout_height="wrap_content"
        android:textSize="20sp"/>
    &lt;TextView
        android:id="@+id/person_email"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="email"
        android:textSize="20sp"/>
    &lt;TextView
        android:id="@+id/person_gender"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="gender"
        android:textSize="20sp"/>
    &lt;TextView
        android:id="@+id/person_phone"
        android:layout_width="wrap_content"
        android:text="phone"
        android:layout_height="wrap_content"
        android:textSize="20sp"/>

&lt;/LinearLayout>
</code></pre>



<p>7. Create a java class named <strong>Constants.java</strong> and write below code to use get the value from JSON file and set to TextView.</p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<pre class="wp-block-code"><code>//Constants.java

public class Constants {

    public static final String FIRST_NAME = "firstname";
    public static final String LAST_NAME = "lastname";
    public static final String EMAIL = "email";
    public static final String GENDER = "gender";
    public static final String PHONE = "phone";
    private HashMap&lt;String,String> relateds;

    //getter method to get the json data
    public HashMap&lt;String,String> getRelateds() {
        return relateds;
    }

    //setter method to set json data on textview
    public void setRelateds(HashMap&lt;String, String> relateds) {
        this.relateds = relateds;
    }
}</code></pre>



<p>8. Now, Open the MainActivity.java class and create a <strong>public String readJsonFromAssets()</strong> method to open and use the local JSON file as shown below:-</p>



<pre class="wp-block-code"><code>//readJsonFromAssets()

//Read and open the .json file
public String readJsonFromAssets()
    {
        String json = null;
        try {
            InputStream is = getAssets().open("sample.json");
            int size = is.available();
            byte[] buffer =new byte[size];
            is.read(buffer);
            is.close();
            json = new String(buffer,"UTF-8");
        } catch (IOException e) {
            e.printStackTrace();
        }
        return json;
    }</code></pre>



<p>as we opened JSON file now in <strong>onCreate()</strong> method<br><strong>loadJson()</strong>&nbsp;is called to get the JSON from the file. Once the JSON is fetched, it is parsed and each contact is added to an array list. Write below code in your MainActivity.java class.</p>



<p>But,</p>



<p> Also, note that I have used&nbsp;<strong>getJSONArray()</strong>&nbsp;or&nbsp;<strong>getJSONObject()</strong>&nbsp;method depending on the type of node. </p>



<pre class="wp-block-code"><code>//MainActivity.java

public class MainActivity extends AppCompatActivity {

    ArrayList&lt;Constants> dataModel = new ArrayList&lt;>();
    ListView listview;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        listview = findViewById(R.id.list_view);
        loadJson();
    }

    //Load json data from json file
    private void loadJson() {
        HashMap&lt;String, String> map = null;
        try {
            JSONObject object = new JSONObject(readJsonFromAssets());
            JSONArray jarray = object.getJSONArray("employee");

            for(int i=0; i&lt;jarray.length();i++)
            {
                //create Constants class object to call getter method
                Constants constant = new Constants();
                JSONObject obj = jarray.getJSONObject(i);
                 map = new HashMap&lt;>();

                map.put(Constants.FIRST_NAME,obj.getString(Constants.FIRST_NAME));
                map.put(Constants.LAST_NAME,obj.getString(Constants.LAST_NAME));
                map.put(Constants.EMAIL,obj.getString(Constants.EMAIL));
                map.put(Constants.GENDER,obj.getString(Constants.GENDER));
                map.put(Constants.PHONE,obj.getString(Constants.PHONE));

                //Add json data to setter method of Constants class
                constant.setRelateds(map);
               
                //Add object to Arraylist
                dataModel.add(constant);
            }
            CustomViewAdapter customAdaptor = new CustomViewAdapter(this, dataModel);

            listview.setAdapter(customAdaptor);

        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

   //Read and open .json file
    public String readJsonFromAssets()
    {
        String json = null;
        try {
            InputStream is = getAssets().open("sample.json");
            int size = is.available();
            byte[] buffer =new byte[size];
            is.read(buffer);
            is.close();
            json = new String(buffer,"UTF-8");
        } catch (IOException e) {
            e.printStackTrace();
        }
        return json;
    }
}

</code></pre>



<p>9. Create a <strong>CustomViewAdapter.java</strong> class which extends <strong>BaseAdapter.class</strong> and implements its methods to set JSON string values into your <strong>TextView </strong>like below.</p>



<p>Write below code into you CustomView class.</p>



<p></p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<pre class="wp-block-code"><code>//CustomViewAdapter extends BaseAdapter


public class CustomViewAdapter extends BaseAdapter {

    Context context;
    ArrayList&lt;Constants> datamodel;
    public CustomViewAdapter(Context context, ArrayList&lt;Constants> dataModel) {
        this.context = context;
        this.datamodel = dataModel;
    }

    @Override
    public int getCount() {
        return datamodel.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int position, View view, ViewGroup parent) {

        TextView name,email,gender,phone;

        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View itemview = inflater.inflate(R.layout.list_view_item, parent, false);

        name = itemview.findViewById(R.id.person_name);
        email = itemview.findViewById(R.id.person_email);
        gender = itemview.findViewById(R.id.person_gender);
        phone = itemview.findViewById(R.id.person_phone);

        name.setText(datamodel.get(position).getRelateds().get(Constants.FIRST_NAME)
                +" "+datamodel.get(position).getRelateds().get(Constants.LAST_NAME));

        email.setText(datamodel.get(position).getRelateds().get(Constants.EMAIL              ));
        gender.setText(datamodel.get(position).getRelateds().get(Constants.GENDER));
        phone.setText(datamodel.get(position).getRelateds().get(Constants.PHONE));

        return itemview;
    }
}
</code></pre>



<pre class="wp-block-code"><code>LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View itemview = inflater.inflate(R.layout.list_view_item, parent, false);</code></pre>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<p>LayoutInflater is used to inflate the <strong>list_view_item.xml</strong> file.</p>



<pre class="wp-block-code"><code>        name.setText(datamodel.get(position).getRelateds().get(Constants.FIRST_NAME)
                +" "+datamodel.get(position).getRelateds().get(Constants.LAST_NAME));
</code></pre>



<pre class="wp-block-code"><code>In the above code, simply I concat the firstname and lastname using (+) operator.</code></pre>



<h2> <br>If you run the project, you can see JSON data populated into list view as shown in the below image. </h2>



<p></p>



<figure class="wp-block-image"><img src="https://www.maxester.com/blog/wp-content/uploads/2019/09/image1-473x1024.png" alt="" class="wp-image-669" srcset="https://www.maxester.com/blog/wp-content/uploads/2019/09/image1-473x1024.png 473w, https://www.maxester.com/blog/wp-content/uploads/2019/09/image1-138x300.png 138w, https://www.maxester.com/blog/wp-content/uploads/2019/09/image1-768x1664.png 768w, https://www.maxester.com/blog/wp-content/uploads/2019/09/image1.png 1080w" sizes="(max-width: 473px) 100vw, 473px" /><figcaption>maxester.com</figcaption></figure>



<p></p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<h2> <br> <strong>Project Structure</strong> Must be like below:- </h2>



<figure class="wp-block-image"><img src="https://www.maxester.com/blog/wp-content/uploads/2019/09/Capture1.png" alt="" class="wp-image-674" srcset="https://www.maxester.com/blog/wp-content/uploads/2019/09/Capture1.png 584w, https://www.maxester.com/blog/wp-content/uploads/2019/09/Capture1-218x300.png 218w" sizes="(max-width: 584px) 100vw, 584px" /></figure>



<a href="https://www.maxester.com/zip/JSON-Parsing-sep-19-2019.zip">Download Zip file here</a>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2019/09/20/json-parsing-in-android/">JSON Parsing In Android</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.maxester.com/blog/2019/09/20/json-parsing-in-android/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
