Tag Archives: activity

What is Context in Android and What is the proper way to use it?

By | December 7, 2018

Lets see what a Context is… Context : Current State of the application. Context : Handle of the application. Context : Provides access to the resources, preferences, accessing database etc. Activity inherits from the Context. Context is the most important part of the Android application and its everywhere. If you wrongly use Context, it can… Read More »

Fast and Efficient way to transfer images between Activites in Android

By | July 14, 2017

We often need to transfer images between activities. Well there are many methods to transfer images. You can make the image into a Base64 String and pass it as String argument extra in a bundle between activities You can save it to a disc and read it in the other activity. Well, these methods will… Read More »

Dynamically Adding, Removing, Toggling and Removing all ActionBar Tabs in Android – Part 2?

By | October 8, 2012

Hi all.. In today’s post I will show you how to add actionbar tabs dynamically, remove one by one , hide and unhide them, removing all tabs at once etc. This simple java code does that. First create a project and in the MainActivity, paste this. You may be getting many errors, we will be… Read More »

How to start with ActionBar in Android?

By | August 23, 2012

With Android 3.0 Google eliminated the need of hardware menu button which is replaced by Action Bars. Here is a quick example on how to use ActionBars. First create a new project and name it ActionBarExample. Now create a folder named “menu” in res folder and create a new XML file inside it named “action_bar_menu.xml”.… Read More »

Creating a custom Sliding GalleryView with Paging in android

By | June 28, 2012

This is a simple example showing A sliding Gallery in android. This example shows a sliding gallery with a paging Control and a changing page text which also indicate the page change. Create a new project named “SlidingGallery” and copy this code into “SlidingGalleryDemo.java“. My Activity name is “SlidingGalleryDemo.java” here. Now create a new class… Read More »

JSON IN ANDROID.

By | April 26, 2012

Complex JSON String parsing in ANDROID http://www.coderzheaven.com/2011/06/10/complex-json-string-parsing-in-android/ Parsing JSON Object in ANDROID. http://www.coderzheaven.com/2011/06/09/parsing-json-objects-in-android/

Using Tabbars in ANDROID, A Simple Example……….

By | April 22, 2012

This is a simple example showing how to use tabbars in ANDROID. First create a new project and copy this code to it. Now create three another java files by right clicking the src folder and name it FirstTab.java, SecondTab.java, ThirdTab.java. Now copy the following code to FirstTab.java. SecondTab.java Now ThirdTab.java. Main.xml file AndroidManifest.xml You… Read More »

Passing data between Intents or classes in ANDROID?

By | March 29, 2012

Many of our application reqiures sending data from one intent to another. This is done by putting data into one intent using putExtras() and getting it in the other intent using the getExtras() which matches the string value. However you can pass string, boolean, integer etc between intents. For passing data between intents you need… Read More »

How to use global variables in android? -Part 2

By | February 20, 2012

Hello all…. In a previous post I showed a method to share global variables across your android application. Those were done using a static class. Now today I will show you another way of sharing global variables across the application Check these posts for sharing data across the application. 1. http://coderzheaven.com/2011/05/global-variables-in-android/ 2. http://coderzheaven.com/2011/05/global-variables-in-android%e2%80%a6/ 3. http://coderzheaven.com/2011/03/passing-data-between-intents-in-android/… Read More »

How to place layouts one over another in android using addContentView()?

By | February 10, 2012

Hello all… In today’s tutorial I will show you how to add different layouts one over another in android through java code. For this we use the function addContentView() which is a variation on setContentView(View, android.view.ViewGroup.LayoutParams) to add an additional content view to the screen. Here I will create an xml with a textView and… Read More »

Changing the style or theme of default alertDialog in Android.

By | February 3, 2012

Hello everyone, Here is a simple example showing how to change the theme of default AlertDialog in android. Check this post before for understanding how to use styles. http://www.coderzheaven.com/2012/04/17/inherit-styles-extend-styles-android/ To start first create a fresh project named AlertTest. In the AlertTestDemo.java file copy this code Now create a file named “styles.xml” inside the res/values folder… Read More »

Saving TextFile to SDCARD in android?

By | January 29, 2012

