【问题标题】:Action_Send how is the right way to do it?Action_Send 怎么做才是正确的呢?
【发布时间】:2014-02-19 04:12:36
【问题描述】:

您好,我想在我的应用程序中执行以下操作:当用户按下发送按钮时,它会保存相机预览图像,然后用户可以发送到其他一些设备。到目前为止,我的代码如下:

    share.setOnClickListener(new View.OnClickListener() 
    {

        @Override
        public void onClick(View v) 
        {
            Uri imageUri = Uri.parse("android.resource://your.package/drawable/flash_on");

            Intent share = new Intent(Intent.ACTION_SEND);
            share.setType("image/png");                                                                                                                                 
            //Uri screenshotUri = Uri.parse(pictureFile.getAbsolutePath());
            share.putExtra(Intent.EXTRA_STREAM, imageUri);
            startActivity(Intent.createChooser(share, "Share Image"));
        }
     });

仅使用图像 flash_on.png 进行测试,但无法正确发送。 我的清单文件有:

<action android:name="android.intent.action.SEND" />

还有:

<category android:name="android.intent.category.DEFAULT" />

【问题讨论】:

  • 您如何尝试将其发送到另一台设备?通过 NFC、蓝牙、WiFi 或特定应用程序?
  • 现在我正在通过蓝牙进行测试,但目标是通过电子邮件、facebook 等发送...

标签: android android-intent action share send


【解决方案1】:
            Intent i = new Intent(Intent.ACTION_SEND);
            i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
            i.setType("image/*");
            Uri uri = Uri.fromFile(pictureFile);
            i.putExtra(Intent.EXTRA_STREAM, uri);
            startActivity(Intent.createChooser(i, "Share image using")); 

【讨论】:

    猜你喜欢
    • 2012-05-26
    • 1970-01-01
    • 1970-01-01
    • 2014-09-26
    • 1970-01-01
    • 1970-01-01
    • 2023-03-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多