Featured
-
Android O Released with Top 7 New Features for App Developers
Android was founded by Andy Rubin, Rich Miner, Nic
by sudhanshu.tripathi -
An Overview of Android Activity - Video Tutorial
As far as Android platform is concerned, the funda
by amit.rai -
How to get IMEI number,serial number and software version of your phone
Hello... Sometimes we need to know the country
by shahbaz.ahmmod -
Search location by using place on google map
Here below is the code for searching places by usi
by shahbaz.ahmmod -
How to know free space in sdcard android
I have written code to know free space in sdcard
by shahbaz.ahmmod
Tags
Managing Fragment In BackStack
While working with fragments we counter the management of fragments in Backstack most of the time we create multiple instance of fragments in Backstack unknowingly.
Here are some points that need to be taken care while creating fragments.
...
Simple way to convert Json data to Java Model/Bean/Pojo
There is easy way to create Pojo/Bean class for any Json scheme.
http://www.jsonschema2pojo.org/
Convert json data to Gson Pojo class:
Copy and paste Json text to http://www.jsonschema2pojo.org/
Enter package name and class name f...
Phone number validation using libPhoneNumber Library
libPhoneNumber
libphoneNumber Library is used to validate the phone number and it is a google's library mostly used by google products and Whatsapp
phone number validation is important for app so that you can get valid number from your use...
Material Design ActionBar
These days android came up with new material design so lets get updated with one of the many features ie. Action Bar which is also special type of tool bar.
Before we start make sure you have these requirements fulfilled.
Android Studio.
...
Using Parcelable in Android
In simple words , Send the complete object to other views like (switching b/w different Activity).
What if you need to send 50 value to other Activity, Don't write 50 putExtra to your code as it will increase the size of code ,just use Parcel...
Restart your schedule with AlarmManager after phone reboot
When you create a schedule using AlarmManager and you found that it stops working after phone reboot. So to avoid this problem we need to add Broadcast receiver that should receive "BOOT_COMPLETED" broadcast.
For this you need to register your...
Deep Linking for App content Android
Deep Linking enable user to enter into app from Search.
For enable Deep Linking we must add intent filters for the relevant activities in application manifest. These intent filters allow deep linking to the content in any activity of applicat...
Butterknife (Easy way to Eliminate findViewById)
Remove findViewById calls by using @Bind on widgets and fields.
Remove the click listeners by annotating methods with @OnClick and others.
class MainActivity extends Activity {
@Bind(R.id.user) EditText username;
@Bin...
Data binding in your xml layouts
Data Binding Guide
This document explains how to use the Data Binding Library to write declarative layouts and minimize the glue code necessary to bind your application logic and layouts.
Setting Up Work Environment:
dependencies {
...
Code Analysis using FindBugs Plugin in Android Studio
Android has Lint for checking errors in Java and XML code. Lint release with every new SDK.
But Lint is not find most type of bugs,exceptions and performance issue.
I found one plugin for static analysis tools to analysis android Java cod...
How to open the Navigation drawer by tapping menu icon of Action Bar.
Navigation drawer partially covers the screen when user swipes from left to right or eigter clicking on the menu icon at the top-left of the action bar. Navigation drawer is basically the hidden place where you can put navigation options.
acti...
Pull to Refresh using SwipeRefreshLayout like Gmail
This blog provide you simple Pull to refresh functionality with SwipeRefreshLayout.
First of all create new project.
Open xml layout file and create ListView/ScrollView/Gridview.
Wrap ListView/ScrollView/Gridview with "android.support.v...
Floating Label in Edittext with TextInputLayout Android Material Design
From 5.0 Lollipop version Android add some designing functionality with Material design. The one is Floating Label on Edit Text.
Before Material design EditText will hide the hint text after the first character is typed. But with the help of ...
How to implement Toolbar
Using Toolbar in place of ActionBar:-
Nowadays ActionBar is getting replaced by toolbar, so it is good to use or get handy with new feature of Android i.e "ToolBar" , Here is the way to use toolbar in your Android Activity.
Step 1:- set the...
Vibrate Service in android
To make user experience better by providing good focus on some events when volume is not relevant.
Android provide vibrator class to handling all this.
Below is the implementation. It vibrates just for 500 milliseconds.
First of all we ne...
Snackbar in android
Basically snackbar use to show message like a Toast but here the advantage is we have event to interact
in it.
It shows message on the bottom of the screen. And it will remove when we swipe off.
First of all add this in your gradle file
d...
Built in Place Picker in Android.
Android has now a built in Place picker, where user can pick the places. Developer can only send an intent and get result in OnActivityResult.
Requirements -Google play service greater than 7.
public void onPickButtonClick(View v) {
//...
Add custom ringtone on Notification
In our application, we can add notification ringtone as we want. Here is the solution.
First of all we need to create a folder named raw in /res/ file. After creating the folder put your ringtone in raw folder.
Then put this code when you...
How to know the call state in Android
Android provide us the facility to know the call state. Android gives this feature by providing Telephonymanager class. We need to implement PhoneStateListener interface that has one method onCallStateChanged().
Below is the example.
publ...
Sliding animation when switch to other activity
We can add animation on activity switching.
First thing that we need to do is to create xml for animation. Here I am using two xml for in and out.
animation_in.xml
set xmlns:android="http://schemas.android.com/apk/res/android" android:sh...
How to capture a video for particular time interval in Android
If you are looking to capture a video for particular time interval using default camera, then follow the below code to achieve the same.
Record video from camera for 60 seconds
private void captureVideoFromCamera(){
Intent intent = ne...
Custom EditText - Clear all text in Editext
It is very common that the Android's Edit text needs to clear all filled data in one hit, rather than clearing every single text using keyboard's 'X' button.
It is a good practice that enable user to clear all the text using Edit Text drawable...
How to copy text to ClipBoard
If you are looking to copy the text from android widgets to clipboard, you can use the below code
TextView contentTextBox=(TextView) findViewById(R.id.tv_content); //get textview from which you want to copy the content
String textToCopy = c...
New Location Dialog from Android Settings API
Enable a system location dialog ,asking user that app needs to find the current location
This dialog is from Android Settings API
public class LocationData implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedL...
DVM in Android
DVM i.e., Dalvik Virtual Machine is basically a virtual machine for android and specially made for mobile
devices.
DVM was written by Dan Bornstein.
Now a days JVM has improved so much that it provides amazing memory management and better
p...
ATTACH SQLite Database
Hi,
Sometimes, we have many database and we need to use any one of them.
In this situation we use SQLite ATTACH DATASE statement to choose a specific database.
Syntax of the command:
ATTACH Database YOUR_DATASE_NAME As Alias-Name;
...
Animation to DialogFragment in android
Hi,
Here I am adding sliding animation to DialogFragment
First I am adding animation xml in res/anim folder.
Then creating custom style that add to the particular fragmentdialogs's onStart() method.
slidestart.xml
<set xmlns:a...
Automatically move to next edittext in android
Hi,
In android, we have TextWatcher interface to keep track of input that we are typing.
Usually it is very useful when we need verification on the basic of text length and content also.
It has method onTextChanged(CharSequence s, int star...
How to make HTTP Basic Authorization Header
For making API's call more secure we need to implement HTTP Basic Authorization Header.
In order to set the authorization, first we need to encode the secret key or API key like this:-
public static String getB64Auth(String key) {
St...
Spelling Checker in Android
Android provides a special feature for checking spelling and it is easy to implement in your App.
Android provides SpellCheckerSessionListener listener that handles spelling checker.
For spelling checker, we have to implement SpellChe...
Custom Fonts in Android
Android gives us the facility to customize our strings font.
For this we need to keep .ttf files of the specific font in assets/fonts folder.
We can easily download ttf from internet that we want to apply.
Then we use Typeface class t...
Android Version Names
Each version of Android is having a specific code name since Android version 1.5. These name are English alphabetically and a confectionery theme based (usually , sugary foods). And these names belongs to one or more version names.
Below is the...
Communication between Fragments
Here I will explain how we can communicate between two fragments in an Activity. There are many situations where we have to communicate two fragments like we have to pass data between fragments in some events. Here I will communicate through Inte...
Add Dynamic Layout in Android
Generally we add layout from xml but sometimes we need to add layout using java. Here I am adding linear layout from java file. I am creating LinearLayout class which is provided by Android and add params on it. We have methods to set orientation...
How o handle navigation drawer with fragments
Step 1: create an xml file for main activity
<android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layou_height="match_...
Android Problem
Hello everyone I would like to start making a E-commerce android application. So how to start plz suggest me.
How to select video from gallery in Android
How to select video from gallery through intent?
Step 1: Declare the variables on the activity from where you want to hit the intent
int SELECT_VIDEO_REQUEST=100;
String selectedVideoPath;
Step 2: Selecting Video from gallery by int...
How to download file from server in android
How to download the file from server to android phone
It is recommended that whenever one wants to download any file from server whether it is song or any image , it must perform in the background either by using asynctask or using a thread.
...
Open FlashLight of Android Phone Programmatically
How to open flashLight of android phone programmatically
declare these variables in the activity
private boolean isLighOn = false; // to check tht flash is on or off
boolean flashAvailable=false;
int cameraID=0 /*cameraId with 0 repr...
Enable/Disable Bluetooth
How to on-off the bluetooth progamatically in android:-
Here, we will use the class "BluetoothAdapter" , which allow us to all bluetooth interaction and perform its tasks.
Firstly , we have to set permission in manifest to access device blu...
App invitation to facebook friend in android
How to invite facebook friends to install aperticular application
There are two functions given that will help to implement app invitation functionality.
CallbackManager callbackManager;
ShareDialog shareDialog;
First Function...
Local Database in Android
In certain cases, it is recommended to store specific data in the database. For this, one has to follow the given steps:-
In this example, I am storing song details with user id so that if users login with different names then he can get only hi...
Extract frame from video in Android
There are many cases where one need to extract frames from video irrespective of its length. With the given function one can retrieve the desired number of frames per second.
ArrayList<Bitmap> frameList;
String absolutePat...
Different Language Support in Android
Android gives us the facility to support different languages in your application. The solution is very easy, you just have to define separate values folder for each language and define every String there. You need to add a hyphen and ISO language...
TextClock in Android
Hi Friends, TextClock is used to show the current time or/and date. In TextClock we use formatted String to show the time or/and date. Basically it is a digital clock added from Api level 17 replacement of DigitalClock. By using this method we ge...
Change brightness of the device in Android
Hi,
Here I have written this code to change the brightness of the device in our application. I use the seekbar to change the brightness of the device. To handle the System Settings I use ContentResolver class and to handle current window referen...
Analog clock in Android
Hi Friends, Analog clock is a two handed clock, one shows hour and other shows minutes. It looks like a normal clock. Android provides AnalogClock to show the time.
Here is the code :-
Button buttonClock = (Button) findViewById(R.id. chang...
Setting listview and pager together in a scrollview
Putting listview and viewpager or anyother view together in Scrollview is not good habit but sometimes it's necessary to do So in that case we can use that following method to set listview height at runtime so that we can scroll listview as well ...
Implementing AlertDialog in your Android Application
This video tutorial describes how to implement AlertDialog in your activity.
A dialog that can show a title, up to 3 buttons and a list. It is a subclass of Dialog that can display one, two or three buttons.
This video tutorial describes the th...
Delete long running resources at onDestroy() in Android
Our Activity do most of the cleanup function in onPause() and onStop() callbacks.
But Sometimes some resources leaks memory like long-running services, background threads.This usually happens when we dont closed it properly.
So we need ...