繼續(xù)今天的Android,經(jīng)過昨天大體了解了Android開發(fā)的一些基本文件結構,今天來做一個電話撥號器!
創(chuàng)新互聯(lián)是一家專注于成都網(wǎng)站制作、成都做網(wǎng)站與策劃設計,孟津網(wǎng)站建設哪家好?創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設十多年,網(wǎng)設計領域的專業(yè)建站公司;建站業(yè)務涵蓋:孟津等地區(qū)。孟津做網(wǎng)站價格咨詢:18980820575
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:numeric="integer"
android:lines = "1"
android:hint="@string/hint"
android:id="@+id/et_number"
/>
android:numeric="integer"
android:lines = "1"
Button button = (Button)this.findViewById(R.id.bt_dail);
button.setOnClickListener((OnClickListener) new MyButtonClickListener());
privateclass MyButtonClickListenerimplements OnClickListener
{
@Override
publicvoid onClick(View v) {
// TODO Auto-generated method stub
System.out.println("按鈕被點擊了");
Log.i(tag, "button被點擊了");
Log.e(tag, "error");
Log.d(tag, "debug");
Log.v(tag,"verbios");
Log.w(tag, "warm");
}
}
privateclass MyButtonClickListenerimplements OnClickListener
{
@Override
publicvoid onClick(View v) {
// TODO Auto-generated method stub
//拿到電話號碼
EditText mEditText = (EditText)MainActivity.this.findViewById(R.id.et_number);
String number = mEditText.getText().toString();
Log.i(tag, number);
//撥打電話號碼
Intent intent = new Intent();//意圖 代表一個要執(zhí)行動作的意圖
//撥打動作 110
intent.setAction(Intent.ACTION_CALL);//Intent.ACTION_DAL是撥號的操作
//輸入的話就撥打輸入的,不屬于的話就撥打作者的號碼
if(!"".equals(number))
{
intent.setData(Uri.parse("tel:"+number));
}
else
{
Log.i(tag, "我的號碼");
intent.setData(Uri.parse("tel:"+"13262983383"));
}
//激活意圖
startActivity(intent);
}
04-0911:31:19.945: E/AndroidRuntime(516): <span style="color:#ff0000;">java.lang.SecurityException: Permission Denial</span>: starting Intent { act=android.intent.action.CALL dat=tel:110 cmp=com.android.phone/.OutgoingCallBroadcaster } from Proce***ecord{45ec9830516:com.example.phonecall/10038} (pid=516, uid=10038) requires android.permission.CALL_PHONE
04-0911:31:19.945: E/AndroidRuntime(516): at android.os.Parcel.readException(Parcel.java:1247)
04-0911:31:19.945: E/AndroidRuntime(516): at android.os.Parcel.readException(Parcel.java:1235)
04-0911:31:19.945: E/AndroidRuntime(516): at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1298)
04-0911:31:19.945: E/AndroidRuntime(516): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1373)
04-0911:31:19.945: E/AndroidRuntime(516): at android.app.Activity.startActivityForResult(Activity.java:2817)
04-0911:31:19.945: E/AndroidRuntime(516): at android.app.Activity.startActivity(Activity.java:2923)
04-0911:31:19.945: E/AndroidRuntime(516): at com.example.phonecall.MainActivity$MyButtonClickListener.onClick(MainActivity.java:45)
04-0911:31:19.945: E/AndroidRuntime(516): at android.view.View.performClick(View.java:2408)
04-0911:31:19.945: E/AndroidRuntime(516): at android.view.View$PerformClick.run(View.java:8816)
04-0911:31:19.945: E/AndroidRuntime(516): at android.os.Handler.handleCallback(Handler.java:587)
04-0911:31:19.945: E/AndroidRuntime(516): at android.os.Handler.dispatchMessage(Handler.java:92)
04-0911:31:19.945: E/AndroidRuntime(516): at android.os.Looper.loop(Looper.java:123)
04-0911:31:19.945: E/AndroidRuntime(516): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-0911:31:19.945: E/AndroidRuntime(516): at java.lang.reflect.Method.invokeNative(Native Method)
04-0911:31:19.945: E/AndroidRuntime(516): at java.lang.reflect.Method.invoke(Method.java:521)
04-0911:31:19.945: E/AndroidRuntime(516): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-0911:31:19.945: E/AndroidRuntime(516): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-0911:31:19.945: E/AndroidRuntime(516): at dalvik.system.NativeStart.main(Native Method)
java.lang.SecurityException: Permission Denial
網(wǎng)頁名稱:[Android]電話撥號器開發(fā)
轉(zhuǎn)載注明:http://vcdvsql.cn/article48/iippep.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供外貿(mào)網(wǎng)站建設、ChatGPT、網(wǎng)站建設、營銷型網(wǎng)站建設、App設計、網(wǎng)站設計
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)