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
Check application screen visibility
Hey do you want to run some code on basis of screen visibility in your app..you can create an Application level class and can set every screen visibility in onResume or in onPaused like this :
public class ThisApplication extends Application {...
How to store data in shared Preference and to fetch the stored data
If you want to store and get data in and from Shared preferences, here is the code that can help you:-
Step 1:- Create the Preference and store the values in created preferences:-
Context context=getApplicationContext();
SharedPreferenc...
Navigate into webview
Sometime it is required to navigate user in webview on back press button rather than to exit webview so for this you can use the following code :
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(event.getAction() == K...
Convert bytes to string and viceversa
As we all know all data are sent in form of bytes from one end and on another end we can read that bytes and convert back into original string. following code will help you to convert string to bytes and vice versa.
public static String encod...
Deserialize object
This is required to deserialize an object or data while recieving data over the network. you can use following code to deserialize your object and return its encoded bytes like this :
public static Object deserialize(String str) throws IOEx...
serialize object
This is required to serialize an object or data while sending over the network. you can use following code to serialize your object and return its encoded bytes like this :
public static String serialize(Serializable obj) throws IOException ...
Restrict device to capture screen shot
For safety reasons in many application we need to restrict a user from capturing screen shot of a screen or an activity.
In Android, we can easily restrict a user by applying FLAG_SECURE
//Restrict screenshot
getWindow().setFlags(WindowMana...
How to get TimeZone in Android
In order to get the TimeZone, we have TimeZone class in android.
For getting TimeZone of a device do the following steps:-
Step 1
Create an Object of Calender
Calender calender = Calendar.getInstance();
Step 2
Get TimeZone object by ...
How to make Touch Listener Image in Android.
Here I have created and example of Touch Listener Image. In this example a image can pull left, right, up and down easily. It can be used to shift your mobile app icon left and right. For this in below code I have used MotionEvent() method. Below...
How to change the enter key to search key in soft keyboard
If you want to change the enter key to search key, here is the code to get the same:-
Step 1:- In your xml file add the following EditText
<EditText
android:id="@+id/ed_search_key"
android:layout_w...
How to make Animated waiting Progressbar in android.
Here I have created Animated waiting bar. It can be used to display page or when we have app open then it will shown status of work being complete.Progressbar class provide method to work on progress bar like setProgress(),setMessage,setProgress...
Re-using layouts with include and merge tags in Android
In most of the android application we have to reuse certain set of layouts. Every time writing same set of code(xml) slows down the user interface performance. To achieve the feature of re-usabilty in our application we have tags include and merg...
How to make Graphics app in android.
Here I have created graphic app. In below example I have used android.graphics.Canvas. The android.graphics.Canvas provides method to draw oval,rectangle,text,picture etc.And The android.graphics.paint holds the information of color and style. B...
Parse String in Date Format
In order to parse the String in date, first of all you need to check in which date format the String is coming.
Then we will define date pattern accordingly.
Following steps will guide you how to parse String in Date:-
Step 1
Understand the ...
How to create a custom keyboard on android
If you are interested in making your own Soft Keyboard in android, then this tutorial will be helpful for you. Below are few steps to learn how to create your own Soft Keyboard that can serve as your own default keyboard.
Step1: To enter a tex...
How to save and fetch data in local device in android .
Here I have created save data item and fetch data Item from local server. In below code first I have created DatabaseSave class and craeted database like Caller name ,CallerDetails,CallNumber etc.
After defining database class I have created tab...
Date/Time in UTC Format
UTC stands for Coordinated Universal Time. It is the common time standard across the world.
In order to get the date-time in UTC, we need to set the timezone in UTC, like this:-
Step 1
Define your format in which you want to get date/time:-
...
How to make Image View and scrollView in android
Here I have created Set Image and Image ScrollView. In the below example when we clicked Image that image will be set on page. Below example will described you how to make Image View and ScrollView.
Step(1)activity_main.xml Layout-
<?xml v...
Make Textview underline
Sample code to make a textview underline -
tvPrivacy3.setPaintFlags(tvPrivacy3.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
And sample code to make textview strike line
tvPrivacy3.setPaintFlags(tvPrivacy3.getPaintFlags() | Paint.ST...
Multidex with Gradle
APK uses executable bytecode i.e Dalvik Executable (DEX) files to run an app. The dex file limits the total number of methods in a single dex file to 65,536, including Android sdk methods, library methods, and methods in our code. But sometimes i...
Convert Currency code to symbol Android
Hello Friends,
Here is simple code to convert currency code to symbol in android.
public String getCurrencySymbol(String currencyCode) {
try {
Currency currency = Currency.getInstance(currencyCode);
return currency...
How to access call logs in android.
Easiest way to get the call duration of last call in android device is by using CallLog.Calls. Content Provider CallLog.Calls is used to provide access to the call logs data. CallLog.Calls provides interface between data and the code, also it con...
Implementing Fragment in Android
In this example we are using two fragments Fragment1 and Fragment2 where Fragment1 consist of a button named click, this button will show the Fragment2 on clicking the Click button.
To implement Fragment in Android follow the steps mentioned b...
Volley api to post parameters
Volley api is powerful api to perform network operation like to perform long running network operations.
you have to create HashMap that will contain key value pair for each variable and then put that hashmap object in JsonObjectRequest as a p...
Add element to Array in parse.com Android
Here I am writing code to add an element to Parse Array.
It is very simple to add values to parse array.
We need to insert using add() or addUnique() instead of put() method.
So for normal column, we use put() method of ParseObject and for...
How to show progress in a ProgressDialog while downloading
Progress dialog in android to show progress indicator/updates while downloading a file or when waiting to load a file while playing a game. Progress dialog have various features like:-
setMessage() to display message Example: Loading... (or) P...
How to download a file with android.
Downloading in android devices i.e receiving data from remote system. In android devices Download manager is a system service that is used to download and manage any type and size of file. We have two nested classes first is DownloadManager.Query...
How to implement Drawable Animation in Android.
To implement Drawable Animation in Android follow the steps :-
1) Prepare a series of images with the individual frames of your animation. Add the images to your projects drawable folder.
2) Declare a XML file that defines the animation se...
Compare two Date object in Java
Sometime we need two compare two dates like which Date object's time coming first or last.
Here is the code to compare two dates.
Date date1;
Date date2;
if(date1.before(date2)){
System.out.println("Date 1 is before date ...
Putting GIF images in your Android application
Put Your GIF image in /raw folder and put the below code in your project
public class CustomGifView extends ImageView {
Movie movie;
InputStream inputStream;
private long mMovieStart;
public CustomGifView(Context contex...
How to obtain the permission to external storage?
If you are looking to get the permission to access your external storage in android, here is the solution:-
you have to add these lines in your manifest file:
<uses-permission android:name="android.permission.STORAGE" />
To store s...
How to make option menu function in android.
In this blog we are inflating the menu by using inflate()method of the menuInflater class this can be performd event handling on menu items, when we need to override then we can used onOptionItemSelected()method of activity class. Hence using bel...
How to upload large files from Android device to server
Android developers do face the exception when sending large file from Android device to a server. To send large file to a server you have to make the file into small size chunks and then send it to the server.
setChunkedStreamingMode(1024), thi...
How to make Menu Slider function in Android?
If you are looking to create Sliding menu in android below example will help you.In android Sliding menu is used to hide and show menu items. In below example I have create multi layouts here like fragment layout using for dividing menu item . fr...
How to impliment view Animation in Android
To implement view Animation in Android follow the steps mentioned below:-
1) Start a new project in android studio.
2) Now create a new Android resource Directory under res directory then choose interpolater option in directory type and nam...
Property Animation Android
1) Here I will rotate a View around its vertical axis using the rotationY property. we will create an XML resource file in the /res/animator directory named as flip_on_vertical.xml.
<objectAnimator xmlns:android="http://schemas.android.com/...
Dynamically adding ListViewItem to Listview
To dynammically add new elements into listview we need a Edittext(etAddItem) to input the item/element, a Button(btnAdd) for adding item to the list, and a listview which shows elements in a vertical scrolling manner.
etAddItem = (Edit...
How to refresh a List in Android?
1)Write activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent...
Freeze TextView text while restore fragment from Backstack/ onOrientationChange
Some time TextView lost text while getting fragment from Back-stack or when screen orientation changed.
I also faced that problem. Here is the solution for save state of TextView forcefully.
Add Tag
android:freezesText="true...
How to make Action Bar in Android?
Here I have created Action Bar in android. In android Action Bar is used to provide navigation and perform some actions.
In this blog I have implement a Action Bar in my Android project and perform actions such as switching fragment. Below ex...
How to make SeekBar in android?
Below code will help you to created SeekBar function in android. In android SeekBar is used by the end user, the user can drag the left and right to move the progress of runing file like audio song, video song etc. In the below code example, I h...
How to make Digital clock in android?
Using below code I have created Digital clock app in android. Android digital clock is used to show time in android app. In android, digitalclock is the sub class of TextView class. Here below code example will help you create Digital Clock funct...
Remove duplication from array list
If you want to remove duplicate entries from your array list you can use hash set to make all items unique rather than use of algorithms.
Set is a ordered collection of items and contains only unique items. And Hashset creates a collection th...
How to Add items Dynamically in RecyclerView?
RecyclerView is works just like listview but more well organised, felexible to customize and optimize to work and in rendering the view of large data set. So in this tutorial we will see how to add items Dynamically in RecyclerView.
...
Utc time to Local time conversion
If you are working on meeting schedule functionality in your android app and you are stuck with the timezone then this example can guide you.
If you are getting the time, timezone from server and time is in UTC then you should not have to ap...
Show loading when load page on WebView
Here I am writing code to load url on WebView.
We need to create WebView client where we get the event of page finished.
Then simply showing ProgressDialog and dismiss it on onPageFinished().
WebView myWebView ;
myWebView = (WebV...
Strike text of TextView in Android
When we need strike text in android most of the time we do strike text with the help of HTML tag.
But Here is simple way to strike TextView's text in android with native code
textView.setText("This is Strike text");
textView.setPaintFl...
Date Picker Material Design
I am writing way to add and use date Picker Material design library to our project.
First of all we need to add library to our build.gradle file
dependencies {
compile 'com.wdullaer:materialdatetimepicker:1.5.4'
}
Then we need to imple...
LibPhoneNumber library implementation - An easy way to fetch phone contacts
Are you Looking for a better library that can fetch all phone contacts easily and that can manage all numbers in common formats. Then LibPhoneNumber library is a better solution because this library is faster then other handmade queries. This lib...
How to make ProgressBar function in android?
Here I have created ProgressBar app in android in which I have used setProgress(), setMessage(), setProgressStyle(),setMax,show() function.
Below code example will help you to create RatingBar function in android.
Step(1)-activity_main.xm...