How to Create QuickAction Dialog in Android

Official Twitter application for Android  has introduced new Android UI features and behavior patterns such as Dashboard, Search Bar, QuickAction and Action Bar. One of the interesting pattern is QuickActions that displays contextual actions in a list view. This pattern actually already exists in QuickContact dialog/bar in default Contact application (since Android 2.0).

QuickContact QuickContact

The QuickActions dialog is not included in standard Android SDK, so we have to create it manually. At first, i had no idea on how to create it so i decided to download and read the Contact app source code from  Android git. I found that the QuickContact dialog  uses private API call ( that does not exists in standard SDK. After posting question about it on google groups and stack overflow, i got the solution for it from Qberticus (thanx Qberticus!).

Qberticus’s QuickActions uses simple/plain layout so i have to create a custom layout so it will look like QuickContact in Contact app or QuickActions in Twitter app. Based on QuickContact source code, i made a slight modification on Qberticus’s BetterPopupWindow class and extended it to implement custom layout. I also made it customizeable, so the icon and text in action list can be customized.

Here are the screenshoots of QuickActions demo:

QuickContact / Twitter-like QuickActions


Code snippet

Create action items:

//Add action item
ActionItem addAction = new ActionItem();
//Accept action item
ActionItem accAction = new ActionItem();
//Upload action item
ActionItem upAction = new ActionItem();

Line 02: Create new action item
Line 04: Set action title
Line 05: Set action icon

Create quickaction instance and setup listener:

final QuickAction mQuickAction  = new QuickAction(this);
//setup the action item click listener
mQuickAction.setOnActionItemClickListener(new QuickAction.OnActionItemClickListener() {
        public void onItemClick(int pos) {
        if (pos == 0) { //Add item selected
           Toast.makeText(Example1Activity.this, "Add item selected", Toast.LENGTH_SHORT).show();
        } else if (pos == 1) { //Accept item selected
           Toast.makeText(Example1Activity.this, "Accept item selected", Toast.LENGTH_SHORT).show();
        } else if (pos == 2) { //Upload item selected
           Toast.makeText(Example1Activity.this, "Upload items selected", Toast.LENGTH_SHORT).show();

Line 1: Create quickaction instance
Line 3-5: Add the action items into quikaction
Line 8: Setup listener for action item clicked, the pos argument on onItemClick method shows which action item is clicked.

Show quickAction dialog:

btn1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {;

Line 04: Show quickaction dialog, the v argument used as the anchor where the quickaction displayed.

Gallery3D-like QuickActions



How to Implement Google Cloud Messaging?

Hi guys, I will explain and show you a simple GCM Implementation.


Because C2DM has been officially deprecated as of June 26, 2012 :p



1. Apache Ant –

2. Apache Tomcat –

First of all you need to get an API key from Google API Console.

Getting your Sender ID

  • STEP 1.  Register Here .
  • STEP 2.  Click Create project. Your browser URL will change to something like:
    " "

    Take note of the value after#project: (4815162342 in this example). This is your project ID, and it will be used later on as the GCM sender ID. This Id will be used by the Android Device while Registering for Push Notification.

  • STEP 3. Choose Service tab from the left side menu on the web page. and turn on “ Google Cloud Messaging for Android “
  • STEP 4. Go to API Access tab from the left menu of web page.

Note: If you going to use a static IP, provide it. If u don’t have, don worry.

Just press Create new Server key and note down the generated API key.


Google has already some things to implement this. Just grab it from (You need to have git installed in ur PC)

if you don’t have git, get it from here –

Server Implementation:

1. After downloading or else gitting, just extract and/or open up


2. Open “api.key” with some text editor, some sample text will be there. Replace it with your API key.

3. open cmd there and navigate to the path(root of gcm-demo-server), you could find a build.xml.

Just give “ant war” in cmd. you will get a “gcm-demo.war” inside “dist” folder (gcm-demo-server\dist)

4. Copy that war file and paste it to “webapps” folder of tomcat.

Just check it whether its working “http://localhost:8080/gcm-demo”

It should give like the thing below.

Great your server implementation is over now.

Client Implementation:

Download GCMDemo (Client side) from here –

Extract and add it to IDE

If you have ADT or some issues with tools, follow the below things:

For this just create android project in your IDE with some name, eg: “GCMDemo”

Goto “gcm\samples\gcm-demo-client”, do the following:

1. Open up “AndroidManifest.xml” and copy it to the same xml which is in android project.

2.Open up “res” folder, you could find some folders. Just drag and drop it to “res”  folder in your android project.

3.Open up “src” folder,you will find a folder named as “src”. Just drag and drop it to “src” folder in your android project.

4.Open up “libs” folder,you will find a file named as “gcm.jar”. Just drag and drop it to “libs” folder in your android project.

For both of the steps, you need to add some spice ups for client implementation.

Open up android project in IDE. Goto “src  >> >>” and do the following.

1. Replace “your_gcm-demo_url” with your server url, static IP users give your static IP.

static final String SERVER_URL = “your_gcm-demo_url”;  In my case “”

For non-static IP users:

Instead of giving “localhost,”, you should give system internal IP which u have mentioned in your network config. Because both of them are giving SocketException. So use system IPv4 Address.

To get it , XP and vista  users type “ipconfig” in your cmd. In W7, Goto Control panel>>Networking and sharing center>> Change adapter settings>>Local Area Connection”

Double click and click details where you could find your IP named as “Ipv4 Address”

2. Replace “your_sender_id_from_api_console_url” with your sender ID, like 4815162342 in this example

static final String SENDER_ID = “your_sender_id_from_api_console_url”;

Uffff! Just run your application in emulator now. Wait! wait! Just add an google account in your emulator. And then run your application. you can get following result.

Now refresh your server URL. you should get whats shown below.

Press “Send Message”. You will get a notification in your emulator.

Voila!! You did it!

If u have any doubts catch me on –

Create Developer Accounts :)

Android Developer Pages:
Android Developer Account
Sony Developer Account For Android
Samsung Developer Account

Other Mobile Developer Pages
Nokia Developer Account  – Qt, Symbian, S40
Samsung Bada Developer Account  – Bada
Blackberry Developer Account – BlackBerry
Windows Phone Developer Account – Windows Phone
Windows Mobile Developer Account – Windows Mobile
Apple Developer Account – iOS, Mac
MeeGo Developer Account – MeeGo
HP webOS(Palm) Developer Account – WebOs
SonyMobile Developer Account – Sony Mobile

Cross Platform IDE:
Corona SDK – Paid
Phonegap – Free
Titanium IDE – Free

Social Networking Developer Accounts and API’s:
Facebook Developer Account
Twitter Developer Account
MySpace Developer Account

Other Developer Accounts:
Verizon Developer Account
Amazon Developer Account
Nvidia Developer Account
Intel Developer Account

What is SuperUser??

Superuser is the app that manages what apps on your rooted device have access to su. Apps that are granted su have elevated permissions and can modify just about any part of the system. The app was originally written by zinx, and I took it and made it much more useable. The app consists of two parts, Superuser.apk and the su binary.

Superuser.apk runs as any other app and gives you, the user, a place to see what apps you have allowed or denied, as well as view a log of what apps have used su when.

The su binary is what other apps call when they need superuser rights. The binary checks the database maintained by Superuser.apk to determine if you have already granted rights to the requesting app, and if not tells Superuser.apk to display a prompt asking you for permission.

Superuser comes pre-installed on any rooted ROM. In fact, without it, you don’t have a rooted device at all. You cannot uninstall it, it lives on the system partition with other apps that came pre-installed on your device. It can be updated from the Market if the developer of your particular ROM has used a version that is signed with the proper keys, which are publicly available on my github.


Installing Superuser isn’t somethng you would need to do under normal circumstances, but just in case here are the files needed:


Donut (1.6)

md5: 9d203f6b7ee6ca7c33a03beedd04a02f | mirror | RM Web Connect
binary only
md5: 10af16ae444c942720f178fb47c52dc8 | mirror | RM Web Connect

Eclair/Froyo/Gingerbread/Honeycomb/IceCreamSandwich (2.1 – 4.0.3)
md5: fc462fa0630379edbe10006b1d19d9b1 | mirror | RM Web Connect
binary only
md5: 26d08a253f1883c13561d173094d70b9 | mirror | RM Web Connect

Older versions