日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

1-电话号拨号器

發(fā)布時(shí)間:2023/12/20 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 1-电话号拨号器 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1>頁面布局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity" ><EditTextandroid:id="@+id/et_number"android:layout_width="match_parent"android:layout_height="wrap_content"android:inputType="phone" /><Buttonandroid:id="@+id/bt_dail"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignLeft="@+id/et_number"android:layout_below="@+id/et_number"android:text="@string/dail" /></RelativeLayout>


2>MainActivity

package com.dail;import android.net.Uri; import android.os.Bundle; import android.app.Activity; import android.content.Intent; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText;public class MainActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);Button but = (Button)findViewById(R.id.bt_dail);but.setOnClickListener(new myListener());}private class myListener implements OnClickListener{@Overridepublic void onClick(View v) {EditText et = (EditText)findViewById(R.id.et_number);String number = et.getText().toString();Intent intent = new Intent();intent.setAction(Intent.ACTION_CALL);intent.setData(Uri.parse("tel:"+number));startActivity(intent);}} } View Code

3>清單文件AndroidManifest.xml 添加打電話權(quán)限

<uses-permission android:name="android.permission.CALL_PHONE"/>

如果不加權(quán)限會報(bào)錯(cuò)

權(quán)限安全異常: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.CALL dat=tel:110 cmp=com.android.phone/.OutgoingCallBroadcaster } from ProcessRecord{43e96760 663:com.dail/10038} (pid=663, uid=10038) requires android.permission.CALL_PHONE

?

?

?

轉(zhuǎn)載于:https://www.cnblogs.com/JiangXiaoTian/articles/3462940.html

總結(jié)

以上是生活随笔為你收集整理的1-电话号拨号器的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。