Android的第一个应用(拨打电话)



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>
<!-- 开发的应用适应的版本8代表Android2.2 -->
<uses-sdk android:minSdkVersion="8" />
<!-- 这里指定拨打电话的权限 -->
<uses-permission android:name="android.permission.CALL_PHONE" />
</manifest>
hyl.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="mobellabel">请输入手机号码</string>
<string name="button">拨打此号码</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);
}

}


}



Android的第一个应用(拨打电话)_第1张图片

Android的第一个应用(拨打电话)_第2张图片

更多相关文章

  1. android 图片水平显示,类Gallery效果
  2. android 图片旋转
  3. android基础学习--->Android SharedPreferences存储对象和图片(An
  4. Android根据Button状态(normal,focused,pressed)显示不同背景图
  5. Android 高清加载巨图方案 拒绝压缩图片
  6. Android图片加载神器之Fresco,基于各种使用场景的讲解
  7. Android(1.5及以上版本) 开机图片/文字/动画分析
  8. Android中几种图像特效处理的小技巧,比如圆角,倒影,还有就是图片

随机推荐

  1. Android(安卓)Application类的详细介绍
  2. android中的HandlerThread类的学习
  3. Android系统做了哪些优化?
  4. Android的Handler总结
  5. android、IOS 基于webview 与 HTML 的集
  6. android R 文件生成不了
  7. 从零搭建 repo 服务器
  8. Android线程优先级设置方法
  9. android笔记
  10. Android(安卓)4.4.2 exfat 移植