Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 

How to deal with Out of Memory Exception in Android ?

How to deal with Out of Memory exception in android: In android we encounter with out of memory exception many times. The reasons are we don't have expanding memory and completely dependent on device the memory available on phone. So we don't...

Push Notification using GCM in Android

For Push Notification using GCM in Android, use the following steps: Create the Google Api Project on Google Console. Note down the project number which will be used as GCM Sender Id. Enable the GCM service by turn on the toggle for Google...

Getting the connected Wi-Fi name in Android.

If you need to display the connected Wi-Fi name in your application than you just have put this method getConnectedWiFiName in your utility class and call it whenever you need the Wi-Fi network name. public static String getConnectedWiFiName...

Android create custom edittext with clear button.

In android there is no default text clear button functionality in EditText so here is a simple example of implementing text clear button in edit-text, You just have to follow instruction given below to make it in your edit-text. 1)- First you...

Storing and retrieving String[ ] Array using SharedPreferences in Android.

I came across to the many questions asking about to store some kind data in Shared-preferences such as String[] array. Many of these questions are answered with "Use a database". But here i will show you a perfect piece of code by which you ...

How to hide title bar and status bar in android

In many application we need to hide the title bar of Activity/Fragment Activity. For this we need to add following line in onCreate() method before calling setContentView() requestWindowFeature(Window.FEATURE_NO_TITLE); Example:- publi...

Convert a Drawable into Bitmap

Following method tells how to convert a drawable into bitmap // method to convert a drawable into Bitmap public static Bitmap drawableToBitmap (Drawable drawable) { // check if drawable is the instance of BitmapDrawable if (draw...

Set or Get phone wallpaper from your Application

To set or get the wallpaper of android phone from your application, we used WallpaperManager. This class provides access to the system wallpaper. By the help of this class you can get the current wallpaper of your phone inside your app and even c...

Implement Gesture listener on listview item

