Tutorial #30: Create Animation in Android

Hello everyone!

It’s difficult to find time these days. However, I always try and make sure that the learning never stops! In one of my earlier posts I had talked about displaying, storing and resizing of Images in Android. In this tutorial, I will talk about creating an animation using the Animation resources offered by Android.

Android includes an Animation class using which an animation can be applied to Views, Surfaces or other objects. There are basically two main types of Animations:

1. Property Animation ( android.animation)

The property animation system allows developers to animate object properties of any type, for example, int, float. One can also specify keyframes, group animations and even control the behavior of animations.

2. View Animation ( android.view.animation )

Unlike property animation, View animation is used to create simple animations such as tweened animation and frame by frame animation. Tweened animation creates an animation by performing a series of transformations on a single image where as frame by frame animation creates an animation by showing a sequence of images.

Once the above concepts are clear, we can now proceed towards creating a simple fade in/fade out animation in Android.

Pre-requisites: Eclipse IDE (preferably latest version), Android SDK

Open the Eclipse IDE. Create a new Android Project named AndroidAnimationDemo with Target SDK Android 2.3.3. Let the package name be com.example and choose to create a Blank Activity.

Step 1: Create anim folder to include Animation

Expand your Project under the Package explorer window. You will find a folder named res. Inside the res folder, create a new folder named anim.

Now, create two XML files as follows:


<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"


<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"

As you can see, we can achieve the fade in and fade out animations by merely changing the alpha (toAlpha and fromAlpha) values. Depending upon your requirements you can also change the duration of the animation. An AlphaAnimation is used to represent a fade in or fade out animation. More details can be found over here.

Step 2: Write Activity code

Moving on, open your Activity class and add the following code!


package com.example;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;

