[VIDEO-Tut] Building an Contact-Caller App in Minutes

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

Postby saahil » Mon Aug 25, 2008 7:56 am

k, thx neway square.
hey plusminus, can u help me?? this is the problem i've been having in almost all of the tutorials that have been described in the forums. plz help :? :(
Posts: 5
Joined: Sun Aug 24, 2008 6:42 pm
Location: Manipal, Karnataka, India


Postby Gurbuh » Sun Sep 14, 2008 2:56 pm

saahil wrote:hey,
ctrl+shift+o didn't change nething. says, 0 imports added. plz help me. btw, i use SDK 0.9 beta, and i guess most of the people here use the m3 or m5 versions. is the problem because of the different versions of the SDK, that the earlier imports or functions are depricated or something? if yes, then plz tell me as to wat would be the solution to this.

I'm having the same trouble (with most tutorials on here btw) with trying to 'convert' them to SDK 0.9. The first error you are getting is probably because your main.xml is not correct.

The second one, I am trying to figure out as we speak. I think/hope i am getting close. Will post the solution if i find it. :wink:
Junior Developer
Junior Developer
Posts: 17
Joined: Mon Sep 08, 2008 9:49 pm
Location: The Netherlands

runtime error?

Postby tintin » Thu Feb 05, 2009 3:36 pm

Hi, I am new to Java/Android so bear with me.

My eclipse should have been setup correctly since the example code in the sdk can run without any problem.
I copied the source above (contact and dial) to Eclipse and tried to run this app. No error msg showing up in Eclipse IDE while a dialog popup on the emulator saying "The application XXX (process com.xx.xx.XXX) has stopped unexpectedly. Please try again. " I tried to
run debug and found the program stopped at the line with (*)

Cursor c = getContentResolver().query(People.CONTENT_URI, null, null, null, null);
startManagingCursor(c); (*)<--stop here.

No any relevant log msg. Anyone has any thought?
Posts: 3
Joined: Thu Feb 05, 2009 3:29 pm

Postby MrSnowflake » Thu Feb 05, 2009 3:51 pm

Ofcourse there's a relevant log message. Did you check ik with logcat?
User avatar
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

logcat is empty

Postby tintin » Thu Feb 05, 2009 4:04 pm

Ran debug for several time. logcat is empty. Or did I do anything wrong by mistake to disable logging?

But another window said "source not found" with a small button allowing me to "Edit source Lookup Path". The file name appeared at the top of the window is "ActivityThread.performLaunchActivity (activityThread$ActivityRecord) line 2140". Thought?
Posts: 3
Joined: Thu Feb 05, 2009 3:29 pm

Postby horse » Sat Feb 07, 2009 8:34 pm

saahil wrote:hello plusminus

i am getting the following two errors in the code -

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. int[] names = new int[]{R.id.row_entry};
  2. R.id cannot be resolved
Parsed in 0.032 seconds, using GeSHi


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Intent i = new Intent(Intent.CALL_ACTION);
  2. Intent.CALL_ACTION cannot be resolved
Parsed in 0.032 seconds, using GeSHi

plz help... :(


I also received an error on PREFERRED_PHONE_ID which worked when changed to PRIMARY_PHONE_ID

Hope that helps someone, I went fishing in #android on irc.freenode for help :) So thank Romainguy
Posts: 2
Joined: Sat Feb 07, 2009 8:30 pm


update to my previous post

Postby tintin » Sun Feb 08, 2009 10:44 am

I copied all the source to my Vista and ran there with Android windows SDK (I was running ubunuty 8.10). The program runs without any problem. So I doubt whether it is because of the differences in Android SDK or Java. Not sure whether anyone ever experienced this.

quite disappointed that no one was able to advice anything.
Posts: 3
Joined: Thu Feb 05, 2009 3:29 pm

Re: [VIDEO-Tut] Building an Contact-Caller App in Minutes

Postby WynixToo » Tue Jul 20, 2010 9:56 am

Hi plusminus,

i have notice the the class "android.provider.Contacts.People" was deprecated after API 2.0. and using the "android.provider.ContactsContract" class for the contact list.

may i know how to correct the code which allow to run in API 2.0? or is it have any other way which can run it in all the version of Android?

Thanks you.

P/S: i'm sorry my english grammer no very well, hope u guy understand what i'm talking about.
Thanks again.

Junior Developer
Junior Developer
Posts: 16
Joined: Fri Jul 02, 2010 10:36 am
Location: Malaysia

Re: [VIDEO-Tut] Building an Contact-Caller App in Minutes

Postby Quelle » Wed Sep 08, 2010 11:10 am


How i work with the contact list in android version 2.00 and higher.
Posts: 34
Joined: Thu Mar 11, 2010 10:53 am

Building an Contact-Caller App in Minutes - Android 2.2

Postby edreamz » Thu Sep 09, 2010 11:31 pm

Hello plusminus,
I am building this tutorial on a Android 2.2 platform, looks like there is a few items that are deprecated. So I changed it and ran the tutorial. I was able to bring the app, but when I click on the item list, the CALL intent is not started and I am getting the following exception.

ERROR/AndroidRuntime(1492): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.CALL dat=content://com.android.contacts/data/4 }

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.felix.contactlist;
  3. import android.app.ListActivity;
  4. import android.content.ContentUris;
  5. import android.content.Intent;
  6. import android.database.Cursor;
  7. import android.os.Bundle;
  8. import android.provider.ContactsContract;
  9. import android.provider.ContactsContract.Contacts;
  10. import android.view.View;
  11. import android.widget.ListView;
  12. import android.widget.SimpleCursorAdapter;
  14. public class ContactList extends ListActivity {
  15.         private SimpleCursorAdapter madapter;
  17.         /** Called when the activity is first created. */
  18.         @Override
  19.         public void onCreate(Bundle savedInstanceState) {
  20.                 super.onCreate(savedInstanceState);
  21.                 //setContentView(R.layout.main);
  22.                 Cursor c = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null,
  23.                                 null, null, null);
  24.                 startManagingCursor(c);
  26.                 String[] columns = new String[] {Contacts.DISPLAY_NAME};
  27.                 int[] names = new int[] {R.id.row_entry};
  29.                 madapter = new SimpleCursorAdapter(this, R.layout.main, c, columns, names);
  30.                 this.setListAdapter(madapter);
  31.         }
  33.         @Override
  34.         protected void onListItemClick(ListView l, View v, int position, long id) {
  35.                 super.onListItemClick(l, v, position, id);
  36.                 Intent i = new Intent(Intent.ACTION_CALL);
  37.                 Cursor c = (Cursor) madapter.getItem(position);
  38.                 long phoneId = c.getLong(c.getColumnIndex(ContactsContract.PhoneLookup._ID));
  39.                 i.setData(ContentUris.withAppendedId(ContactsContract.Data.CONTENT_URI, phoneId));
  40.                 startActivity(i);
  42.         }
  43. }
