Communication Between Activity and Fragment Example

android-logoAfter received many requests from online users of my Android blog, I have posted the complete tutorial about the communication between activity and fragment Example. Here you can learn how a simple fragment can communicates with an Activity in Android. We will use simple  getFragmentManager() API  and Fragment Class in Android to complete this task .

Insert New Contact in Android Code Example

android-logoInsert new contact in Android is very easy. Here we will learn how to add a new mobile number  into Android Contacts list programmatically. We will use inbuilt Android classes (ContactsContract, ContentProviderOperation) to add new contacts in Android Contacts List. Below is the code snippet with example and detailed description.

Read Multiple Phone Numbers From Android Contacts List Programmatically

android-logo It is very easy to retrieve phone numbers in Android. This is how you can read multiple phone numbers from Android Contacts List programmatically. If a contact has multiple phone numbers, then You can retrieve all phone numbers and other details using Android’s inbuilt classes (Cursor and ContactsContract ) in Android. 

Singleton Design Pattern – A Creational Design Pattern

singleton-design-pattern

singleton design pattern

As the name suggest, Singleton means ‘Single Instance’.  As it is a creational design pattern so this design pattern provides the solution to create only one object (instance) of a class throughout the application’s life time.That means you can restrict the creation of an object of a given class by providing a static member function to create only one object for that class.

Creational Design Patterns

singleton-design-pattern

singleton design pattern

This design pattern provides the way to create an object of a class as per your project requirement. It means you can control the creation and life cycle of an object in your application.  As we have already discussed about different creational design patterns in my previous post, lets have a recall about  the creational patterns as below and then we will discuss different types of creational patterns in this post later.

Get Running Applications List in Android Example

get-installed-application-list-androidHere we will discuss about how to get running applications list in Android with an simple example. There are many applications and services which are running in your Android device. We can use  ActivityManager.getRunningTasks(Integer.MAX_VALUE) API to get list of all running tasks in Android.