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 Widget程序源码
  2. Android程序设置成横屏方法
  3. android4.2上获取应用程序大小的变更点
  4. Android 7.1 触摸事件代码跟踪
  5. Android 博客园客户端 (一) 基本界面
  6. Android 用户反馈界面的实现
  7. android 开发中将十六进制 颜色代码 转换为int类型数值 方法 :
  8. android双击返回键退出程序
  9. TextView --- 内容设置成上下滑动 和 代码设置字体颜色

随机推荐

  1. Android(安卓)分辨率 及 px, dip相互转换
  2. 更新ADT20后出现This template depends o
  3. Android开机时桌面Widget的载入流程
  4. SwipeRefreshLayout和ListView的EmptyVie
  5. 可以显示九天天气情况的天气预报哦-LINUX
  6. Android使用KSOAP2调用WebService及正确
  7. android 弹出Dialog的时候播放声音!
  8. [转]五大布局对象---FrameLayout,LinearL
  9. [置顶] android 耳机按钮深层理解
  10. [android] Proguard代码混淆器如何排除指