首页>代码>android service学习实例>/StadyService/src/lovefang/stadyService/UseActionCall.java
package lovefang.stadyService;
/**引入包*/
	import android.os.Bundle;
	import android.app.Activity;
	import android.net.Uri;
	import android.view.View;
	import android.content.Intent;
	import android.widget.Button;
	import android.widget.EditText;
/**如何拨打电话*/
	public class UseActionCall extends Activity{
			/**创建参数*/
		private Button call_Button;
		private EditText etext_callnumber;
			/**创建Activity*/
		public void onCreate(Bundle savedInstanceState){
			super.onCreate(savedInstanceState);
			setContentView(R.layout.use_action_call);
			getWidget();
			call_Button.setOnClickListener(call_Phone);
		}
		public void getWidget(){
			call_Button = (Button) findViewById(R.id.button_call);
			etext_callnumber = (EditText) findViewById(R.id.etext_action_call);
		}
			/**读取手机状态需要权限android.premission,CALL_PHONE*/
		private Button.OnClickListener call_Phone= new Button.OnClickListener(){
			public void onClick(View view){
				String phoneNum = etext_callnumber.getText().toString();
				Uri uri = Uri.parse("tel:"+phoneNum);// 将电话号码解析为Uri
				Intent intent = new Intent();
				intent.setAction(Intent.ACTION_CALL);// 将intent的Action设为call
				intent.setData(uri);// 将Uri对象传入intent对象
				startActivity(intent);// 开始通话
			}
		};
		
	}
最近下载更多
县飞飞飞飞飞  LV1 3月26日
diyutaizi3721  LV2 2023年10月25日
xiaoniao1号  LV1 2022年5月7日
511076827  LV33 2022年4月10日
*财来  LV4 2021年12月27日
哈哈哈哈123  LV9 2021年9月10日
lizhoutao  LV11 2020年12月11日
nuozai  LV7 2019年6月18日
xiaquan084  LV1 2019年4月11日
gggggggg123456  LV3 2018年12月19日
最近浏览更多
亦是此间少年  LV3 4月19日
diyutaizi3721  LV2 2023年10月25日
微信网友_6446990493290496  LV2 2023年4月29日
qazfxh  LV1 2023年4月4日
uni-code_0123  LV1 2022年11月16日
stdtta  LV8 2022年6月2日
ajie2123  LV4 2022年5月31日
萌了个乖乖  LV12 2022年5月20日
cxywt12  LV2 2022年5月20日
bingpine  LV6 2022年5月9日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友