Skip to main content

Posts

Using Retrofit 2.x as REST client

This tutorial explains the usage of the Retrofit library as REST client. What is Retrofit? Retrofit is a REST Client for Android and Java by Square. It makes it relatively easy to retrieve and upload JSON (or other structured data) via a REST based webservice. Using Retrofit To work with Retrofit you need basically three classes. Model class which is used to map the JSON data to Interfaces which defines the possible HTTP operations Retrofit.Builder class - Instance which uses the interface and the Builder API which allows defining the URL end point for the HTTP operation. Every method of an interface represents one possible API call. It must have a HTTP annotation (GET, POST, etc.) to specify the request type and the relative URL. The return value wraps the response in a Call object with the type of the expected result. Add these two lines to the build.gradle file: compile 'com.squareup.retrofit2:retrofit:2.3.0' compile 'com.squareup.retrofit2:con

ORMLite with Android

This tutorial will guide you how to implement ORMLite (a very light weight, open source, Android compatible ORM) in an Android project. Android supports SQLite database and writing database queries can create a lot of boilerplate code and can be really difficult to debug. I was looking for some sort of ORM library for android. I came around few of them. I decided to give ORMLite a shot. The library is very stable and uses annotations. It was really easy to implement everything so I decided to stick with it. What are the benefits you may achieve compare to conventional way of using SQLite from Android. You will learn to build an app with ORMLite that allows you to store and view data from a database. So lets begin… Model To use ORMLite, you first need to create your model classes. A sample model class would like this. Open below link to view source EmployeeDetails.java Database Helper It is the most important file from the ORMLite implementation point of view, which cons

JSON API CALLING

How to call JSON Api Post Response PostLibResponse.java Post Listner LibPostListner.java Calling API private PostLibResponse postRequest; static final int REQUEST_CODE = 1  Map<String, String> parmas = new HashMap<>();                 parmas.put("user_id", userId);                 postRequest = new PostLibResponse(EntertainmentActivity.this, new EntertainmentDataModel(), EntertainmentActivity.this, parmas, URL, REQUEST_CODE); @Override     public void onPostResponseComplete(Object clsGson, int requestCode) {         dismissProgress();         if (requestCode == REQUEST_CODE) {             if (clsGson != null) {                mDataModel = (DataModel) clsGson;                 if () {                     success                 } else {                     error                 }             } else {                 alertError("Something is wrong");             }         }     }     @Override     public void onPostRe

Firebase – Login and Registration Authentication

Android Getting Started with Firebase – Login and Registration Authentication With the latest news from Google I/O comes the new and upgraded Firebase . To demonstrate how simplified and easy to use firebase is, we will build a simple login/register (Firebase Authentication) demo using the Firebase Email & Password authentication. Firebase provides a full set of authentication options out-of-the-box. Firebase automatically stores your users’ credentials securely (using bcrypt ) and redundantly (with replication and daily off-site backups). This separates sensitive user credentials from your application data, and lets you focus on the user interface and experience for your app. Features of Firebase Firebase comes with bunch features essential for every android app starting from authentication to hosting the app. Firebase Advantages * Super easy and quick to implement  *  No server side configuration needed. No PHP Scripts and No Data

Right to Left or Left to Right Animation Android

Create an "anim" folder inside res folder in your application. Create animation resources into anim folder 1. in_from_left.xml <set xmlns:android="http://schemas.android.com/apk/res/android"  android:shareInterpolator="false">  <translate         android:fromXDelta="-100%" android:toXDelta="0%"         android:fromYDelta="0%" android:toYDelta="0%"         android:duration="1400" /> </set> 2. in_from_right.xml <set xmlns:android="http://schemas.android.com/apk/res/android"  android:shareInterpolator="false">  <translate         android:fromXDelta="100%" android:toXDelta="0%"         android:fromYDelta="0%" android:toYDelta="0%"         android:duration="1400" /> </set> 3. out_to_left.xml <set xmlns:android="http://schemas.android.com/apk/res/android"  android:s

How to finish all activities in your Android application through simple call

Hi, Maybe you had some problem which I can describe and show the way to fix it. Actually, problem is a closing all your Android application’s Activities through simple call. There are many ways to fix this. I want to show you one of them. Before starting I want to ask you something. Please email me or post a comment for this post if you find better and more flexible way to close all Android application's activities. I will be appreciative you! Below you can download the sample project. This project contains 3 (three) activities and ONE abstract Activity. All Activities in this sample project extended this abstract Activity class. This Activity extended Activity class from Android API. The most interesting contains in this abstract Activity. Here the source: package com.ravi; import android.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; public class AppBas