public class MainActivity extends Activity
	private ImageView image;
	private Animation animFadeIn;
	private Animation animFadeOut;
	private Button btnFadeIn;
	private Button btnFadeOut;
  public void onCreate(Bundle savedInstanceState) {
      btnFadeIn = (Button)findViewById(R.id.btn_fadein);
      btnFadeOut = (Button)findViewById(R.id.btn_fadeout);
      image = (ImageView)findViewById(R.id.my_image);
      animFadeIn = AnimationUtils.loadAnimation(this, R.anim.anim_fade_in);
      btnFadeIn.setOnClickListener(new Button.OnClickListener(){

   public void onClick(View arg0) {
    // TODO Auto-generated method stub
      animFadeOut = AnimationUtils.loadAnimation(this, R.anim.anim_fade_out);
      btnFadeOut.setOnClickListener(new Button.OnClickListener(){

   public void onClick(View arg0) {
    // TODO Auto-generated method stub


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical" >
      android:text="Fade In"/>
      android:text="Fade Out"/>

     android:src="@drawable/android" />


I have added a sample JPG image in my drawable folder. No changes are required to the AndroidManifest.xml file. Run the project on the emulator and you should see the following output! Source code can be found over here.



Tutorial #29: Connect to MySQL database using ODI

Hello everyone!

One of the main reasons developers use the Oracle Data Integrator platform is basically to integrate data from heterogeneous databases. The data is usually of high volume containing information stored on multiple databases. In such cases one needs to retrieve data from different sources and assemble it in a proper manner. This is where Oracle Data Integrator plays an important role.

In this tutorial, I will demonstrate how to first create and then connect to a MySQL database using ODI

Pre-requisites: MySQL Client, Oracle Data Integrator 11g (version

Step 1: Open MySQL command line client. Enter your password to login and create a new database

create database karan;
use karan;

Step 2: Create a new table called Employee

create table Employee(EmpId int primary key, EmpName varchar(30);

Inside some dummy data inside the table.

insert into Employee values(101,'karan');
insert into Employee values(102,'kedar');
insert into Employee values(103,'mahesh');

Step 3: Create new data server, physical and logical schemas for MySQL

Open ODI Studio and connect to your work repository. Under the Technologies tab, right click MySQL–>Create new data server

Create new MySQL data server

Create new MySQL data server


Note: Click on Test Connection button to ensure that the connection is successful. If the connection is successful you are connected to your MySQL database. If not, you need to check your credentials including port number, username and password.

Now, create physical and logical schemas for the MySQL data server.

Create physical and logical schemas

Create physical and logical schemas


Step 4: Create new Model project and reverse engineer Employee table

Create a new Model project named mysql_model. Right click and select new Model.

Create new Model project

Create new Model project

Reverse engineer your Employee table. Right click table and view the data. It should reflect the data you inserted before!

Reverse engineer table

Reverse engineer table

View data

View data

You can now use this model in your Interfaces for loading data into your target datastore. That’s it for this tutorial. Thanks! 🙂

Learning Kivy: Bubble

Hello friends!

Today, we will learn about a very simple yet fascinating Kivy widget called Bubble. The Bubble widget is basically a small pop up that appears and consists of menu options that are stacked either horizontally or vertically.

Every Bubble widget contains an arrow pointing towards the direction you choose. By default the direction is ‘bottom_mid’ i.e bottom middle.

A Bubble widget can be implemented as:

bubble = Bubble(orientation = 'vertical')
#Add items to the Bubble

What is a BubbleButton?

It is basically a button intended for use as in a Bubble widget. Using BubbleButton you can use the background that has been already defined. On the other hand if you stick to Bubble then you need to customize it in order to change the background image, color etc.

Customizing your bubble

You can change the background color, image and border of the Bubble. You can also add an image for the arrow as follows:

bubble.background_color = (1, 0, 0, .5) #50% translucent red
bubble.border = [0, 0, 0, 0]
background_image = 'path/to/background/image'
arrow_image = 'path/to/arrow/image'

So now let’s begin implementing the Bubble widget!

Open Python IDLE. Create a new Python script named bubbledemo.py and write the following code!


from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.button import Button
from kivy.uix.bubble import Bubble
from kivy.uix.bubble import BubbleButton

class MyBubbleApp(App):
    def build(self):
        root= GridLayout()
        layout = FloatLayout(orientation='horizontal', size=(150,100), size_hint=(None, None))
        my_btn=Button(text='Press to view bubble',pos=(300,300),on_press=show_bubble)
        return root

def show_bubble(self,*args):
        my_bubble= Bubble(orientation = 'horizontal',pos=(280,400))
        #Customizing my bubble
        my_bubble.background_color =(20, 0, 0, .5) 
        my_bubble.border = [50, 50, 50, 10]
        my_bubble.arrow_pos= 'top_left'
        my_bub_btn1= BubbleButton(text='Copy',size_hint=(None, None),size=(80, 50),pos=(200,400)) 
        my_bub_btn2= BubbleButton(text='Cut',size_hint=(None, None),size=(80, 50),pos=(300,400))
        my_bub_btn3= BubbleButton(text='Paste',size_hint=(None, None),size=(80, 50),pos=(300,400))
        #Add items to bubble
if __name__ == '__main__':

Run the above script by typing kivy bubbledemo.py inside the command prompt and you should see the following output!



Tutorial #28: Implement SHA1 and MD5 hashing in Android

Hey everyone!

Security plays an important role especially in applications where in you need to connect to the Internet. Hashes are useful in such cases since they help to ensure that the transmitted messages are not altered by any means. In general, a hash value or a hash, also known as message digest is a number generated from a string of text. Android provides us with the MessageDigest class that enables developers to create and use hashes while comparing user credentials.

In this tutorial, I will demonstrate how to go about hashing a password using SHA1 and MD5 hashing techniques!

MessageDigest class

As mentioned in the Android docs, the class uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence. The original arbitrary-length sequence is the message, and the fixed-length byte sequence is the digest or message digest.

1. SHA1

SHA stands for secure hashing algorithm. SHA-1 produces a 160-bit message digest and is considered to be more secure than MD5. However, when compared to SHA256 it is not that secure.

2. MD5

It is widely used cryptographic hash function that produces a 128 bit (16 byte) hash value. It is represented in the form of a 32 digit hexadecimal number and cannot not decrypted. The downside of the algorithm is the fact that it has been broken as mentioned over here.

Now, let’s create an Android application project to implement SHA-1 and MD5.

Pre-requisites: Eclipse IDE (latest version preferably), Android SDK

Open Eclipse. Create a new Android project named AndroidHashDemo with Target and Build SDK as Android 2.3.3. Let package name be com.example. Choose to create a blank Activity and click on Finish.

We will create the layout for our application by modifying the activity_main.xml file.


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    tools:context=".MainActivity" >

        android:text="@string/hello_world" />

        android:text="Compute SHA-1 hash of password"/>
        android:text="Compute MD5 hash of password"/>
        android:layout_height="wrap_content" />


We also need to modify our strings.xml file!


<?xml version="1.0" encoding="utf-8"?>

    <string name="app_name">AndroidHashDemo</string>
    <string name="action_settings">Settings</string>
    <string name="hello_world">Android Hash Demo!</string>
	<string name="username">enter your username!</string>
    <string name="password">enter your password!</string>

Now, move to your MainActivity.java file and write the following code!


package com.example;

import java.io.IOException;
import android.util.Base64;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {

	private TextView result;
	private Button computeSha,computeMD5;
	private EditText userName, passWord;
	private String username,passwd;
	private String SHAHash;
	public static int NO_OPTIONS=0;
	protected void onCreate(Bundle savedInstanceState) 
		result= (TextView)findViewById(R.id.textView2);
		//get username and password entered
		username= userName.getText().toString();
		passwd= passWord.getText().toString();	
		//check if username or passwd is not null
		if( (username != null && username.equals("") ) || (passwd !=null && passwd.equals("")) )
			computeSha.setOnClickListener(new View.OnClickListener() {
				public void onClick(View v) 
					// TODO Auto-generated method stub
					//call method to compute SHA hash
			computeMD5.setOnClickListener(new View.OnClickListener() {
				public void onClick(View v) 
					// TODO Auto-generated method stub
					//call method to compute MD5 hash
			Toast.makeText(getApplicationContext(), "Enter your credentials..", Toast.LENGTH_LONG).show();
	} //end onCreate()

	 private static String convertToHex(byte[] data) throws java.io.IOException 
	        StringBuffer sb = new StringBuffer();
	        String hex=null;
	        hex=Base64.encodeToString(data, 0, data.length, NO_OPTIONS);
	        return sb.toString();
	public void computeSHAHash(String password)
		  MessageDigest mdSha1 = null;
	          mdSha1 = MessageDigest.getInstance("SHA-1");
	        } catch (NoSuchAlgorithmException e1) {
	          Log.e("myapp", "Error initializing SHA1 message digest");
	        try {
			} catch (UnsupportedEncodingException e) {
				// TODO Auto-generated catch block
	        byte[] data = mdSha1.digest();
	        try {
			} catch (IOException e) {
				// TODO Auto-generated catch block
			result.setText("SHA-1 hash generated is: " + " " + SHAHash);
	public void computeMD5Hash(String password)

		try {
	        // Create MD5 Hash
	        MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
	        byte messageDigest[] = digest.digest();
	        StringBuffer MD5Hash = new StringBuffer();
	        for (int i = 0; i < messageDigest.length; i++)
	            String h = Integer.toHexString(0xFF & messageDigest[i]);
	            while (h.length() < 2)
	                h = "0" + h;
	     	result.setText("MD5 hash generated is: " + " " + MD5Hash);
			catch (NoSuchAlgorithmException e) 


Finally, run your Android project to see the following output!






Source code for this tutorial can be found over here. Thanks! 🙂

Tutorial #27: Implement Slowly Changing Dimensions in ODI

Hello friends!

In this tutorial we will learn how to implement the concept of Slowly Changing Dimensions (SCD) using Oracle Data Integrator. As the name suggests, SCD in data warehousing refers to the slow change in data rather than the change on a regular basis. It is applicable in those cases where the attribute for a record varies over time.

There are three basic types of SCD’s:

1.Type 1 – Overwrite old values

In this case, new record replaces the original record. No copy of the original record exists.

2.Type 2 – Create a new record

In this case, a new record is added to the dimension table.

3.Type 3 – Create new fields

In this case, the latest update to the changed values can be seen. The original record is modified to reflect the change.

So now let’s begin implementing SCD using Oracle Data Integrator. Open ODI Studio and follow the below steps!

Pre-requisites: Oracle 10g Express Edition with *SQL Plus, Oracle Data Integrator 11g (version

Step 1: Create source, target tables for SCD using *SQL Plus

Source table

create table scd_test(EmpId int, EmpName varchar2(30), DeptName varchar2(30), salary number(6,2));

Insert few rows of dummy data inside the source table.

insert into scd_test values(101,'Karan','Computer',2200.23);
insert into scd_test values(102,'Mahesh','Computer',3200.53);
insert into scd_test values(103,'Prasad','Mechanical',5300.13);

Target table

create table scd_target(EmpId int, EmpName varchar2(30), DeptName varchar2(30), salary number(6,2), joining_date date, flag number);

Step 2: Create models for source and target tables

Under Designer tab, create a new Model folder and then right click it, select Models–>Create new model. Reverse engineer both the source and the target tables under the same model. Provide any existing Oracle logical schema while re-factoring.

creating data model

Step 3: Modify target table model and it’s columns for SCD

Open the target table datastore and change OLAP type to slowly changing dimension.

Then expand your target datastore to get all columns. Open required columns one by one and do the changes as follows!








Step 4: Create new interface

While creating new interface select IKM as Oracle Slowly Changing Dimension. Map the source and the target tables. For columns joining_date and flag specify the implementation as shown below!

Creating interface

Creating interface







Run the interface without any errors. View the target table data.



Running the interface for the first time

Running the interface for the first time

Now, update few records of the source table. In this case, I will update name and salary of employee. Hence as per SCD Types 1 and 3, first a new record will be inserted since we had selected Add row on change for Employee name and then salary will be overwritten as we had selected Overwrite on change for Employee salary.

update scd_test set empname='nitesh' where empid=101;
update scd_test set salary=5634.43 where empid=102;

Run the interface again and then view the target table data. It now reflects SCD.

Output data

Output data


That completes this tutorial. Keep visiting for more!

Update #1: “Tips And Tricks” category added

I have been using a computer for more than 10 years now. Still, at times I feel, how didn’t I know about this?. It’s true that technology keeps on evolving and getting better every day. As humans we need to try and keep pace with technology. We need to learn something new every day. The learning can be through the Internet, through books or through any friend who comes to your place and teaches you something that you didn’t really know about!

By introducing this new category, I plan to share some of my learnings with you. It includes some basic stuff you need to know while you are operating a computer. I hope this will benefit you in some way and make your overall computer experience a lot more enjoyable.

Let’s begin with our first computer tip for today! It talks about using Environmental Variables in Windows.

In any Windows machine, there are dynamic strings that contain information about the environment of the system. Many software programs, for example Java, Python etc use this information to place their files. There are a number of environmental variables that get referenced by programs that are useful to a user to find any information related to that computer environment.

There are basically two types of Environmental Variables:

1. User variables

A user can add, remove or modify a user environmental variable. The changes are written to the registry and get reflected immediately.

2. System variables

These variables can be modified by the administrator of the system. They are applicable to all the users. They too are written to the registry and most of the time require restarting the system to become effective.

Here are the steps to view Environmental variables on a Windows 7 machine!

Step 1: Right click My Computer–> Properties

Step 2: Select Advanced System Settings. Go to Advanced Tab and select Environmental variables.

Step 3: Click one of the following options, for either a user or a system variable.

Click New to add a new variable name and value.
Click an existing variable, and then click Edit to change its name or value.
Click an existing variable, and then click Delete to remove it.

Hope you liked this post. Happy learning! 🙂

Learning Kivy: TabbedPanel

Hello everyone!

On May 13th, 2013 Kivy launched version 1.7.0 for it’s platform. The new version includes some cool features as well. You can have a look at the changelog from over here.

Today’s Kivy tutorial talks about one of the existing complex UX widgets called TabbedPanel. The TabbedPanel widget manages different widgets in tabs. It consists of a header area for the actual tab buttons and a content area for showing the current tab content. Before you begin implementing this widget you need to understand the concept of a TabbedPanelHeader.

What is a TabbedPanelHeader?

An individual tab is called a TabbedPanelHeader. It is a special button containing the content property. In order to use it, we need to first add the TabbedPanelHeader to our TabbedPanel and then set its content as seen below!

tp = TabbedPanel()
th = TabbedPanelHeader(text='Tab2')
th.content = your_content_instance

Once you are clear with the concept of a TabbedPanelHeader, you can now go ahead and start implementing your own TabbedPanel widget. Fire up Python IDLE and begin writing the following code!


from kivy.app import App
from kivy.uix.tabbedpanel import TabbedPanel
from kivy.uix.tabbedpanel import TabbedPanelHeader
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.image import Image

class TabbedPanelApp(App):
      def build(self):
          tb_panel= TabbedPanel()

          #Create text tab          
          th_text_head = TabbedPanelHeader(text='Text tab')
          th_text_head.content= Label(text='This is my text content')

          #Create image tab
          th_img_head= TabbedPanelHeader(text='Image tab')
          th_img_head.content= Image(source='sample.jpg',pos=(400, 100), size=(400, 400))

          #Create button tab
          th_btn_head = TabbedPanelHeader(text='Button tab')
          th_btn_head.content= Button(text='This is my button',font_size=20)


          return tb_panel

if __name__ == '__main__':

Run the above code using Kivy by typing kivy tabbedpanel.py inside the command prompt. You should get the following output!



Output screenshots

Output screenshots

It is important to note that the Default tab is added when the TabbedPanel is instantiated. Tabs created individually get added to the Default tab.

So, that’s it for this tutorial. Keep visiting for some more interesting Kivy tutorials! 🙂

Tutorial #26: Using Jython in ODI

Hello everyone!

Since the past few weeks, I have been learning a bit of Jython in order to implement a certain functionality in Oracle Data Integrator. If you happen to read the developer’s guide for Oracle Data Integrator you will come to know that Jython is mainly used to capture or raise errors, handle RDBMS operations and run OS specific commands.

In you are not aware of Jython, I suggest you read about it before you begin with this tutorial from over here. To start learning about the use of Jython in ODI, I would recommend reading the book Jython’s beginner guide for ODI.

Once you are familiar with Jython, you can now start using it in ODI. Open ODI Studio and carry out the following steps!

Step 1: Create data server and physical schema for Jython technology

Under Topology navigator, select the Physical architecture tab. Right click Jython–> New data server

Create new data server

Create new data server

Now, create a new physical schema for the same

create physical schema

create physical schema

Step 2: Create new logical schema for Jython technology

Under Topology navigator, select the Logical architecture tab. Right click Jython–> New logical schema

create logical schema

Step 3: Create a new Procedure

In any of your existing Projects under Designer tab, create a new procedure as follows:

Create new procedure

You now have to write your Jython code using proper indentations under Command on target. Specify the directory where you want the output file to be created. Over here I have specified c:/count_write.txt

Jython code

import string
import java.sql as sql
import java.lang as lang
import re

sourceConnection = odiRef.getJDBCConnection("SRC")

sqlstring = sourceConnection.createStatement()
print >> output_write, " The counts are .... '\n'"

sqlstmt="select count(*) as rowcount from all_tables where owner='SYSTEM'"

while result.next():

print >> output_write ,rs


Under Command on Source, just select any logical schema present for Oracle technology and do not write any code for it.


In case you need to write more queries, you can find them on this blog post by ODI experts.

Save and run the procedure. Make sure no errors are present. For the output, check the directory that you have mentioned in your code. You should now see a new text file created containing your result!



Tutorial #25: HelloWorld application using Android Studio

Hi guys!

Google recently announced a new IDE for Android called Android Studio. It’s free and can be downloaded from over here.

Android Studio is a new Android development environment based on IntelliJ IDEA. It is similar to Eclipse with the ADT Plugin and provides tools for development and debugging.

As the Android Studio is available currently as an early access preview there are several features that are not yet implemented and you may encounter bugs when you are trying it out for yourself. Through this post, I will tell you how to install Android Studio on your Windows 7 machine and create a new HelloWorld application!

Requirements: Windows 7(64 bit), JDK 1.7(get the latest update preferably), Gradle-1.6.

We need to do a few workarounds to start using Android Studio on Windows 7. Follow these steps after you have downloaded and installed Android Studio.

Step 1: Create new Environmental variable.

Right click My Computer–>Properties. Click on Advanced System Settings. Select Environmental variables. Create a new System variable named JDK_HOME.

Variable Name: JDK_HOME
Variable value: C:\Program Files\Java\jdk1.7.0_05

Step 2: Download Gradle

This StackOverflow link will help you for this step. Follow the workaround by downloading Gradle and then copying the appropriate files to the mentioned Studio locations. Finally, restart Android Studio.

Step 3: Create a new Android Project as you would do normally in Eclipse

Create new Android project







Finally, run the application HelloWorldStudio by clicking on the green color play button at the top.



Tutorial #24: Creating Yellow Interface in ODI

Hello everyone!

In Oracle data integrator (ODI), an interface is an object which populates one datastore, called the target, with data coming from one or more other datastores, known as sources. The fields of the source datastore are linked to those in the target datastore using the concept of Mapping.

Temporary interfaces used in ODI are popularly known as Yellow Interfaces. It is because ODI generates a yellow icon at the time of creation of a yellow interface as opposed to the blue icon of a regular interface.

The advantage of using a yellow interface is to avoid the creation of Models each time you need to use it in an interface. Since they are temporary, they are not a part of the data model and hence don’t need to be in the Model.

So let’s begin and start creating our yellow interface!

Pre-requisites: Oracle 10g Express Edition with *SQL Plus, Oracle Data Integrator 11g.

Open *SQL Plus and create a new table Sales in Oracle. You can use any existing table as well for this tutorial. Insert some dummy data in the table as well.

create table Sales(saleid int primary key, saleperson varchar(30), quantity int);

Sample data inside the table:


Open ODI Studio and perform the following steps!

Step 1: Create new data server, logical and physical schemas for your table. Skip to step 2 if already created.

Step 2: Create Model folder and reverse engineer your table. Skip to step 3 if already created.

Step 3: Create new interface

Make a new interface called test_yellow_interface. Make sure you select the correct logical schema. IKM used in this case is Oracle Incremental Update.



Under options set Flow Control to false and Create_Targ_Table to true.

create yellow interface

create yellow interface

Run the interface. If no errors occur, your yellow interface will work! Now, you can use this temporary interface instead of importing the Sales model over and over again.