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, 02:27 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
I know you can use Intent.ACTION_DIAL to bring up the dialer with the supplied phone number.
But how do you make the actual call from an app, i know theres and Intent.ACTION_CALL.

here my code of a simple app enter the phone number and press the button to place the call
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;

public class MakeCall extends Activity implements View.OnClickListener{
    EditText editText;
    Button callBtn;
    
    @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);
    }

	@Override
	public void onClick(View v) {
		if(v.getId() == R.id.callBtn) {
			String phn_number = editText.getText().toString();
			if(!phn_number.equals("")) {
				Intent dial_intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phn_number));
				startActivity(dial_intent);
				Intent call_intent = new Intent(Intent.ACTION_CALL); //not sure how to implement this action
				startActivity(call_intent);
			}
						
		}
	}
    
    
}
my layout
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"
	/>
</LinearLayout>
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
Call waiting, switching from call to call tazz Droid 2 01-27-2011 05:03 PM
Want to make an app but have no idea where to start! cyberpedz Android Games And Applications 0 01-04-2010 02:26 AM
Afraid to make the purchase coachnref825 Android Hardware 3 12-07-2009 03:06 PM
Two app ideas (can any1 make?) evolve Android Games And Applications 1 02-27-2009 11:34 AM
Can anyone make this app ????? Crush Android Games And Applications 0 02-23-2009 10:31 AM


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

All times are GMT -6. The time now is 04:56 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.