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

            歡迎訪問 生活随笔!

            生活随笔

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

            编程问答

            01电话拨号器

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

            實(shí)例非常簡(jiǎn)單,意在體驗(yàn)Android的Intent,用戶權(quán)限。

            Intent 見?http://blog.csdn.net/zengmingen/article/details/49586045

            用戶權(quán)限 見?http://blog.csdn.net/zengmingen/article/details/49586569

            -----------------------------------------------------------------------------------------------

            MainActivity.java

            package com.example.callPhone;import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.View; import android.widget.EditText;public class MainActivity extends Activity {private EditText et;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);et=(EditText) findViewById(R.id.phoneNumber);}public void callPhone(View v){String phoneNumber=et.getText().toString();//撥打電話是系統(tǒng)應(yīng)用,谷歌沒有提供直接的打電話API,需要通過意圖調(diào)用//創(chuàng)建意圖對(duì)象Intent intent=new Intent();//我們需要告訴系統(tǒng),我們的動(dòng)作:我要打電話intent.setAction(Intent.ACTION_CALL);//把電話號(hào)碼告訴系統(tǒng)的打電話應(yīng)用。這是android系統(tǒng)設(shè)計(jì)思想,組件調(diào)用intent.setData(Uri.parse("tel:" + phoneNumber));startActivity(intent);//現(xiàn)實(shí)中,打電話要錢,所以需要增加打電話權(quán)限}}
            AndroidManifest.xml

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

            <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.example.callPhone"android:versionCode="1"android:versionName="1.0" ><uses-sdkandroid:minSdkVersion="8"android:targetSdkVersion="17" /><uses-permission android:name="android.permission.CALL_PHONE"/><applicationandroid:allowBackup="true"android:icon="@drawable/ic_launcher"android:label="@string/app_name"android:theme="@style/AppTheme" ><activityandroid:name="com.example.callPhone.MainActivity"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></manifest>
            activity_main.xml

            <LinearLayout 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"android:orientation="vertical"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/inputNumber" /><EditTextandroid:id="@+id/phoneNumber"android:layout_width="match_parent"android:layout_height="wrap_content"android:inputType="phone"/><Button android:layout_width="match_parent"android:layout_height="wrap_content"android:text="@string/callPhone"android:onClick="callPhone"/></LinearLayout>


            代碼下載:

            http://download.csdn.net/detail/zengmingen/9172881



            總結(jié)

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

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