如何使用意图过滤器将gmail附件放入本地设备存储

时间:2018-11-29 22:40:50

标签: xamarin.forms xamarin.android

In my application i want to open gmail attachment with my application, i used intent filter for that, 
    I am getting URI and i want to use that and copy that attachment to my local device and want to display that with my application .

    url = {content://com.google.android.gm.sapi/abc@gmail.com/message_attachment_external/%23thread-f%3A1610966348228029097/%23msg-f%3A1610966348228029097/0.1?account_type=com.google&mimeType=application%2Foctet-stream&rendition=1}

经过几天的研究和实施,这是gmail附件文件的最终解决方案,用于查看和下载我们的应用程序。

[IntentFilter(new string[] { Intent.ActionView }, Categories = new string[] { Intent.CategoryDefault, Intent.CategoryBrowsable }, DataScheme = "content", DataMimeType = "application/octet-stream")]

Stream inputsTream = resolver.OpenInputStream(url);
                        fs = File.Create(fileName);

                        byte[] buffer = new byte[32768];
                        int count;
                        int offset = 0;
                        while ((count = inputsTream.Read(buffer, offset, buffer.Length)) > 0)
                        {
                            fs.Write(buffer, 0, count);
                        }
                        fs.Close();
                        inputsTream.Close();

0 个答案:

没有答案