Android's first application (dialing)

Source: Internet
Author: User



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

 


 

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.