Parsed in 0.040 seconds, using GeSHi

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.         android:orientation="vertical" android:layout_width="wrap_content"
  4.         android:layout_height="wrap_content">
  6.         <TextView android:layout_width="wrap_content"
  7.                 android:layout_height="wrap_content" android:text="Name: " />
  9.         <TextView android:id="@+id/row_entry" android:layout_width="wrap_content"
  10.                 android:layout_height="wrap_content" />
  11. </LinearLayout>
Parsed in 0.002 seconds, using GeSHi

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3.         package="com.felix.contactlist" android:versionCode="1"
  4.         android:versionName="1.0">
  5.         <uses-permission android:name="android.permission.READ_CONTACTS" />
  6.         <uses-permission android:name="android.permission.CALL_PHONE" />
  7.         <application android:icon="@drawable/icon" android:label="@string/app_name">
  8.                 <activity android:name=".ContactList" android:label="@string/app_name">
  9.                         <intent-filter>
  10.                                 <action android:name="android.intent.action.MAIN" />
  11.                                 <category android:name="android.intent.category.LAUNCHER" />
  12.                         </intent-filter>
  13.                 </activity>
  14.         </application>
  15. </manifest>
Parsed in 0.003 seconds, using GeSHi
User avatar
Junior Developer
Junior Developer
Posts: 18
Joined: Fri Aug 06, 2010 2:29 am
Location: U.S

Re: [VIDEO-Tut] Building an Contact-Caller App in Minutes

Postby David Moldenhauer » Mon Feb 07, 2011 12:17 pm

how to make a call in Android 2.2 :

package com.daviesmeyer.android.makeacall;

import android.app.ListActivity;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.Contacts;
import android.view.View;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.util.Log;

public class MakeACall extends ListActivity {

private SimpleCursorAdapter mAdapter;
private static final String TAG = "MyMessage";
public String[] contactID;
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
Cursor c = getContacts();

String[] columns = new String[]{Contacts.DISPLAY_NAME};
int[] names = new int[]{android.R.id.text1};

//Log.v(TAG, theNumber[0]);

mAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, c, columns, names);

protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);

Intent i = new Intent(Intent.ACTION_CALL);
ContentResolver cr = getContentResolver();

Cursor c = (Cursor) mAdapter.getItem(position);
//long phoneId = c.getLong(c.getColumnIndex(ContactsContract.Contacts._ID));
String myID = (String)c.getString(c.getColumnIndex(ContactsContract.Contacts._ID));
Cursor pCur = managedQuery(
ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?",
new String[]{myID}, null);
Log.v(TAG, pCur.getString(pCur.getColumnIndex(Phone.NUMBER)));



private Cursor getContacts() {
// Run query
Uri uri = ContactsContract.Contacts.CONTENT_URI;
String[] projection = new String[] { ContactsContract.Contacts._ID,
ContactsContract.Contacts.DISPLAY_NAME };
contactID = new String[]{ContactsContract.Contacts._ID};
String selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '"
+ ("1") + "'";
String[] selectionArgs = null;
String sortOrder = ContactsContract.Contacts.DISPLAY_NAME

return managedQuery(uri, projection, selection, selectionArgs,

David Moldenhauer
Once Poster
Once Poster
Posts: 1
Joined: Mon Feb 07, 2011 12:15 pm


Return to Novice Tutorials

Who is online

Users browsing this forum: Yahoo [Bot] and 11 guests