Tuesday, December 4, 2012

Access ContactsContract.CommonDataKinds.Phone via LOOKUP_KEY

Last exercise demonstrate how to "Handle Item Click on Query Contacts database ListView". In this exercise, it will be modified retrieve ContactsContract.CommonDataKinds.Phone, a data kind representing a telephone number.

Access ContactsContract.CommonDataKinds.Phone via LOOKUP_KEY


In last exercise, we have get the column LOOKUP_KEY without actually using it. The column LOOKUP_KEY that is a "permanent" link to the contact row. Because the Contacts Provider maintains contacts automatically, it may change a contact row's _ID value in response to an aggregation or sync. Even If this happens, the content URI CONTENT_LOOKUP_URI combined with contact's LOOKUP_KEY will still point to the contact row, so you can use LOOKUP_KEY to maintain links to "favorite" contacts, and so forth. This column has its own format that is unrelated to the format of the _ID column. ~ To understand it in more details, refer HERE.

package com.example.androidquerycontacts;

import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.provider.ContactsContract.Contacts;
import android.support.v4.content.CursorLoader;
import android.support.v4.widget.CursorAdapter;
import android.support.v4.widget.SimpleCursorAdapter;
import android.app.Activity;
import android.database.Cursor;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class MainActivity extends Activity {

ListView listContacts;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

listContacts = (ListView)findViewById(R.id.conactlist);

Uri queryUri = ContactsContract.Contacts.CONTENT_URI;

String[] projection = new String[] {
ContactsContract.Contacts._ID,
ContactsContract.Contacts.DISPLAY_NAME,
ContactsContract.Contacts.HAS_PHONE_NUMBER,
ContactsContract.Contacts.LOOKUP_KEY};

String selection = ContactsContract.Contacts.DISPLAY_NAME + " IS NOT NULL";

CursorLoader cursorLoader = new CursorLoader(
this,
queryUri,
projection,
selection,
null,
null);

Cursor cursor = cursorLoader.loadInBackground();

String[] from = {ContactsContract.Contacts.DISPLAY_NAME};
int[] to = {android.R.id.text1};

ListAdapter adapter = new SimpleCursorAdapter(
this,
android.R.layout.simple_list_item_1,
cursor,
from,
to,
CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
listContacts.setAdapter(adapter);

listContacts.setOnItemClickListener(myOnItemClickListener);
}

OnItemClickListener myOnItemClickListener
= new OnItemClickListener(){

@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
Cursor cursor = (Cursor)parent.getItemAtPosition(position);
int item_ID = cursor.getInt(cursor.getColumnIndex(ContactsContract.Contacts._ID));
String item_DisplayName = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
int item_HasPhoneNumber = cursor.getInt(cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER));

String item_LookUp = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));

/*
String item_PhoneNumber = "";
if (item_HasPhoneNumber > 0){
item_PhoneNumber = "Has phone number.";

}else{
item_PhoneNumber = "No number.";
}

String item = String.valueOf(item_ID) + ": " + item_DisplayName
+ "\n" + item_PhoneNumber
+ "\nLOOKUP_KEY: " + item_LookUp;

Toast.makeText(getApplicationContext(), item, Toast.LENGTH_LONG).show();
*/

Uri lookUpUri = ContactsContract.Data.CONTENT_URI;
String[] projection = new String[] {
ContactsContract.CommonDataKinds.Phone.NUMBER,
ContactsContract.CommonDataKinds.Phone.TYPE,
ContactsContract.CommonDataKinds.Phone.LABEL};
String selection = ContactsContract.Data.LOOKUP_KEY + "=?";
String[] selectionArgs = new String[]{item_LookUp};

CursorLoader cursorLoader_LookUp = new CursorLoader(
MainActivity.this,
lookUpUri,
projection,
selection,
selectionArgs,
null);
Cursor cursor_LookUp = cursorLoader_LookUp.loadInBackground();

int lookUpCol_Type = cursor_LookUp.getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE);
int lookUpCol_Number = cursor_LookUp.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
int lookUpCol_Label = cursor_LookUp.getColumnIndex(ContactsContract.CommonDataKinds.Phone.LABEL);