This blog gives a simple example to implement Gesture listener ( or horizontal swipe) on ListView item. public class MainActivity extends Activity implements OnGestureListener{ private ListView listView; private ArrayList LIST; ...

How to check if your device is connected to Internet

We need to check if device is connected to Internet on making every API call (or call to Remote server). The function below returns true if device is connected to Internet. //**This function tells whether the device having an Internet connec...

How to get Rounded Corner bitmap ?

In many android applications, we need to set rounded corner image in ImageView. The bad part is that ImageView does not provide any property for this. So for this the following method will help you get rounded corner Bitmap:- public static Bit...

Saving an image into SDcard in Android

Sometime we need to save images on SDcard that we click or get from server in many applications, and you can do it very easily by using the below code. To save Images on SDcard on Android Device, write the following code: ByteArrayOutputStr...

Sample Barcode Scanner Application

Here is a sample code of simple **Barcode Scanner** app. Barcode scanner library is attached with this project you just have send an startActivityForResult to open Scanner like this. Intent intent = new Intent(getApplicationContext(),Captu...

how to detect swipe left or right function on listview item in android

If you want to detect swipe gesture from left to right or right to left on the list view item in android. than you just have to add this Class in your activity and perform any task by detecting any type of gesture in your list item in android...

Remove all the previous activities from the back stack in android

Whenever you switch from one activity to another using intent and specially in the case of logout and sessions related android applications you will find activity back stack issue. Here i will show you a small piece of code which will help you...

How to improve selection criteria of your app using Radio button?

Radio Button A radio button is a two-states button that can be either checked or unchecked. They are normally used together in a RadioGroup. When several radio buttons live inside a radio group, checking one radio button unchecks all the others....

Creating shapes,Boder,selector and Drawable using xml in Android

This blog will help you to Create shapes,Border,selector and Drawable using xml in Android. 1.Selector for a button: Create xml file named background_selector.xml in res/drawable and write the bellow code in that <?xml version="1.0" enco...

Getting roundedCorner for an Image in Android

Sometimes we need to display images with rounded corners in our several Applications, and this can be done very easily by writing some lines of code. To get roundedCorner for an Image use the following code: /** * This method is used to ...

Post in FaceBook using your Android device via feed dialog

In many applications we have to share content, links etc on Facebook. We can achieve this by using Facebook feed dialog. The following lines of code explains how to use feed/publish dialog. First you need to get the app id and create a meta da...

Save ArrayList of Object into Shared Preferences in Android

Sometime we need to save ArrayList of Objects into Shared preferences so that we can use that data in multiple Activities when required. We can do that easily as below: Suppose we have model Users as below: public class Users { privat...

Easy methods of incorporating Google maps for Android

First create a layout for Map Activity. The name of layout is activity_main.xml <fragment xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/map" class="com.google...

How to display multiple images one after another in some time interval

Sometimes we need to display ads in our application.To display the multiple images one after another in some time interval write the following code: Create a customTimerTask class that extends the TimerTask class public class customTime...

getting contact information from contact list in Android

We can get a contact information for any contact from contact list of an Android Device easily. For this follow the steps below: Write the permission to read Contact's data into your AndroidManifest.xml <uses-permission android:name="a...

Load Image From Url

How To Load a Image Form a url You can use this class in your application to load image . It can be use by calling its DisplayImage(String url, int loader, ImageView imageView) function.This function there are three parameters first is Str...

Use existing sqlite database in android

I will show you the easiest solution, by far, is to use SQLiteAssetHelper. You add your existing sqlite database in a specified location in your project's assets/ directory, then use SQLiteAssetHelper to access your database (much same as you wo...

Adjust Image view width dynamically according to the screen size in android.

It is very difficult to re-size the image-view width according to the screen without losing the quality of the image or you can say increase the width in proportionate to height of the image view. I will show you the trick how you can do tha...

Finding Current Location in Android

To find the current location, follow the steps below: Create a dialog box to display loading message while finding the location ProgressDialog dialog=new ProgressDialog(this); dialog.setMessage("Please wait while getting your location in...

Make String with different colors in Android

We will use SpannableString to add different colors to a string and will use the setSpan(Object what, int start, int end, int flags) method of SpannableString to change the color for defined range of characters in that string. Here is the cod...

Using ViewPager for Screen Slides in Android

ViewPagers have built-in swipe gestures to transition through pages You don't need to add any animation. sample code : Set your main Activity layout as: in mainactivity Layout xml file set relative layout,in it set the view p...

Player Settings for Android in Unity3D

When we build our project to see how it looks, we need to set the Player Settings- Today I'll describe you the Player Settings for Android After building the project in Android Go To Edit->Project Settings-> Player Following Playe...

How to change the Image orientation in Android

To change the orientation of an image write the following code: BitmapFactory.Options o2 = new BitmapFactory.Options(); o2.inSampleSize = 2; // Get the original bitmap from the filepath to which you want to change orientation // fileName i...

Play YouTube videos and other Webview videos in Android.

In android playing videos from web-view is such a mess but now just using a small trick you can play all web videos of the YouTube, Daily-motions, etc. You just have to add this method in your web-view Activity. Here is the trick-: ...

How to make your Android Applications better by applying the Drag and drop functionality

Drag and Drop functionality provides user a facility to move a data (or object) from one view to another. This tutorial will help you with the development of the Drag and Drop functionality in your android application. For this you require API l...

Get Facebook messages in Android

Note- Facebook provides 25 latest message conversation. To get Facebook chat messages in Android, following steps are used: Define the 'read_mailbox' property as below: private static final List PERMISSIONS = Arrays.asList("read_mailbo...

Playing with date format in Android

We can change date format of a date as below: Here, I have defined different date formats: String FACEBOOK_DATE_FROMAT = "yyyy-MM-dd'T'HH:mm:ssZZZZZ"; String MESSAGE_DATE_FORMAT = "MM/dd/yyyy hh:mm a"; String MESSAGE_DATE_TIME_FORMAT = "M...

How to Develop an Android Game in Unity3D

When we create our game, we might want to see how it looks when we build and run it outside of the editor as a standalone or web player. Today, I will explain how to access the Build Settings and how to create different builds of your games. G...

Getting MMS from an Android Device programmatically

To get MMS conversation from an Android device, use the following code: ContentResolver contentResolver = getActivity().getContentResolver(); Uri uri = Uri.parse("content://mms"); Cursor cursor = contentResolver.query(uri, null, "thread_id ...

How to get SMS from an Android Device programatically

To get SMS conversation from an Android device we will use following code: ContentResolver contentResolver = getActivity().getContentResolver(); Uri uri = Uri.parse("content://sms/conversations/"); Cursor cursor = con...

Associate your actionbar popup menu with the hardware menu button in Android.

Google Kills Android Menu Button, Replaces It with Action Bar But still so many devices have hardware menu button so now we can combine hardware menu button along with action bar option popup menu by just doinig a small trick. When you clicks...

Steps to download a file in android using Asynctask

Five Steps for downloading a file using AsyncTask in android Declare the reference of ProgressDialog class in your Activity globally. Ex:- ProgressDialog mProgressDialog; Instantiate the above reference in onCreate() method of activity...

Dynamicaly load more items to the ListView

To dynamically load more items to the ListView when you scroll at the bottom, we implement onScroll() method in which we can find out the which item is visible when we will reach at bottom it will load more items. Following steps are used fo...
1 15 17 next
Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: