13 December, 2015

Android JSON Parsing Using okHttp Example with New Material Design Library

Hello to everyone, Today I am posting about JSON Parsing in Android using okHttp Library.

HTTP is the way modern applications network. It’s how we exchange data & media. Doing HTTP efficiently makes your stuff load faster and saves bandwidth.

I found many documentation to understand okHttp but I want to share my example which i have created as Demo.


1. What is JSON?
2. Android Studio Basics


Create New Project in Android Studio android follow the instructions.

Permissions in AndroidManifest.xml

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

Add following gradle dependency in build.gradle:

compile 'com.android.support:appcompat-v7:23.1.0'  
compile 'com.android.support:design:23.1.0'  
compile 'com.squareup.okhttp:okhttp:2.0.0'  

JSON Parser File (Copy Class and Paste in Your src Folder):

  * @author Pratik Butani  
 public class JSONParser {  
    * URLS  
   private static final String MAIN_URL = "http://pratikbutani.x10.mx/json_data.json";  
    * TAGs Defined Here...  
   public static final String TAG = "TAG";  
    * Key to Send  
   private static final String KEY_USER_ID = "user_id";  
    * Response  
   private static Response response;  
    * Get Table Booking Charge  
    * @return JSON Object  
   public static JSONObject getDataFromWeb() {  
     try {  
       OkHttpClient client = new OkHttpClient();  
       Request request = new Request.Builder()  
       response = client.newCall(request).execute();  
       return new JSONObject(response.body().string());  
     } catch (@NonNull IOException | JSONException e) {  
       Log.e(TAG, "" + e.getLocalizedMessage());  
     return null;  

Layout File: activity_main.xml

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"  
       app:popupTheme="@style/AppTheme.PopupOverlay" />  
   <ListView app:layout_behavior="@string/appbar_scrolling_view_behavior"  
     android:layout_height="match_parent" />  
     android:src="@android:drawable/stat_sys_download" />  


 public class MainActivity extends AppCompatActivity {  
   private ListView listView;  
   private ArrayList<String> list;  
   private ArrayAdapter<String> adapter;  
   protected void onCreate(Bundle savedInstanceState) {  
     Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);  
      * Array List for Binding Data from JSON to this List  
     list = new ArrayList<>();  
      * Binding that List to Adapter  
     adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, android.R.id.text1, list);  
      * Getting List and Setting List Adapter  
     listView = (ListView) findViewById(R.id.listView);  
     listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {  
       public void onItemClick(AdapterView<?> parent, View view, int position, long id) {  
         Snackbar.make(findViewById(R.id.parentLayout), list.get(position), Snackbar.LENGTH_LONG).show();  
     FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);  
     fab.setOnClickListener(new View.OnClickListener() {  
       public void onClick(@NonNull View view) {  
          * Just to know onClick and Printing Hello Toast in Center.  
         Toast toast = Toast.makeText(getApplicationContext(), "Hello in Center", Toast.LENGTH_LONG);  
          * Checking Internet Connection  
         if (InternetConnection.checkConnection(getApplicationContext())) {  
           new GetDataTask().execute();  
         } else {  
           Snackbar.make(view, "Internet Connection Not Available", Snackbar.LENGTH_LONG).show();  
    * Creating Get Data Task for Getting Data From Web  
   class GetDataTask extends AsyncTask<Void, Void, Void> {  
     ProgressDialog dialog;  
     protected void onPreExecute() {  
        * Progress Dialog for User Interaction  
       dialog = new ProgressDialog(MainActivity.this);  
       dialog.setTitle("Hey Wait Please...");  
       dialog.setMessage("I am getting your JSON");  
     protected Void doInBackground(Void... params) {  
        * Getting JSON Object from Web Using okHttp  
       JSONObject jsonObject = JSONParser.getDataFromWeb();  
       try {  
          * Check Whether Its NULL???  
         if (jsonObject != null) {  
            * Check Length...  
           if(jsonObject.length() > 0) {  
              * Getting Array named "contacts" From MAIN Json Object  
             JSONArray array = jsonObject.getJSONArray(Keys.KEY_CONTACTS);  
              * Check Length of Array...  
             int lenArray = array.length();  
             if(lenArray > 0) {  
               for(int jIndex = 0; jIndex < lenArray; jIndex++) {  
                  * Getting Inner Object from contacts array...  
                  * and  
                  * From that We will get Name of that Contact  
                 JSONObject innerObject = array.getJSONObject(jIndex);  
                 String name = innerObject.getString(Keys.KEY_NAME);  
                  * Getting Object from Object "phone"  
                 JSONObject phoneObject = innerObject.getJSONObject(Keys.KEY_PHONE);  
                 String phone = phoneObject.getString(Keys.KEY_MOBILE);  
                  * Adding name and phone concatenation in List...  
                 list.add(name + " - " + phone);  
         } else {  
       } catch (JSONException je) {  
         Log.i(JSONParser.TAG, "" + je.getLocalizedMessage());  
       return null;  
     protected void onPostExecute(Void aVoid) {  
        * Checking if List size if more than zero then  
        * Update ListView  
       if(list.size() > 0) {  
       } else {  
         Snackbar.make(findViewById(R.id.parentLayout), "No Data Found", Snackbar.LENGTH_LONG).show();  


Download Demo from GitHub: JSON Parsing using okHttp

Hope You will enjoy with Android JSON Parsing with okHttp and basic of Android Design Library.

Any question, Any query, Any suggestion Always Welcome. Do comment.

Thank you.

11 September, 2015

Paryushan Parv - Janism

આત્મીય સ્નેહીજનો, પ્રણામ, જય જિનેન્દ્ર ,

આપ સહુ શાતામા હશો. સઘળું આનંદ મંગળ હશે. કદાચ સ્નેહીજનો શબ્દ પરીવાર માટે વાપરવામાં આવે છે, પરંતુ પરમાત્મ ભક્તિ દ્વારા બંધાયેલ આપણો આ સંબંધ એક પરિવારજન સમાન જ છે.

જોત-જોતામાં પર્યુષણ મહાપર્વ પણ આવી ગયા..!

સર્વજીવો સાથેની મૈત્રી નો કરાર કરવાનો ઉત્તમ અવસર એટલે જ પર્યુષણ..!

કર્મોના ભાર થી દબાયેલાં આત્માને પુણ્યથી ઉગારી લેવાનો અવસર એટલે જ પર્યુષણ..!

ને તમારા ને અમારા આ આત્મીય સંબંધોને સંવત્સરી મિચ્છામી દુક્કડમ્ થી શણગારવાનો અવસર એટલે જ પર્યુષણ..!

ભવિષ્યમાં આવનારા પ્રભુ-ભક્તિ, ગુરુ-ભક્તિ અને જિન-શાસન શોભા વૃદ્ધિના અવસરો એ ફરી ફરી ને આપણું મિલન થતું રહે એજ અભ્યર્થના સહ..

સંવત્સરી મિચ્છામી દુક્કડમ્..

18 August, 2015

MarshMallow : Android M is now #MarshMallow

Get your apps ready for Android Marshmallow:

The final Android 6.0 SDK is now available to download via the SDK Manager in Android Studio. With the Android 6.0 SDK you have access to the final Android APIs and the latest build tools so that you can target API 23. Once you have downloaded the Android 6.0 SDK into Android Studio, update your app project compileSdkVersion to 23 and you are ready to test your app with the new platform. You can also update your app to targetSdkVersion to 23 test out API 23 specific features like auto-backup and app permissions.

Along with the Android 6.0 SDK, we also updated the Android Support Library to v23. The new Android Support library makes it easier to integrate many of the new platform APIs, such as permissions and fingerprint support, in a backwards-compatible manner. This release contains a number of new support libraries including: customtabs, percent, recommendation, preference-v7, preference-v14, and preference-leanback-v17.

Check your App Permissions:

Along with the new platform features like fingerprint support and Doze power saving mode, Android Marshmallow features anew permissions model that streamlines the app install and update process. To give users this flexibility and to make sure your app behaves as expected when an Android Marshmallow user disables a specific permission, it’s important that you update your app to target API 23, and test the app thoroughly with Android Marshmallow users.

How to Get the Update:

The Android emulator system images and developer preview system images have been updated for supported Nexus devices (Nexus 5, Nexus 6, Nexus 9 & Nexus Player) to help with your testing. You can download the device system images from the developer preview site. Also, similar to the previous developer update, supported Nexus devices will receive an Over-the-Air (OTA) update over the next couple days.

Although the Android 6.0 SDK is final, the devices system images are still developer preview versions. The preview images are near final but they are not intended for consumer use. Remember that when Android 6.0 Marshmallow launches to the public later this fall, you'll need to manually re-flash your device to a factory image to continue to receive consumer OTA updates for your Nexus device.

What is New

Compared to the previous developer preview update, you will find this final API update fairly incremental. You can check out all the API differences here, but a few of the changes since the last developer update include:
  • Android Platform Change:
    • Final Permissions User Interface — we updated the permissions user interface and enhanced some of the permissions behavior.
  • API Change:
    • Updates to the Fingerprint API — which enables better error reporting, better fingerprint enrollment experience, plus enumeration support for greater reliability.

Upload your Android Marshmallow apps to Google Play:

Google Play is now ready to accept your API 23 apps via the Google Play Developer Console on all release channels (Alpha, Beta & Production). At the consumer launch this fall, the Google Play store will also be updated so that the app install and update process supports the new permissions model for apps using API 23.

To make sure that your updated app runs well on Android Marshmallow and older versions, we recommend that you use Google Play’s newly improved beta testing feature to get early feedback, then do a staged rollout as you release the new version to all users.

01 August, 2015

Best Useful Links for Laravelers

Hello to all Laravelers,

Hope you are doing well with Laravel and Playing with Errors :)

I am basically Android Application Developer and Love to Stackoverflowing. I just found following links by My Research while learning Laravel. It will may useful to you also.


People to Follow:

PHP PaaS(Platform as a Service) Providers:

Laravel Chat:

#Laravel #Links #LaravelTutorials

Thank you..

14 July, 2015

How to debug Angular JavaScript Code

1. Chrome:

For Debug AngularJS in chrome you can use AngularJS Batarang. (From recent reviews on the plugin it seems like AngularJS Batarang is no longer being maintained. Tested in various versions of chrome does not work)

Here is the Link for description and Demo:

Introduction of Angular JS Batarang

Download chrome plugin from here: Chrome plugin for debug AngularJS

You can also refer this link: ng-book: Debugging AngularJS

2. Firefox:

For Firefox with the help of Firebug you can debug the code.

Also use this Firefox Add-Ons : AngScope: Add-ons for Firefox (Not official extension by AngularJS Team)

3. Debugging AngularJS:

Check the Link : Debugging AngularJS

Reference: http://stackoverflow.com/a/18782130/1318946

02 July, 2015

Google Drive : Create, Share and manage Custom Maps

Hey Howdy, Now Share your Custom Maps Whether you're planning your cricket schedule, learning about new things, or mapping your favorite places, Google My Maps makes it easy to put your world on a custom map.

As i saw post while googling, I just want to share it with you that you can access My Maps right from Google Drive on your Google Apps account, so it’s even easier to create, find and share your custom maps. 

Here are some examples: 

In the following image i am pointing out My Home Place and My Work Place. You can also see Route of both place. 

Whatever your needs, Google My Maps—now accessible in Google Drive—makes teaching, learning, and getting things done that much easier.

Special Thanks to Google for Education.

30 June, 2015

Android Multiple Selection Spinner Item with Filtration

I have recently posted problem on stackoverflow but didn't get response what i want, stuck with that problem for 2 days continuously and got the solution.

I just want to share it with all #androiders so they can take it easily.

I have created Git Repository MultiSelectSpinner so you can directly download demo of Multi Selection Spinner with Search Functionality and without Search Functionality.

Download Demo from HERE:

Demo of MultiSelectSpinner
MultiSelectSpinner without Search

MultiSelectSpinner with Search

Thank you :) Keep Sharing :)

29 June, 2015

Android Basics Tutorial, PPT, Demos : Workshop at OM VVIM - Morbi

I would like to share my experience of Android Expert Lecture at OM VVIM college - Morbi. First of all I am thankful of Respected Staff Members Especially Hardik Sir. It was very excellent Experience in My Life as a Teacher.
Lets talk  about what we have taken in Lecture:

Key Notes:

  1. What is Android?
  2. Why Android?
  3. Features of Android
  4. History of Android
  5. Android Architecture
  6. Android Application Components
  7. Creating First Android App
  8. Anatomy of Android Application
  9. Accessing Resources in Java
  10. Accessing Resources in XML
  11. Activity Life Cycle
  12. Service Life Cycle
  13. Intents
You can find here attached Android PPT File and some demos which we had learn in 
 our Workshop.

You can visit Java Robot Example :)

Please give me your valuable FEEDBACK.

10 June, 2015

Laravel 5.1 is Released

Laravel has just announced the immediate availability of v5.1. This marks the first release in Laravel’s history to offer long-time support. Let’s look at some of the new features and also learn more about it.

Long Term Support

Since originally launching in 2011, Laravel has always followed the "release early, release often" mantra which is popular in open source applications. With the historic rise in popularity of the framework, it was time to start focusing on the needs of large organizations and mission-critical applications that need security fixes but can’t upgrade quickly. Laravel 5.1 will now include 3 years of security fixes.
The long-term support is arguably the biggest feature in 5.1, but it includes several other new features.


The second big change is the “Commands” folder is being renamed to “Jobs” to indicate it’s primarily for queued jobs. This folder change will not be a backwards compatibility break.

New Documentation

The documentation has been completely reworked to offer more clarity, to be more in-depth, and to have a nicer flow. This was a huge undertaking and countless hours was spent fine-tuning each page.

Taylor said he would delay an entire Laravel release rather than release something with poor documentation, when asked if spending this much time on it was worth it. Another new documentation feature is real-time search with auto-complete.


The app and generators are converting to PSR-2. If you are not familiar with PSR-2, it’s a Coding Style Guide. The biggest change from current Laravel style is tabs to spaces and control structures will now go on the same line.

Resolve a service from blade

You can now resolve a service directly from a Blade Template:



Envoy runs local SSH scripts

Finally, and this is available now, Envoy allows you to run local scripts without SSH. See this pull request for more details. To get the latest version just run:


Middleware Parameters

This new feature allows you to pass parameters into the middleware. Here is a screenshot of a demo:

Broadcasting Events

Laravel already included a powerful event system and this new feature builds on that by allowing you to broadcast events over a websocket so your client can consume them. With this new feature, it makes creating real-time applications simple.

Better Application Unit Testing

With an inclusion of Laracasts integrated testing package testing your application is going to be easier than ever before.

public function testNewUserRegistration(){



CSRF Except

In Laravel 5.0 all requests are ran through the CSRF middleware and this is great for most use cases. However, one gotcha is using services with web hooks where you do not have the ability to set a token. A new feature in 5.1 is an except property on the VerifyCsrfToken class which will allow this to be easily over-ridden.


Where to go next

Head over to the new official documentation which includes everything you need to know about installation, upgrading, and all the framework features.

#laravel #laravel5.1 #laravel_new_release

04 March, 2015

The new Google Contacts: Bringing everyone together

From email to Hangouts to a good ol' fashioned phone call, you've got a lot of options to get in touch with someone. But keeping all those options organized for all your contacts...well, it can be a pain, especially when you need to find that information in a hurry!

So today we’re releasing a preview of the new Google Contacts that makes it easier to keep track of the people you know and get the info you need, fast. The new Google Contacts comes with a fresh look and feel, and conveniently pools together all your contacts, circles, and the people you talk to most in Gmail.

Easily get rid of duplicates:

No one likes having duplicate contacts, but they inevitably crop up. So we've rebuilt our “Find duplicates” feature from the ground up to help give you a quick and painless way to clean up your duplicates.

Keep your contacts up to date automatically:

As the people you know change jobs, cities, and names, it can be tough to stay up to date with their latest information. The new Contacts ensures that the info you see is still accurate and ready to use by blending your contact’s Google profile information with the stuff you already have.

See your recent emails & meetings:

Finally, you can now see your most recent emails and meetings with a person directly in their contact card. So whether it’s been two days or two years since your last conversation, it’s easier than ever to pick up right where you left off.

For people looking to access the preview through Gmail, keep an eye out over the next few weeks. In the meantime, you can try the new Google Contacts today by visiting contacts.google.com/preview. 

P.S. The new Contacts isn’t yet available for Google Apps customers, but we're working on it.

Originally Posted: Official Gmail Blog: The new Google Contacts: Bringing everyone together

Enjoy Contacting... :) :)

21 February, 2015

Create Your Brand (Personal Website)

Hello guys, Hope you doing well!

I want to share something new here, I found one website which is creating your brand like personal website. It is awesome If you have LinkedIn Account, it will directly take your info and gives you branded website as your personal website.

Generate a fully customizable personal website in seconds. Get started for free!


  1. Automation & Speed
  2. Easy Editing
  3. Advanced Themes
  4. Transferrable Content
  5. Mobile Friendly
  6. Custom Domain & Email

02 February, 2015

Whatsapp to launch free voice calling service soon

Popular messaging app, WhatsApp is all set to launch the existing app with new features that would push more people to download the application. However, there were lot of buzz that WhatsApp may launch free calling service this year.

WhatsApp recently launched WhatsApp Web, a browser-based service which allows you send and receive messages using your PC.

The Android version of the WhatsApp app exists in two builds – the stable branch which can be found on the Play Store and another one which is distributed directly from the company’s website.

The version on the company website, gets updated more frequently and has a lot of hidden features which undergo testing before it is ported as a stable build on the Play Store. The latest version on the company website had a lot of hidden secret screens that were unearthed.

Although officially unconfirmed, the screenshots point to the fact that voice calling is being tested on WhatsApp. The calling functionality and chatting functionality appear as separate. Call logs, dialling and contacts screen is handled by separate screens.

Another interesting feature includes call recording and playback.

There is no word out if this will be a paid app. But if the past is any indication, the voice calling feature will also be offered for free considering apps such as Viber, Line and Skype already offer it.


24 January, 2015

Moto G 2nd Gen. Lollipop - Setting Ringtones Problem

Hey Friends, Have you updated Lollipop in Moto G 2nd Gen? Hows it?

Moto G 2nd Gen with Lollipop Update

Recently I have updated Moto G 2nd Gen. with Lollipop Android 5.0.2. Its really awesome and quick use and User Friendly but i just got one problem that it is not supports set ringtones from sd card files.

I have tried many times to change it but not succeed and after all I have just move Ring Tone from SD card to Phone Memory and Its Works.

So just wanna share with you all that if you got any problem to set ringtone from SD card, just have to copy that ringtone to phone memory and the set as ringtone. You will enjoy your Music when some one calling you. Otherwise your phone ringing only default (Bell ringtone) ;) :)

Thank you.

#KeepSharing #KeepRinging

Now, Read Audio Clips on Facebook Messenger

Hey Friends, Hows going on?

We are already aware with Voice Messages in WhatsApp Application. Today I have read one updated news and i want to share with you that Now you can Send Audio Clips on Facebook Messenger Also.

Yeah.. Social networking site Facebook has launched a new feature for its messenger app that automatically transcribes any file sent as a voice recording and lets the people send voice clips to each other.

Facebook Messenger is receiving a sizeable update this evening, introducing thumb-happy texters into the world of real voice messaging (that thing you used to use a phone for). Now, jumping into the application and pressing on the "+" icon will pull up the usual set of messaging attachments with "Record Voice" being the newest option. The recipient can then listen to the recorded message at their leisure (this isn’t push-to-talk).

To send an audio clip, just tap the microphone icon, record the message and send.

The tool listens to the full audio clip and posts a typed version below the audio, media reports said.

The tool has been presently rolled out for a test group.

"We are always working on ways to make Messenger more useful. Facebook offers a feature that lets people send voice clips to their friends without having to type the text," said David Marcus, vice-president of messaging products at Facebook.

"Today, we are starting to roll out a small test that helps people read the voice clips they receive instead of having to play them out loud," he said in a statement.

While some would likely speculate this is Facebook challenging apps like Voxer I must say, sound quality isn't anywhere near the clarity of Voxer. Facebook Messenger voice messages sound like your typical cellular gibberish. Pity. Still, there’s no beating it if you've got your hands full and need to quickly respond to a Facebook buddy.
There’s also talk that Facebook is dabbling in VoIP capabilities for Facebookers in Canada, allowing users to place calls using their phone’s data connection as opposed to cellular voice minutes. Neato. Expect it to arrive stateside in the near future.

23 January, 2015

WhatsApp Web - Send Photos, Videos and Voice Messages

As we have seen in previous post WhatsApp on Web. Now you can learn here how to send Photos or Videos and Voice Messages from you PC in WhatsApp.

To send a photo or video:

  1. Click the attachment button  at the top of the chat.
  2. Choose whether you want to take a new photo or send a photo or video from your computer:
    • Click the gallery button  to pick a photo or video from your computer. You can select up to 10 photos or videos to send at a time.
    • Click the camera button  to use your computer’s camera to take a photo.
  3. Click the send button  to send your selected photos or videos.
  4. Alternatively, you can drag and drop a photo or video directly into the text input box.
Note: There is a 16MB size limit for each video you want to send.

To send a Voice Message

  1. Click the microphone button  next to the text input box to begin recording.
  2. Speak into your computer’s microphone.
  3. When you are finished recording, click the check mark button  to send the Voice Message.
While recording a Voice Message, click the cancel button  at any time to cancel the recording.

To save a photo or video to your computer

  1. Click the photo or video you want to save.
  2. Click the download button  in the top right corner.

#KeepSharing #Thankyou.

22 January, 2015

WhatsApp on Web

WhatsApp, the world's most popular instant messaging app, is finally available on a computer. Sort of. It is still not as simple as opening a web page and logging into an account to send messages. But it is simple enough and should satisfy millions of consumers who were rooting for web access to WhatsApp.

"Today, for the first time, millions of you will have the ability to use WhatsApp on your web browser. Our web client is simply an extension of your phone: the web browser mirrors conversations and messages from your mobile device -- this means all of your messages still live on your phone," WhatsApp noted on its website.
The feature currently won't be available for iPhone users because. "Unfortunately for now, we will not be able to provide web client to our iOS users due to Apple platform limitations," the company said.

How does it work?

Web WhatsApp

As I said, using WhatsApp on the computer is somewhat different compared to how we use other web-based instant messaging services like Google Talk.

To use WhatsApp in a web browser, take following steps:
  • Update the WhatsApp app on your phone.
  • Open web.whatsapp.com in Chrome. Other browsers are not supported for now.
  • You will see a QR code. Open WhatsApp and go into menu by pressing on three dots on the top right corner of the app.
  • From the options select WhatsApp Web
  • Point your phone's camera towards the QR code inside the browser.
  • This will pair the phone and WhatsApp data with the browser. To make sure you don't have to repeat the procedure you can check the box so that your login details are remembered.

Thank you. #KeepSharing

You can see here How to Send Photos, Videos and Voice Messages on Web WhatsApp.