String stringNums = item_LookUp + "\n";
while(cursor_LookUp.moveToNext()){
int type = cursor_LookUp.getInt(lookUpCol_Type);

String stringType;
switch(type){
case ContactsContract.CommonDataKinds.Phone.TYPE_CUSTOM:
//the actual type in LABEL
stringType = "*" + cursor_LookUp.getString(lookUpCol_Label) + "*";
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_HOME:
stringType = "HOME";
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE:
stringType = "MOBILE";
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_WORK:
stringType = "WORK";
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_FAX_WORK:
stringType = "FAX_WORK";
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_FAX_HOME:
stringType = "FAX_HOME";
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_PAGER:
stringType = "PAGER";
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_OTHER:
stringType = "OTHER";
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_CALLBACK:
stringType = "CALLBACK";
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_CAR:
stringType = "CAR";
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_COMPANY_MAIN:
stringType = "COMPANY_MAIN";
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_ISDN:
stringType = "ISDN";
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_MAIN:
stringType = "MAIN";
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_OTHER_FAX:
stringType = "OTHER_FAX";
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_RADIO:
stringType = "RADIO";
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_TELEX:
stringType = "TELEX";
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_TTY_TDD:
stringType = "TTY_TDD";
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_WORK_MOBILE:
stringType = "WORK_MOBILE";
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_WORK_PAGER:
stringType = "WORK_PAGER";
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_ASSISTANT:
stringType = "ASSISTANT";
break;
case ContactsContract.CommonDataKinds.Phone.TYPE_MMS:
stringType = "MMS";
break;
default:
stringType = "unknown";
break;
}

String stringNumber = cursor_LookUp.getString(lookUpCol_Number);

stringNums += String.valueOf(type) + " " + stringType + " : " + stringNumber + "\n";
}

Toast.makeText(getApplicationContext(),
stringNums,
Toast.LENGTH_LONG).show();

}

};

}


download filesDownload the files.


Next:
- Get Email from Contacts database


Google Maps Garage: Google Maps Android API V2



From the developers of Trulia Android App, about the app and how to migrate the new Google Maps Android API V2.

BEST GAME ANDROID FREE DOWNLOAD Absolute RC Plane Simulator v2.7.0 Apk Android


Possibly the best RC plane simulator for Android!
Get 4 models and 3 landscapes with this value pack edition of our Absolute RC Plane Sim, for big savings compared to buying them one by one. In addition to the included content, you can still buy extra models if needed.


The Absolute RC Sim is a professional RC plane simulator and must have for anyone flying RC. The models fly like real RC planes, and can be used to learn to fly and to improve your flying. A lot of fun for not much money! Any plane crash cost many times more, and you will be able to fly in the sim no matter what is the weather outside!

Included free models in this version:

Apprentice (Trainer)
AT-6 Harvard (Low Wing Intermediate)
P-51 Mustang (War bird scale - Intermediate-Advanced)
A-10 Warthog (Electric fan scale - Advanced)

Included free landscapes in this version: :

Osage Park
Tangamanga
Island Fliers

Please try our full featured professional RC flight simulator ClearView for PC here: http://rcflightsim.com - see the video of ClearView bellow.

Notes:
1. This is not a game. You are controlling flying rc models that reacts like real flying models. It takes some time to learn, and again, do not expect "arcade" style controls.
2. The onscreen control sticks are just indicators! They are made small so they do not obscure the screen.

*** You do not need to keep your fingers on them ***

Sliding your finger any where on the right screen half affects the right control stick , the same for the left screen part - sliding finger there moves the left control stick.

We suggest to select beginner settings at first few days before you can comfortably progress further.

Click Here To Download
Direct Download Link


The Magician's Handbook II: BlackLore v1.0 Apk Android


Two years have passed and your trip to the Cursed Valley is only a memory. The pages of the Magician’s Handbook remain blank and life has resumed to its natural course, until the day when a tiny fairy appears in your house pleading for help. The evil magician pirate, Blacklore, has captured all the magicians and fairies to use good magic for evil purposes. Search gorgeous, hand drawn locations, learn powerful spells to solve witty puzzles, free your friends and stop Blacklore in this immersive sequel to The Magician's Handbook: Cursed Valley!


• 21 Challenging mini-games
• 16 Spooky locations
• 11 Captivating chapters
• 5 Powerful spells
• 3 Gameplay modes: casual, apprentice and magician

PLEASE NOTE: This app lets you purchase digital content using actual money. You can configure parental controls for in-app purchases, which will require your Amazon account password or a 4-digit PIN, by going to the Settings menu from within the Amazon Appstore.

21 Challenging mini-games
16 Spooky locations
11 Captivating chapters
5 Powerful spells
3 Gameplay modes: casual, apprentice and magician

Click Here To Download
Direct Download Link


Boost 2 v1.0.8 Apk Android


Experience the fastest tunnel racer ever made on Android! Boost 2: Now available on Android.
"...among the iPhone tunnel games, Boost is king" - Touch Arcade

"It was the best tunnel racer when it was originally released in 2009, and I'm having a hard time thinking of a better one that has been released since then" - Touch Arcade


"I don’t consider myself a fan of racing games, but Boost 2 was a welcome change to my usual gaming fare." - AppAdvice

"Lanis has crafted a beautiful tunnel-racer that makes its predecessor, Cube Runner, look crude by comparison" - Thumb Spree

