Android 常用 Intent (拨号,浏览器,联系人,Wi-Fi, 浏览器查询等等)
- 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"));
- //http://www.myexception.cn/android/967395.html
- //webIntent.setClassName("com.android.browser","com.android.browser.BrowserActivity");
- 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);
- }
// 浏览器查询
public void wifiSettingsIntent(View v){
Intent intent = new Intent();
intent.setAction(Intent.ACTION_WEB_SEARCH);
intent.putExtra(SearchManager.QUERY,"searchString");
startActivity(intent );
}
- }
- <?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>
相关推荐
ConnectivityManager是Android系统提供的一个关键组件,它为应用程序提供了接口来管理和监控网络连接,包括Wi-Fi、蜂窝数据等。 1. **ConnectivityManager概述** ConnectivityManager的主要职责是监听各种网络连接...
3. **Wi-Fi管理**:应用可能需要读取和操作设备的Wi-Fi状态,包括连接、断开、扫描可用网络等,需要用到Android的Wi-FiManager API。 4. **数据解析与处理**:由于涉及到拨号源码的破解,应用可能需要解析并处理...
为了实现在电脑上控制Android设备拨号,可能需要利用蓝牙或Wi-Fi Direct技术建立设备之间的直接连接。蓝牙需要处理配对、连接、数据传输等问题,而Wi-Fi Direct则允许设备间快速建立无线连接,不需通过路由器。 6....
5.14.1 wi-fi简介 5.14.2 实现原理 5.14.3 具体实现 5.15 获取sim卡内信息 5.15.1 sim卡简介 5.15.2 实现原理 5.15.3 具体实现 5.16 触屏拨号 5.17 获取正在运行的程序 5.18 变换屏幕的方向 5.19 获取设备信息 5.20 ...
2. 判断网络状态:可以使用ConnectivityManager类来检查当前设备的网络连接状态,包括移动数据、Wi-Fi等。 3. 获取惯性滑动位置:通过GestureDetector和Scroller类,可以捕捉用户的滑动事件,并计算出惯性滑动的...
例如,启动Wi-Fi设置界面,可以创建一个Intent,其ACTION为`Settings.ACTION_WIFI_SETTINGS`,然后使用`startActivity()`启动。其他如蓝牙、飞行模式等,都有相应的ACTION可供调用。 使用手机通讯功能涉及权限管理...
- **dun**:支持拨号网络桥接,常用于车载Wi-Fi等场景。 - **hipri**:具有最高优先级,用于特定的路由设置,如访问移动DNS服务。 - **fota**:专门用于空中固件升级,确保设备能够及时获取最新的软件版本。 - **ims...
- **联系人管理**:介绍了如何读取设备上的联系人信息,并进行增删改查等操作。 ##### **8. 通知与提醒(Notifications and Alarms)** - **通知栏消息发送**:讲解如何向通知栏发送消息,包括设置图标、标题、...
此外,某些应用会提供自定义快捷方式的选项,比如设置特定联系人的快速拨号或直接打开某个特定的音乐播放列表。 2. **快捷方式种类**:除了应用快捷方式外,还有活动快捷方式。活动快捷方式可以指向应用内的特定...
注意,设备可能有多个网络接口,如Wi-Fi和移动数据,所以需要根据需求选择合适的接口。 - 代码示例: ```java Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces(); ...
这可能是为了快速联系紧急联系人,或者在特定应用触发时自动拨打电话。实现自动拨号通常需要结合Intent和Phone类,当满足条件时启动拨号Intent,调用`startActivity()`来执行拨号操作。 在压缩包中的"SendMessage...
【标题】"android_packages_apps_Dialer" 是Android操作系统中电话应用的核心组件,它负责处理用户的拨号、接听和联系人管理等电话功能。在Android系统中,Dialer应用程序通常被称为电话应用,是用户与通信服务交互...