Intent官方教程(4)用Intent构造应用选择框
Forcing an app chooser
When there is more than one app that responds to your implicit intent, the user can select which app to use and make that app the default choice for the action. This is nice when performing an action for which the user probably wants to use the same app from now on, such as when opening a web page (users often prefer just one web browser) .
However, if multiple apps can respond to the intent and the user might want to use a different app each time, you should explicitly show a chooser dialog. The chooser dialog asks the user to select which app to use for the action every time (the user cannot select a default app for the action). For example, when your app performs "share" with the ACTION_SEND action, users may want to share using a different app depending on their current situation, so you should always use the chooser dialog, as shown in figure 2.
Figure 2. A chooser dialog.
To show the chooser, create an Intent using createChooser() and pass it to startActivity(). For example:
Intent sendIntent = new Intent(Intent.ACTION_SEND);
... // Always use string resources for UI text.
// This says something like "Share this photo with"
String title = getResources().getString(R.string.chooser_title);
// Create intent to show the chooser dialog
Intent chooser = Intent.createChooser(sendIntent, title); // Verify the original intent will resolve to at least one activity
if (sendIntent.resolveActivity(getPackageManager()) != null) {
startActivity(chooser);
}
This displays a dialog with a list of apps that respond to the intent passed to the createChooser() method and uses the supplied text as the dialog title.
Intent官方教程(4)用Intent构造应用选择框的更多相关文章
- Intent官方教程(6)常见Intent示例,启动日历,时钟,镜头等。
guide/components/intents-common.html 包含:Alarm Clock Calendar Camera Contacts/People App Email File S ...
- Intent官方教程(3)各属性介绍
Building an Intent An Intent object carries information that the Android system uses to determine wh ...
- Intent官方教程(2)Intent的两种类型
Intent Types There are two types of intents: Explicit intents specify the component to start by name ...
- Intent官方教程(5)在manifest中给组件添加<Intent-filter>
Receiving an Implicit Intent To advertise which implicit intents your app can receive, declare one o ...
- Intent官方教程(1)简介和作用
Intents An Intent is a messaging object you can use to request an action from another app component. ...
- ContentProvider官方教程(7)3种访问形式:批处理、异步访问、intent间接访问(临时URI权限)
Alternative Forms of Provider Access Three alternative forms of provider access are important in app ...
- DroidParts 中文系列教程(基于官方教程)
DroidParts中文系列教程(基于官方教程) (一)DroidParts框架概况 2014年4月18日星期五 11:36 他是一个精心构造的安卓框架,包括下面这些基本功能 DI依赖注入,可以注入V ...
- Android官方教程翻译(4)——启动另一个Activity
Starting Another Activity 启动另一个Activity PREVIOUSNEXT THIS LESSON TEACHES YOU TO 这节课教你 1. Respond t ...
- Ceisum官方教程2 -- 项目实例(workshop)
原文地址:https://cesiumjs.org/tutorials/Cesium-Workshop/ 概述 我们很高兴欢迎你加入Cesium社区!为了让你能基于Cesium开发自己的3d 地图项目 ...
随机推荐
- java一般要点
1.String是引用类型. 2.char, short, byte在进行运算的时候会自动转换成int类型数据., 3.数据A 异或同一个数两次,得到的还是A 4.java的for循环,可以在前面加一 ...
- Demo12SimpleAdapter
/Users/alamps/AndroidStudioProjects/Demo12SimpleAdapter/Demo12SimpleAdapter/src/main/res/layout/data ...
- Android bindservice使用
package com.example.myact10; import com.example.myact10.MyService.MyBinder; import android.support.v ...
- angular 解析html
方法1:写filter <div ng-bind-html="showContent | html" class="detail-content"> ...
- oracle的冷备份
oracle冷备份要备份三类文件:数据文件,控制文件,日志文件 查看所有数据文件 select name from v$datafile; 查看所有日志文件 select member from v$ ...
- 夺命雷公狗---DEDECMS----21dedecms按照地区取出电影内容
我们现在要做的就是: 这些电影都是要按照地区来取出才可以的,但是我们arclist标签里面有没有按照条件来查找的地方,我们只好换套路了,要不然条条大路都不通,,,, 我们先来构造一条语句: 他这个标签 ...
- 「ruby」使用rmagick处理图像
安装rmagick gem A new release 2.13.2 of RMagick is now available on github as well as rubygems. This r ...
- sql插入删除表内字段基础操作
1 取得表格资讯 1.1 DESCRIBE指令 「DESCRIBE」是MySQL资料库提供的指令,它只能在MySQL资料库中使用,这个指令可以取得某个表格的结构资讯,它的语法是这样的: 你在MySQL ...
- 160909、Filter多方式拦截、禁用IE图片缓存、Filter设置字符编码
dispatcher多方式拦截 我们来看一个例子 我们定义一个index.jsp,里面有一个链接跳转到dispatcher.jsp页面 <body> <a href="di ...
- Backup: Numbers in Perl6
Perl6 is a new language, not a improved version of Perl5. Perl6 inherits many good features from man ...