Android Forums

Go Back   These FORUMS ARE DISABLED!! OUR NEW FORUMS ARE AT http://androidforum.com/ > Android Coders > Android Development, Answers, Tutorials, and Code Snippets
Connect with Facebook

Click Here To Register!
 
 
LinkBack Thread Tools Display Modes
Old 12-30-2009, 04:42 PM   #1
Junior Member
 
Join Date: Oct 2009
Posts: 1
Friends: 0
View grimx's Profile   View grimx's Photo Album   View grimx's Blog   View Social Groups
How do you get the number back from an implicit call to view the contacts list

.java file
Code:
package com.grimx.MakeCall;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MakeCall extends Activity implements View.OnClickListener{
	private static final int CONTACT_ACTIVITY = 100;
    EditText editText;
    Button callBtn;
    Button contactsBtn;
    Button closeBtn;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        editText = (EditText)findViewById(R.id.editText);
        callBtn = (Button)findViewById(R.id.callBtn);
        callBtn.setOnClickListener(this);
        contactsBtn = (Button)findViewById(R.id.contactsBtn);
        contactsBtn.setOnClickListener(this);
        closeBtn = (Button)findViewById(R.id.closeBtn);
        closeBtn.setOnClickListener(this);
    }

	@Override
	public void onClick(View v) {
		if(v.getId() == R.id.callBtn) {
			String phn_number = editText.getText().toString();
			if(phn_number.equals("")) {
				Toast.makeText(MakeCall.this, "Please Enter A Phone Number", Toast.LENGTH_LONG).show();
				
			}
			else
			{
				Intent call_intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phn_number));
				startActivity(call_intent);
			}
						
		}
		else if(v.getId() == R.id.contactsBtn) {
			Uri uri = Uri.parse("content://contacts/people");
			Intent contacts_intent = new Intent(Intent.ACTION_PICK, uri);
			startActivityForResult(contacts_intent, CONTACT_ACTIVITY);
		}
		else if(v.getId() == R.id.closeBtn) {
			Toast.makeText(MakeCall.this, "Exiting MakeCall", Toast.LENGTH_LONG).show();
			finish();
		}
	}
	
	public void onActivityResult(int requestCode, int resultCode, Intent data){
		super.onActivityResult(requestCode, resultCode, data);
		
		switch(requestCode){
		case(CONTACT_ACTIVITY): {
			if(resultCode == Activity.RESULT_OK) {
				//want to get the number an put it in the editText
				//editText.setText( );
			}
		break;
		}
			
		}
	}
    
    
}
my layout file
Code:
<?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"
    >
<EditText 
	android:id="@+id/editText"
	android:phoneNumber="true"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    />
<Button
	android:id="@+id/callBtn"
	android:layout_width="fill_parent"
	android:layout_height="wrap_content"
	android:text="Call"
	/>
<Button
	android:id="@+id/contactsBtn"
	android:layout_width="fill_parent"
	android:layout_height="wrap_content"
	android:text="Show Contacts"
	/>
<Button
	android:id="@+id/closeBtn"
	android:layout_width="fill_parent"
	android:layout_height="wrap_content"
	android:text="Close"
	/>
</LinearLayout>
AndroidManifest.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.grimx.MakeCall"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".MakeCall"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
    <uses-sdk android:minSdkVersion="3" />
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.CALL_PRIVILEGED" />

</manifest>
grimx is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
 

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert "pause" (p) in number in contacts... G1 dials a "7" instead... sasha26 Android Games And Applications 10 05-07-2010 11:24 AM
Number of widget screens xtiger Droid Eris 1 12-02-2009 08:28 PM
Maximum number of SMS messages sent at one time Russ Garrett Android Chat 0 11-14-2009 11:25 AM
Popular Contacts - Track your most talked to contacts leoromanovsky Android Games And Applications 0 06-15-2009 03:28 PM
Making Calls Showing A Different Number munchie8209 Android Games And Applications 2 03-08-2009 10:21 PM


Unlocked G1 Phones | Buy T-Mobile G1 | Google Phone

All times are GMT -6. The time now is 04:57 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.
Copyright (c) 2012 TalkAndroid.com. All rights reserved.