Android Call Call code

Source: Internet
Author: User

Package auscend.sdk;

Import android.app.Activity;
Import android.content.Intent;
Import Android.net.Uri;
Import Android.os.Bundle;
Import Android.view.View;
Import Android.view.View.OnClickListener;
Import Android.widget.Button;
Import Android.widget.EditText;

public class Android_2activity extends Activity {

Private EditText et;
Private Button BT;

@Override
public void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.main);

ET = (EditText) Findviewbyid (r.id.et);
BT = (Button) Findviewbyid (R.id.button);

Bt.setonclicklistener (New Onclicklistener ()
{

@Override
public void OnClick (View v)
{
Incoming service, parse () parse number
Intent Intent = new Intent (Intent.action_call, Uri.parse ("Tel:" + et.gettext ()));
Notifies activtity to process incoming call service
Android_2Activity.this.startActivity (Intent);
}

});
}
}

XML layout
<?xml version= "1.0" encoding= "Utf-8"?>
<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:layout_width= "Fill_parent"
android:layout_height= "Fill_parent"
android:orientation= "Vertical" >

<textview
Android:id= "@+id/tv"
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"
android:text= "@string/phone"/>

<edittext
Android:id= "@+id/et"
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"/>

<button
Android:id= "@+id/button"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:text= "@string/button"/>

</LinearLayout>

Phone service Add
<?xml version= "1.0" encoding= "Utf-8"?>
<manifest xmlns:android= "Http://schemas.android.com/apk/res/android"
Package= "ANDROID.SDK"
Android:versioncode= "1"
Android:versionname= "1.0" >

&LT;USES-SDK android:minsdkversion= "Ten"/>
<!--phone service add-
<uses-permission android:name= "Android.permission.CALL_PHONE"/>

<application
android:icon= "@drawable/ic_launcher"
Android:label= "@string/app_name" >
<activity
Android:label= "@string/app_name"
Android:name= ". Android_callactivity ">
<intent-filter >
<action android:name= "Android.intent.action.MAIN"/>

<category android:name= "Android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>

SOURCE:</manifest>
http://blog.163.com/[email protected]/blog/static/172710222201111110149176/

Android Call Call code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.