【问题标题】:How do get a reference to the file chosen in a action.SEND如何获取对 action.SEND 中选择的文件的引用
【发布时间】:2010-12-13 16:46:42
【问题描述】:

早上好,

我正在使用以下代码,以便在用户选择图像上的共享选项时显示我的应用:

 <intent-filter>
  <action android:name="android.intent.action.SEND" />
   <category android:name="android.intent.category.DEFAULT" />
   <data android:mimeType="image/*" />                 
 </intent-filter>

当用户选择我的应用时,我无法弄清楚如何获取图像或图像的 Uri。

感谢任何帮助。

【问题讨论】:

    标签: android intentfilter


    【解决方案1】:

    这是您需要的代码。从您的活动中调用它。

    Intent launchIntent = getIntent();
    Bundle extras = launchIntent.getExtras();
    if (extras.containsKey(Intent.EXTRA_STREAM)) {
          final Uri uri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM);
    }
    

    【讨论】:

    • 真棒,完美。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-24
    • 2013-12-13
    相关资源
    最近更新 更多