AndroidManifest. xml
<? Xml version = "1.0" encoding = "UTF-8"?>
<Manifest xmlns: android = "http://schemas.android.com/apk/res/android"
Package = "com. hyl. phone" android: versionCode = "1" android: versionName = "1.0">
<Application android: icon = "@ drawable/maolv" android: label = "@ string/app_name">
<Activity android: name = ". phoneActivity" 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>
<! -- Version 8 for the developed application represents Android2.2 -->
<Uses-sdk android: minSdkVersion = "8"/>
<! -- Specify the call permission here -->
<Uses-permission android: name = "android. permission. CALL_PHONE"/>
</Manifest>
Hyl. xml
<? Xml version = "1.0" encoding = "UTF-8"?>
<Resources>
<String name = "mobellabel"> enter the mobile phone number </string>
<String name = "button"> call this number </string>
</Resources>
Main. xml
<? 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: layout_width = "fill_parent"
Android: layout_height = "wrap_content" android: text = "@ string/mobellabel"
Android: id = "@ + id/TextView01"
/>
<EditText android: id = "@ + id/EditText01"
Android: layout_width = "fill_parent" android: layout_height = "wrap_content"/>
<Button android: text = "@ string/button" android: id = "@ + id/Button01"
Android: layout_width = "wrap_content" android: layout_height = "wrap_content"/>
</LinearLayout>
PhoneActivity. java
Package com. hyl. phone;
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 phoneActivity extends Activity {
/** Called when the activity is first created .*/
Private Button button;
Private EditText editText;
Public void onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState );
SetContentView (R. layout. main );
Button = (Button) this. findViewById (R. id. Button01 );
EditText = (EditText) this. findViewById (R. id. EditText01 );
Button. setOnClickListener (new ButtonListener ());
}
Private final class ButtonListener implements View. OnClickListener {
Public void onClick (View v ){
String phonenum = editText. getText (). toString ();
// Android. intent. action. CALL = Intent. ACTION_CALL
Intent intent = new Intent (Intent. ACTION_CALL, Uri. parse ("tel:" + phonenum ));
StartActivity (intent );
}
}
}
Author: hyljava