Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Mobile Development > BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2
BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2
This is the forum to discuss the Wrox book Professional Android Application Development by Reto Meier; ISBN: 9780470344712
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 23rd, 2009, 01:24 PM
Registered User
Join Date: Mar 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter-5 on Intents:ContactPickerTester does not show the button "Pick a Contact"

I am was trying to run the example from the chapter 5 on Intents... The created the ContactPicker and ContactPckerTester activities. Everything looks ok - compiling, running but I am not sure what to look for. The first activity that gets invoked is "ContactPickerTester" and rightly so , since the manifest defines the intent filter for it as action.MAIN and category.LAUNCHER.

However, it does not do anything after launching activity. I do not see the button to click "Pick Contact" ( the book says "Pick a Contact"). On debug mode , my control gets into a code outside by codebase after it reaches the
button.setOnClickListener(new OnClickListener() ..

Kindly explain to me what is happening?. I have coded both the contactpicker and contactPickerTest and I am convinced that I am passing the correct Intent. However I do not see the what is shown in the figure 5-1.

I am very confused.. thanks a ton for any help..

The full code for the ContactPickerTester.java is:

class ContentPickerTester extends Activity {
publicstaticfinalintPICK_CONTACT =1;


publicvoid onCreate(Bundle savedInstanceState) {
Button button = (Button)findViewById(R.id.
if (button== null)
new OnClickListener(){
publicvoid onClick(View _view) {
Intent intent =
new Intent(Intent.ACTION_PICK,Uri.parse("content://contacts/"));

protectedvoid onActivityResult(int reqCode, int resCode, Intent data){
//public void OnActivityResult(int reqCode, int resCode, Intent data){

super.onActivityResult(reqCode, resCode, data);
if (resCode == Activity.RESULT_OK){
Uri ContactData = data.getData();
Cursor c = managedQuery(ContactData,
null, null, null, null);
String name;
name = c.getString(c.getColumnIndexOrThrow(People.
TextView tv ;
tv= (TextView)findViewById(R.id.

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

<application android:icon="@drawable/icon" android:label="@string/app_name">

<activity android:name=".ContactPicker"


<action android:name="android.intent.action.PICK" />

<category android:name="android.intent.category.DEFAULT" />

<data android:path="contacts"




<activity android:name=".ContentPickerTester"
android:label="Contact Picker Test">


<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />



<uses-permission android:name="android.permission.READ_CONTACTS"/>

Old April 14th, 2009, 02:57 PM
Authorized User
Join Date: Mar 2009
Posts: 21
Thanks: 0
Thanked 3 Times in 3 Posts

What about your contactpickertester.xml file? What does that look like?
Old April 14th, 2009, 03:08 PM
Registered User
Join Date: Mar 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default I am attaching the ContactPickerTest.xml file

Thanks for your response.

attached is my contactpickertest.xml. lemme know what you think: thanks in advance

xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" >
<TextView android:id="@+id/selected_contact_textView" android:layout_width="fill_parent" android:layout_height="fill_parent" />
<Button android:id="@+id/pick_content_button" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text ="Pick Contact" />

Old April 15th, 2009, 11:55 AM
Authorized User
Join Date: Mar 2009
Posts: 21
Thanks: 0
Thanked 3 Times in 3 Posts

Well, you don't have correct values defined for layout_height of TextView or Button. Instead of "fill_parent", these should be set to "wrap_content".

I'm not exactly sure why a GIANT button isn't created. Maybe Android refuses to create a button that large. But if you correct the XML layout values, you should see the button appear.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Code not going as planned: "icicle" vs "savedinstancestate" joopthecat BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 3 May 3rd, 2009 03:09 PM
The Myth of "Good Web Design is in the Graphics" iminore PHP Databases 0 March 9th, 2009 02:02 PM
Message received by "FILE" adapter is suspended skindika Biztalk 0 February 2nd, 2009 07:06 PM
WebPart not supporting/enabled displaymode other than "Browse" amitjoshipune ASP.NET 2.0 Professional 1 January 9th, 2009 02:34 PM
google Response.Write(Request.QueryString("q")) senol01 ASP.NET 2.0 Basics 1 January 2nd, 2009 12:01 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.