如果我的应用程序是通过ACTION_VIEW开始了,我怎么获取附加的数据? [英] If my app was started via ACTION_VIEW, how do I retrieve the attached data?

查看:175
本文介绍了如果我的应用程序是通过ACTION_VIEW开始了,我怎么获取附加的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了我的应用程序句柄ACTION_VIEW意图为特定的数据类型,它确实很好。我似乎无法工作,如何以实际检测是否我的应用程序已经以这种方式推出,虽然,以及如何获得在附加的数据。有人能指出我在正确的方向?下面是从我的清单的摘录,如果有帮助。

 <活动机器人:名字=MyApp的
          机器人:标签=@字符串/ APP_NAME
          机器人:screenOrientation =肖像>            ...            &所述;意图滤光器>
              <作用机器人:名字=android.intent.action.VIEW/>
              <作用机器人:名字=android.intent.action.EDIT/>
              <作用机器人:名字=android.intent.action.PICK/>
              <类机器人:名字=android.intent.category.DEFAULT/>
              <数据机器人:mime类型=音频/ WAV/>
            &所述; /意图滤光器>
< /活性GT;


解决方案

您可以从意向的数据检索数据URI:


URI URI = getIntent()!= NULL? 。getIntent()的getData():空;

I've made my app handle ACTION_VIEW intents for a certain data type, which it does fine. I can't seem to work out how to actually detect whether my app has been launched in this way though, and how to get at the attached data. Can someone point me in the right direction? Here's an excerpt from my manifest, if it helps.

<activity android:name=".MyApp"
          android:label="@string/app_name"
          android:screenOrientation="portrait" >

            ...

            <intent-filter>
              <action android:name="android.intent.action.VIEW"/>
              <action android:name="android.intent.action.EDIT" />
              <action android:name="android.intent.action.PICK" />
              <category android:name="android.intent.category.DEFAULT" />
              <data android:mimeType="audio/wav" />
            </intent-filter>


</activity>

解决方案

You can retrieve the data URI from the intent's data:

Uri uri = getIntent() != null ? getIntent().getData() : null;

这篇关于如果我的应用程序是通过ACTION_VIEW开始了,我怎么获取附加的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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