`
meohao
  • 浏览: 94390 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

写在20110903:ACTION_GET_CONTENT

 
阅读更多
如彩信、Email、Gmail、网站等添加附件,如果应用本身没有做文件浏览选择的功能,此时应用可以通过发送ACTION_GET_CONTENT的系统接口来获取其他具备浏览选择文件功能的应用来支持该功能,比如此时添加附件会弹出一个选择框,有图库、音乐播放器等,现在如果想让FM也支持,在AndroidMenifest.xml中添加如下配置:
<intent-filter>
  <action andriod:name="android.intent.action.GET_CONTENT"/>
  <category android:name="android.intent.category.OPENABLE"/>
  <category android:name="android.intent.category.DEFAULT"/>
  <data android:mimetype="*/*"/>
</intent-filter>

在点击Item打开File的时候添加如下代码:
String action=mContext.getIntent().getAction();
if(!TextUtils.isEmpty(action)&&action.equals(Intent.ACTION_GET_CONTENT)){
   Uri uri=getDbUriFromFilepath(mContext,filepath);     
   //从数据库中查询该物理路径对应的Uri
   if(uri!=null){
      intent.setDataAndType(uri,type);
   }else{
      intent.setDataAndType(Uri.fromFile(new File(filepath)),type);
   }
   mContext.setResult(Activity.RESULT_OK,intent);
   mContext.finish();
   return;
}
分享到:
评论

相关推荐

    viewpager相关

    this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } } activity_main: &lt;LinearLayout xmlns:android=...

    SwipeListViewTest项目

    &lt;TextView android:id="@+id/example_row_tv_title" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_centerInParent="true" android:textSize="18sp" /&gt; 这个布局...

    Android中获取系统图片示例

    获取系统图片的简单示例,使用Intent.ACTION_GET_CONTENT 和 MediaStore两种方式获取图片以及其真正的系统所在的位置

    Android实现图片自动轮换

    从手机相册中选择一幅图片并显示在屏幕上 */ public class MainActivity extends AppCompatActivity { private Button btn_choose; private ImageView img_show; private final int REQUEST_PICTURE_CHOOSE = 1...

    Web应用安全:HTTP协议GET和POST的使用区别实验.docx

    &lt;meta http-equiv="Content-Type" content="text/html;charset=utf-8"/&gt; &lt;script type="text/javascript" src="jquery-1.8.0.min.js"&gt;&lt;/script&gt; &lt;form action="a2.php" name="form1" method="post"&gt; 姓名: 年龄:...

    MapView的使用

    在论坛里看到一篇 "MapView和其它控件一起显示 " 的帖子, 那是很老的一篇帖子了, 很多朋友都说无法在android SDK 1.0上运行。既然那么多人关心,我在这里就把它重写一遍,顺便加入了一些新的功能 ,感兴趣的朋友可以...

    file_get_contents&#40;php://input, r&#41;实例介绍

    form action=”action.php” method=”post” &gt; &lt;input type=”text” name=”userName” id=”userName” /&gt;  &lt;input type=”text” name=”user...php$raw_post_data = file_get_contents(‘php:

    android用于打开各种文件的intent

    android用于打开各种文件的intent

    react-native-document-picker:使用文档提供程序的React Native的文档选择器

    Android的Intent.ACTION_GET_CONTENT Windows Windows.Storage.Pickers 需要Android 5.0以上版本和iOS 10以上版本 安装 npm i --save react-native-document-picker OR yarn add react-native-document-picker ...

    Android4.4 WebAPI实现拍照上传功能

    主要原因是android从4.4版本开始通过intent.ACTION_GET_CONTENT打开选择器后,getData()返回的URI没有包含真实的文件路径,而是像这样“content://com.android.providers.media.documents/document/image:1234”,以...

    Android如何通过URI获取文件路径示例代码

    前言 最近在工作的过程中,遇到不同 Android 版本下 URI 采用不同方式...intent = new Intent(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType(image/*); startActivityFor

    android开发使用例子

    Intent getImage = new Intent(Intent.ACTION_GET_CONTENT); getImage.addCategory(Intent.CATEGORY_OPENABLE); getImage.setType(MIME_TYPE_IMAGE_JPEG); startActivityForResult(getImage, ACTIVITY_GET_IMAGE);...

    PocketSphinxAndroidDemo

    switch (event.getAction()) { case MotionEvent.ACTION_DOWN: start_date = new Date(); this.listening = true; this.rec.start(); break; case MotionEvent.ACTION_UP: Date end_date = new...

    DX1.5 手机正式版

    define(‘MAGIC_QUOTES_GPC’, function_exists(‘get_magic_quotes_gpc’) && get_magic_quotes_gpc());//获取是否开启了自动转义 define(‘ICONV_ENABLE’, function_exists(‘iconv’));//iconv函数是否存在 ...

    应用启动页自定义跳转计时器View Demo

    import android.content.Context; import android.content.res.ColorStateList; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Color; import android.graphics...

    将图片转换成声音

    Intent galleryIntent = new Intent(Intent.ACTION_GET_CONTENT); galleryIntent.addCategory(Intent.CATEGORY_OPENABLE); galleryIntent.setType("image/png"); startActivityForResult(galleryIntent, 1);...

    Android代码-基于 Bottom Sheet 实现的图片选择器,交互效果不错。

    What is TedBottomPicker? In Google's Material Design, Google introduce Bottom ...Get image from gallery(using Intent.ACTION_PICK intent) Get image from recent image(using MediaStore.Images.Media.EXTE

    cms后台管理

    return (List&lt;Content&gt;) super.getData(params, env); } } @Override protected boolean isPage() { return false; } } Content_list.html中的内容 [#list tag_list as a] &lt;li&gt;&lt;a href="${a.url}" ...

    javalruleetcode-interview-question-collection:面试问题收集

    java lru leetcode interview-question-collection 算法 leetcode n个整数的无序数组,找到每个元素后面比它大的第一个数,要求时间复杂度为O(N) ...简述Android的View绘制流程,Android的wrap_content是

    Web Performance in Action

    The content of the web is maturing and increasing in complexity, but internet infrastructure quality varies widely across the globe. People are browsing the web through a greater variety of devices ...

Global site tag (gtag.js) - Google Analytics