连接到意图意图过滤器 [英] Connecting Intents to intent-filters

查看:159
本文介绍了连接到意图意图过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我测试Oracle的VirtualBox虚拟与VM =WSVGA 7.0平板 - 4.2.2 - API17

我无法用一个Intent连接到这个code的应用程序:


 意向意图=新意图(com.estrongs.action.PICK_FILE);
  意向意图=新意图(com.example.filechooser.PICK_DIRECTORY);
    // intent.setDataAndTypeAndNormalize(Uri.parse(文件://),* / *);
            //无活动处理意向{行动= com.estrongs.action.PICK_FILE DAT =文件://典型= * / *}
            //无活动处理意向{行动= com.estrongs.action.PICK_FILE}
    // intent.setType(* / *);
            //无活动来处理意图行事{= com.estrongs.action.PICK_FILE典型值=文件/ *}
            //无活动来处理意图行事{= com.estrongs.action.PICK_FILE典型值= * / *}
            //注意:在上述行动结束的额外空间。下方拆下
            //无活动来处理意图行事{= com.estrongs.action.PICK_FILE典型值= * / *}
            //无活动来处理意图行事{= com.example.filechooser.PICK_DIRECTORY典型值= * / *}
            //无活动处理意向{行动= com.example.filechooser.PICK_DIRECTORY}


  // startActivityForResult(意向,FolderChosen);
>

从我的Andr​​oidManifest.xml:


  

 <意向滤光器>
      <作用机器人:名字=android.intent.action.VIEW/>
      <作用机器人:名字=android.intent.action.SEND/>
      <作用机器人:名字=android.intent.action.GET_CONTENT/>
      <类机器人:名字=android.intent.category.OPENABLE/>
      <类机器人:名字=android.intent.category.DEFAULT/>
      <类机器人:名字=android.intent.category.BROWSABLE/>
      <数据机器人:mime类型=* / */>
  &所述; /意图滤光器>  &所述;意图滤光器>
       <作用机器人:名字=com.example.filechooser.PICK_DIRECTORY/>
  &所述; /意图滤光器>


  
  


>
我没有得到这个工作:

意向意图=新意图(Intent.ACTION_GET_CONTENT);
intent.setDataAndTypeAndNormalize(Uri.parse(文件://), / 的); //文件://保护正常工作

  //的onCreate意图= {意图行事= android.intent.action.GET_CONTENT DAT =文件://典型= * / *
// FLG = 0x3000000 CMP = com.example.filechooser / .FileChooser}<<<<<<<<<<<<<注意:工作

我应该怎样code意图过滤器,可以通过这样的一个意图来选择:


  

意向意图=新意图(com.estrongs.action.PICK_FILE);
     意向意图=新意图(com.example.filechooser.PICK_DIRECTORY);



解决方案

 <意向滤光器>
    <作用机器人:名字=com.estrongs.action.PICK_FILE/>
    <作用机器人:名字=com.example.filechooser.PICK_DIRECTORY/>
    <类机器人:名字=android.intent.category.DEFAULT/>
    <类机器人:名字=android.intent.category.OPENABLE/>
    <类机器人:名字=android.intent.category.BROWSABLE/>
&所述; /意图滤光器>

我以为你会接受所有的MIME类型,因为你的元素包含 / 的,所以我建议你忽略的元素。默认情况下,如果过滤器单元(IE)不是present,Android将匹配任何值。

I'm testing in Oracle's VirtualBox with VM="WSVGA 7.0 Tablet - 4.2.2 - API17"

I am unable to use an Intent to connect to an app with this code:

  Intent intent = new Intent("com.estrongs.action.PICK_FILE");
  Intent intent = new Intent("com.example.filechooser.PICK_DIRECTORY");
    //      intent.setDataAndTypeAndNormalize(Uri.parse("file://"), "*/*"); 
            //No Activity found to handle Intent { act=com.estrongs.action.PICK_FILE  dat=file:// typ=*/* }
            //No Activity found to handle Intent { act=com.estrongs.action.PICK_FILE  }
    //      intent.setType("*/*");
            //No Activity found to handle Intent { act=com.estrongs.action.PICK_FILE  typ=file/* }
            //No Activity found to handle Intent { act=com.estrongs.action.PICK_FILE  typ=*/* }  
            //  NOTE:  Extra space at end of action  above.  removed below
            //No Activity found to handle Intent { act=com.estrongs.action.PICK_FILE typ=*/* }
            //No Activity found to handle Intent { act=com.example.filechooser.PICK_DIRECTORY typ=*/* }
            //No Activity found to handle Intent { act=com.example.filechooser.PICK_DIRECTORY }

    //      startActivityForResult(intent, FolderChosen);
>

From my AndroidManifest.xml:

   <intent-filter>
      <action android:name="android.intent.action.VIEW" />
      <action android:name="android.intent.action.SEND" />
      <action android:name="android.intent.action.GET_CONTENT" />
      <category android:name="android.intent.category.OPENABLE" />
      <category android:name="android.intent.category.DEFAULT" />
      <category android:name="android.intent.category.BROWSABLE" />
      <data android:mimeType="*/*" />
  </intent-filter>

  <intent-filter>
       <action android:name="com.example.filechooser.PICK_DIRECTORY" />
  </intent-filter>

> I did get this to work:

Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setDataAndTypeAndNormalize(Uri.parse("file://"), "/"); // file:// WORKED

// onCreate intent=Intent { act=android.intent.action.GET_CONTENT dat=file:// typ=*/* 
//      flg=0x3000000 cmp=com.example.filechooser/.FileChooser }  <<<<<<<<<<<<<NOTE:  WORKED 

How should I code an intent-filter that can be chosen by an intent like these:

Intent intent = new Intent("com.estrongs.action.PICK_FILE"); Intent intent = new Intent("com.example.filechooser.PICK_DIRECTORY");

解决方案

<intent-filter>
    <action android:name="com.estrongs.action.PICK_FILE" />
    <action android:name="com.example.filechooser.PICK_DIRECTORY" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.OPENABLE" />
    <category android:name="android.intent.category.BROWSABLE" />
</intent-filter>

I assume that you'll accept all MIME types, since your element contains "/", so I suggest you omit the element. By default, if a filter element (ie ) isn't present, Android will match any value.

这篇关于连接到意图意图过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