Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chromebook : can't attach file to e-mail

I have a (big) problem on chromebook with a functionnality working fine on "classic" android devices (phones, tablets).

I try to send an e-mail with an attached file.

Here's a portion of code (api>=23).

        Intent email = new Intent(Intent.ACTION_SEND);
        String[] str = new String[1];
        str[0] = "[email protected]";
        email.putExtra(Intent.EXTRA_EMAIL, str);

        email.putExtra(Intent.EXTRA_TEXT, "My text");
        email.putExtra(Intent.EXTRA_SUBJECT, "My subject");

        Uri uri = FileProvider.getUriForFile(this, "com.TTT.fileprovider", new File(dest));

        email.putExtra(android.content.Intent.EXTRA_STREAM, uri);

        email.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION
                | Intent.FLAG_GRANT_WRITE_URI_PERMISSION
                | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);

        email.setType("message/rfc822");

        startActivity(email);

On my Phone (android 9 api 28), gmail app is called, all text fields are filled with correct information and the file (myResume.pdf) is correctly attached.

When sent then received, the e-mail contains a readable pdf file. that's cool.

With my chromebook (PB 314 / v. 83.0.4103.119), gmail is called, all text fields are filled with correct information but no attached file.

LogCat indicates :

2020-06-27 15:25:50.886 127-2348/? I/ActivityManager: START u0 {act=android.intent.action.SEND typ=message/rfc822 flg=0x43 cmp=org.chromium.arc.applauncher/.ChromeBrowserProxyActivity clip={message/rfc822 T:My text} (has extras)} from uid 10040
2020-06-27 15:25:50.887 565-565/? D/ArcDummy: New intent received: Intent { act=android.intent.action.SEND typ=message/rfc822 flg=0x10000043 cmp=org.chromium.arc.applauncher/.ChromeBrowserProxyActivity clip={message/rfc822 T:My text} (has extras) }
2020-06-27 15:25:50.887 565-565/? W/ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.startService:1531 android.content.ContextWrapper.startService:664 org.chromium.arc.applauncher.DummyActivity.forwardIntentIfNeeded:155 org.chromium.arc.applauncher.DummyActivity.onNewIntent:121 android.app.Activity.performNewIntent:7255 
2020-06-27 15:25:50.892 127-2348/? W/WindowManagerInjector: Attempted to get menu state of app token with non existing window
2020-06-27 15:25:50.896 780-842/? D/ArcMediaControllerManager: onTaskMovedToFront: 2
2020-06-27 15:25:50.897 780-842/? I/ArcMediaControllerManager: onAppBecameActive: org.chromium.arc.applauncher
2020-06-27 15:25:50.892 127-2348/? W/WindowManagerInjector: Attempted to get menu state of app token with non existing window
2020-06-27 15:25:50.900 127-760/? W/ActivityManager: For security reasons, the system cannot issue a Uri permission grant to content://com.TTT.fileprovider/images/myResume.pdf [user 0]; use startActivityAsCaller() instead
2020-06-27 15:25:50.901 127-760/? W/WindowManagerInjector: Attempted to get menu state of app token with non existing window   

when testing on android phones, this sentence never appears :

For security reasons, the system cannot issue a Uri permission grant to content://com.TTT.fileprovider/images/myResume.pdf [user 0]; use startActivityAsCaller() instead  

more information about previous code :

the file "myResume.pdf" is copied to a special directory for beeing shared with gmail.
    
dest is a string (/storage/emulated/0/MyDir/myResume.pdf) obtained with
    
Environment.getExternalStorageDirectory().toString() > /storage/emulated/0/
my sub directory, created and verified > MyDir/
the file > myResume.pdf
    

the file AndroidManifest.xml includes

<provider
        android:name="android.support.v4.content.FileProvider"
        android:authorities="com.TTT.fileprovider"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/provider_paths"/>
</provider>

the file @xml/provider_paths is :

<?xml version="1.0" encoding="utf-8"?>
    <paths xmlns:android="http://schemas.android.com/apk/res/android">
    <external-path name="images"  path="myDir/"/>
    </paths>

I hope I have explained my problem with all details,
Can anyone help me? Thank you very much!

like image 989
kodaski Avatar asked Jun 27 '20 14:06

kodaski


People also ask

Why is my email not allowing me to attach files?

The most common reason that an attachment won't send is that it is too big. These limits are set by whoever you use for email, whether it's an email account through your ISP or through an online provider like Yahoo or GMail. You should check with your email service provider to see what the limits are for attachments.

Why can I not attach files in Chrome?

Restart Chrome. After you open Chrome up again, type chrome://plugins in the browser's address bar and hit enter. Under Silverlight check-mark "Always allowed to run". Open a new email window and click on the attachment button to see if the browse window opens.

Why is my attach file not working?

If you are unable to attach files to Gmail message and you're seeing error messages while uploading attachments, make sure you have Flash installed. Visit Adobe Flash Player to check for updates and download the latest version. In addition, please make sure that Flash is not being blocked on your computer.


1 Answers

the problem is finally solved by using gmail app (after downloaded it) then using it instead of gmail/web/chrome.

like image 140
kodaski Avatar answered Sep 30 '22 06:09

kodaski