Hello android lovers, In today’s tutorial I will show you how to 1. Create a text file and save a textfile in your SDCARD in your preferred path. 2. Read the contents from the same file and show it in a TextView. For writing a file we use the FileWriter class and for reading the… Read More »

How to change the default transition between activities?

By | October 26, 2011

In android the default transition between activities is to slide from left to right. But with custom animations we can change that. First create a folder inside the res/drawable folder called “anim”. Then create a file named “fade.xml” and copy this code into it. create another file named “hold.xml” in the same place hold.xml. activity_animation.xml… Read More »

How to use shapes in android? A simple example.

By | October 23, 2011

In android with shapes we can create beautiful layouts. Lets look at an example. Create an xml named “gradient.xml” in your drawable folder and copy this code into it. Now the main layout file main.xml The main java file. Done. You can now run the application.

How to remove a view in your xml layout file using program?

By | September 28, 2011

Hello everyone, this is a simple example showing how to remove a view in android that is created using your xml file. This is the xml file that contains a TextView Here is the java code for removing this view After running this program you will not see the TextView that was in your layout… Read More »

Complex JSON String parsing in ANDROID

By | June 10, 2011

Hello all….. In the previous post I have shown you how to parse a Simple JSON String in ANDROID. In today’s tutorial I will show you how to parse a complex JSON String. Take a look at the example Here the JSON String used is Now let’s dothe operation……….. Please check the Logcat for the… Read More »

Parsing JSON Object in ANDROID.

By | June 9, 2011

JSON are alternative to XML and easy to understand than XML. As other languages Java also supports JSON parsing. Here is a simple example of JSON parsing in ANDROID. This is the JSON String that I am going to parse. And this JSON is same as this xml. Here is the code for this parsing.… Read More »

Global variables in ANDROID……

By | May 17, 2011

Hi all……. In today’s exampl e I will show you how to deal with global variables in ANDROID. You know global variables are those variables that you can access across any variables. It’s value becomes changed when you change it in any of the classes in your project. These types of variables act as like… Read More »

How to use Global variables in ANDROID?

By | May 17, 2011

Hi all……. In today’s exampl e I will show you how to deal with global variables in ANDROID. You know global variables are those variables that you can access across any variables. It’s value becomes changed when you change it in any of the classes in your project. These types of variables act as like… Read More »

How to send email from and ANDROID Application programatically?

By | May 16, 2011

Hello all…….. In today’s post I will show you send mail from an android application progrmatically.. Let’s go to the code fast…… This is the code in the mail java file…. Now the layout file (main.xml) The AndroidManifest.xml Note: However if you test this in your emulator, it will not work. Install it in your… Read More »

TextView with link in ANDROID…….

By | May 10, 2011

Hi all……. All of you may be familiar with TextViews in ANDROID. But how many of you know that we have have html as text in a textView. This post is a simple example to show this. Create a fresh project and copy this code to the main java file. The main.xml The AndroidManifest.xml file

ANDROID Tabbars Example……..

By | May 9, 2011

This is a simple example showing how to use tabbars in ANDROID. First create a new project and copy this code to it. Now create three another java files by right clicking the src folder and name it FirstTab.java, SecondTab.java, ThirdTab.java. Now copy the following code to FirstTab.java. SecondTab.java Now ThirdTab.java. Main.xml file AndroidManifest.xml You… Read More »

Using Tabbars in ANDROID, A Simple illustration……….

By | May 9, 2011

This is a simple example showing how to use tabbars in ANDROID. First create a new project and copy this code to it. Now create three another java files by right clicking the src folder and name it FirstTab.java, SecondTab.java, ThirdTab.java. Now copy the following code to FirstTab.java. SecondTab.java Now ThirdTab.java. Main.xml file AndroidManifest.xml You… Read More »

Using Tabbars in ANDROID, A Simple Example……….

By | May 9, 2011

This is a simple example showing how to use tabbars in ANDROID. First create a new project and copy this code to it. Now create three another java files by right clicking the src folder and name it FirstTab.java, SecondTab.java, ThirdTab.java. Now copy the following code to FirstTab.java. SecondTab.java Now ThirdTab.java. Main.xml file AndroidManifest.xml You… Read More »