package com.mrzhu.intenttest;import android.app.Activity;import android.content.Intent;import android.net.Uri;import android.os.Bundle;import android.view.View;public class IntentTestActivity extends Activity {    /** Called when the activity is first created. */    @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.main);    }        //拨号代码,需要在AndroidManifest.xml文件中加入 拨打电话权限    //<uses-permission android:name="android.permission.CALL_PHONE"/>    public void callIntent(View v){    Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:12345678"));    startActivity(callIntent);    }        //将电话号码传入拨号程序的代码    public void dialIntent(View v){    Intent dialIntent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:12345678"));    startActivity(dialIntent);    }        //调用拨号程序的代码    public void touchDialerIntent(View v){    Intent touchDialerIntent = new Intent("com.android.phone.action.TOUCH_DIALER");    startActivity(touchDialerIntent);    }        //调用系统浏览器浏览网页的代码    public void webIntent(View v){    Intent webIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://nkiaguy.blogjava.net"));    startActivity(webIntent);    }        //调用系统程序查看联系人的代码    public void contaclistIntent(View v){    Intent contacListIntent = new Intent("com.android.contacts.action.LIST_CONTACTS");    startActivity(contacListIntent);    }        //显示系统设置界面的代码    public void settingsIntent(View v){    Intent settingsIntent = new Intent("android.settings.SETTINGS");    startActivity(settingsIntent);    }        //显示Wi-Fi设置界面的代码    public void wifiSettingsIntent(View v){    Intent wifiSettingsIntent = new Intent("android.settings.WIFI_SETTINGS");    startActivity(wifiSettingsIntent);    }}


<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:orientation="vertical" >    <Button        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:onClick="callIntent"        android:text="@string/btn_callIntent" />    <Button        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:onClick="dialIntent"        android:text="@string/btn_dialIntent" />    <Button        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:onClick="touchDialerIntent"        android:text="@string/btn_touchDialerIntent" />    <Button        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:onClick="webIntent"        android:text="@string/btn_webIntent" />    <Button        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:onClick="contaclistIntent"        android:text="@string/btn_contacListIntent" />    <Button        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:onClick="settingsIntent"        android:text="@string/btn_settingsIntent" />    <Button        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:onClick="wifiSettingsIntent"        android:text="@string/btn_wifiSettingsIntent" /></LinearLayout>


<?xml version="1.0" encoding="utf-8"?><resources>    <string name="hello">Hello World, IntentTestActivity!</string>    <string name="app_name">IntentTest</string>    <string name="btn_callIntent">callIntent</string>    <string name="btn_dialIntent">diaIntent</string>    <string name="btn_touchDialerIntent">touchDialerIntent</string>    <string name="btn_webIntent">webIntent</string>    <string name="btn_contacListIntent">contacListIntent</string>    <string name="btn_settingsIntent">settingsIntent</string>    <string name="btn_wifiSettingsIntent">wifiSettingsIntent</string></resources>


更多相关文章

  1. android ksoap2 访问https javax.net.ssl.SSLHandshakeException
  2. android中的按钮以图片的方式显示_基础篇
  3. [Android(安卓)特效] Android(安卓)通过流播放声音(三)
  4. Android隐藏输入法软键盘的注意事项
  5. Android程序设置成横屏方法
  6. Android(安卓)7.1 触摸事件代码跟踪
  7. Android(安卓)Studio 使用NDK编译时常见的问题
  8. ListView与Button的共存问题解决(点击事件)
  9. android 开发中将十六进制 颜色代码 转换为int类型数值 方法 :

随机推荐

  1. 使用Eclipse搭建Android的开发环境
  2. Android Studio 单刷《第一行代码》系列
  3. Android中绘制图表解决方案
  4. 基于百度地图实现Android定位功能实现(详
  5. Android SDK中的必会工具——android
  6. Android(安卓)问题积累
  7. 【Android您问我讲】如何使用选显卡 - Ta
  8. Android简明开发教程十八:自定义对话框 Tr
  9. Android磁盘管理-系统源码分析(1)
  10. Android 系统概要 ——《第一行代码 Andr