android打电话程序
16lz
2021-01-23
android打电话程序
package com.tovcd.activity;
2![]()
3
import android.app.Activity;
4
import android.content.Intent;
5
import android.net.Uri;
6
import android.os.Bundle;
7
import android.view.View;
8
import android.widget.Button;
9
import android.widget.EditText;
10![]()
11![]()
public class Memory01Activity extends Activity
{
12
privateEditTexteditText;
13
privateButtonbuttonCall;
14
privateStringstrEditText;
15![]()
16
@Override
17![]()
publicvoidonCreate(BundlesavedInstanceState)
{
18
super.onCreate(savedInstanceState);
19
setContentView(R.layout.main);
20
editText=(EditText)findViewById(R.id.edit_text_number);
21
buttonCall=(Button)findViewById(R.id.button_call);
22![]()
23
//while(editText.isFocused()){
24
//editText.setText("");
25
//
26
//}
27![]()
28![]()
buttonCall.setOnClickListener(newView.OnClickListener()
{
29![]()
30
@Override
31![]()
publicvoidonClick(Viewv)
{
32
strEditText=editText.getText().toString();
33
Intentintent=newIntent(Intent.ACTION_CALL,Uri.parse("tel:"+strEditText));
34
Memory01Activity.this.startActivity(intent);
35![]()
36
}
37
});
38![]()
39![]()
40
}
41
}
<? xmlversion = " 1.0 " encoding = " utf-8 " ?>
2
< manifestxmlns:android = " http://schemas.android.com/apk/res/android "
3
package = " com.tovcd.activity "
4
android:versionCode = " 1 "
5
android:versionName = " 1.0 " >
6
< applicationandroid:icon = " @drawable/icon " android:label = " @string/app_name " >
7
< activityandroid:name = " .Memory01Activity "
8
android:label = " @string/app_name " >
9
< intent - filter >
10
< actionandroid:name = " android.intent.action.MAIN " />
11
< categoryandroid:name = " android.intent.category.LAUNCHER " />
12
</ intent - filter >
13
</ activity >
14![]()
15
</ application >
16
< uses - sdkandroid:minSdkVersion = " 4 " />
17![]()
18
// 加入打电话权限
19
< uses - permissionandroid:name = " android.permission.CALL_PHONE " />
20
</ manifest >
main.xml
1
<? xmlversion = " 1.0 " encoding = " utf-8 " ?>
2
< LinearLayoutxmlns:android = " http://schemas.android.com/apk/res/android "
3
android:orientation = " vertical "
4
android:layout_width = " fill_parent "
5
android:layout_height = " fill_parent "
6
>
7
< TextView
8
android:layout_width = " fill_parent "
9
android:layout_height = " wrap_content "
10
android:text = " @string/hello "
11
/>
12
< EditText
13
android:id = " @+id/edit_text_number "
14
android:layout_width = " fill_parent "
15
android:layout_height = " wrap_content "
16
android:text = " @string/edit_text_number "
17
android:textColor = " #c5c5c5 "
18
/>
19
< Button
20
android:id = " @+id/button_call "
21
android:layout_width = " wrap_content "
22
android:layout_height = " wrap_content "
23
android:text = " @string/button_call "
24
/>
25
</ LinearLayout >
26
Memory01Activity.java
12
3
4
5
6
7
8
9
10
11
![](https://img.16lz.com/image/product/d3c975ab092b4b77b3c90271c80dcc88.gif)
12
13
14
15
16
17
![](https://img.16lz.com/image/product/d3c975ab092b4b77b3c90271c80dcc88.gif)
18
19
20
21
22
23
24
25
26
27
28
![](https://img.16lz.com/image/product/d3c975ab092b4b77b3c90271c80dcc88.gif)
29
30
31
![](https://img.16lz.com/image/product/d3c975ab092b4b77b3c90271c80dcc88.gif)
32
33
34
35
36
37
38
39
40
41
AndroidManifest.xml
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
main.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
更多相关文章
- Android adb.exe程序启动不起来
- Android 消息通知栏Notification使用和权限
- Android拷贝压缩文件到程序目录
- 在应用程序使用android google搜索功能
- Android 程序开机自启动
- android 再按一次后退键退出应用程序
- Android Wear 进阶 2 Creating Wearable Apps-创建手表程序
- Android动态权限判断以及动态权限申请
- android 在自己的程序中添加Widget