"Addicting Solid Tunnel Game" - itunesgames.net

Click Here To Download
Direct Download Link


Monday, December 3, 2012

Angry Birds Star Wars v1.1.0 | APK Download

Angry Birds Star Wars

Developer: Rovio Mobile Ltd.
Version: 1.1.0
Requires Android: 2.2 and up
Category: Arcade & Action
Size: 38 MB
Price: Free
Average Rating: 4.5 / 5.0

May the birds be with you! Join the Angry Birds in their biggest adventure yet!

A long time ago in a galaxy far, far away, a group of desperate rebel birds faced off against a galactic menace: The Empire’s evil Pigtroopers!

Rebel birds, striking from a hidden base, have won their first victory against the evil Imperial Pigs. During the battle, Rebel spies managed to steal secret plans to the Empire’s ultimate weapon, the Pig Star, and are racing to deliver the plans to the Rebel Birds. Now they need your help!

Join an epic adventure with the Angry Birds in the legendary Star Wars™ universe! Use the Force, wield your lightsaber, and blast away Pigtroopers on an intergalactic journey from the deserts of Tatooine to the depths of the Pig Star – where you’ll face off against the terrifying Darth Vader, Dark Lord of the Pigs! Can you become a Jedi Master and restore freedom to the galaxy?

Time to grab your lightsaber and join the adventure! May the birds be with you!

Hours And Hours of Engaging Gameplay
  • Explore more than 80 levels in iconic locations like Tatooine and the Pig Star. Can you dodge Imperial pigs, laser turrets, Tusken Raider pigs, and the dark side of the Force to get all three stars?
New Gameplay Mechanics
  • Use lightsabers, Blasters and Jedi powers to wreak havoc on the Imperial Pigs!
Level Up Your Birds
  • Keep playing and level up your birds to improve their skills!
Secrets And Hidden Goodies
  • Can you unlock all the R2-D2 and C-3PO bonus levels?
Free Updates
  • This is only the beginning of the epic saga!
The Mighty Falcon
  • Stuck on a tricky level? Earn stars and call the Mighty Falcon to rain down the destruction. New goals, achievements and gameplay!
Path of the Jedi
  • The ultimate training ground for a Young Jedi, this in-app purchase unlocks 40 Dagobah Challenge Levels with Jedi Master Yoda! Master the Path of the Jedi to unlock the ultimate lightsaber!
Screenshots:


For more info, visit Angry Birds Star Wars on Google Play.

Angry Birds Star Wars HD v1.1.0 | APK Download

Angry Birds Star Wars HD

Developer: Rovio Mobile Ltd.
Version: 1.1.0
Requires Android: 2.2 and up
Category: Arcade & Action
Size: 45 MB
Price: US$2.99
Average Rating: 4.4 / 5.0

May the birds be with you! Join the Angry Birds in their biggest adventure yet!

A long time ago in a galaxy far, far away, a group of desperate rebel birds faced off against a galactic menace: The Empire’s evil Pigtroopers!

Rebel birds, striking from a hidden base, have won their first victory against the evil Imperial Pigs. During the battle, Rebel spies managed to steal secret plans to the Empire’s ultimate weapon, the Pig Star, and are racing to deliver the plans to the Rebel Birds. Now they need your help!

Join an epic adventure with the Angry Birds in the legendary Star Wars™ universe! Use the Force, wield your lightsaber, and blast away Pigtroopers on an intergalactic journey from the deserts of Tatooine to the depths of the Pig Star – where you’ll face off against the terrifying Darth Vader, Dark Lord of the Pigs! Can you become a Jedi Master and restore freedom to the galaxy?

Time to grab your lightsaber and join the adventure! May the birds be with you!

Hours And Hours of Engaging Gameplay
  • Explore more than 80 levels in iconic locations like Tatooine and the Pig Star. Can you dodge Imperial pigs, laser turrets, Tusken Raider pigs, and the dark side of the Force to get all three stars?
New Gameplay Mechanics
  • Use lightsabers, Blasters and Jedi powers to wreak havoc on the Imperial Pigs!
Level Up Your Birds
  • Keep playing and level up your birds to improve their skills!
Secrets And Hidden Goodies
  • Can you unlock all the R2-D2 and C-3PO bonus levels?
Free Updates
  • This is only the beginning of the epic saga!
The Mighty Falcon
  • Stuck on a tricky level? Earn stars and call the Mighty Falcon to rain down the destruction. New goals, achievements and gameplay!
Path of the Jedi
  • The ultimate training ground for a Young Jedi, this in-app purchase unlocks 40 Dagobah Challenge Levels with Jedi Master Yoda! Master the Path of the Jedi to unlock the ultimate lightsaber!
Screenshots:


For more info, visit Angry Birds Star Wars HD on Google Play.

Password: axa