Canvas Background Image saves ok from Companion but not from APK

When I save from the Companion, the image shows up in my Gallery but I cannot find the image anywhere when it is saved from the built app.

I have another app that uses this same "save" code that works fine from both Companion and APK. Phone storage permission is enabled for both apps.

Any suggestions or explanations would be appreciated.

Please see

1 Like

The image is saved in the ASD on all Android versions. But on Android 11+ the ASD is not visible, so you cannot find the image in the Gallery. Save it in one of the Shared folders (like /DCIM/CompArt/myCanvas.jpg). To do this, you must copy or move the image from the ASD there using the File component or one of the File extensions from @Taifun or @vknow360.

1 Like

Thank you. I tried what I think you were suggesting. The file is now written to the ASD and then moved to a shared directory (/DCIM/CompArt/) but I get a runtime error message "argument is neither Class nor Type", which I tried to diagnose unsuccessfully. Again, the canvas save works from Companion but the move does not execute. Any guidance?
image

Following your example I still get the error message "argument is neither class nor type".
In your MakeDirectory block, did you mean Shared or should it be Legacy? I tried it both ways without success. I am using Move file instead of Copy file. Do I need to change the filename since they are 2 different storage locations? Here are my blocks.
image

Post a screenshot of the error message.
Which Android version?

Do you use Campanion 2.63u?

Samsung Galaxy J7
Android 6.0.1
Companion 2.59

In your example, you used "shared" as the SharedDirectory file scope even though you said that "shared" doesn't work with Android. Is this ok?
Does my code block look ok?

Forgot the error message you asked for. There's not much to it ...
image

Update Companion!
FileScope.Shared does not work only with the copy / move block.

I get the same error with v2.59:

grafik

Almost there! Save and Move are working with the enclosed code (both Companion and APK). BUT although I can find the image file in my directory (My Files>My device>DCIM>CompArt), the image is not showing up in my Gallery. After restarting the phone, the image does appear in the Gallery. BTW, I have cleared the Gallery cache and memory. So it seems that either Gallery Refresh is not working or I am applying it incorrectly. Help please.
image

On some devices/Android versions, an absolute path is required for the GalleryRefresh method to work.

See also here:

Summary

Thanks for the very informative tutorial on the Android Storage System.

Regarding Taifun Gallery Refresh using the full path (/storage/emulated/0/DCIM/CompArt/) caused the Gallery to be refreshed immediately.

Now my question is how to use MoveFile to move the image file to the SD Card. I tried the following modification without success:
My SD Card path seems to be a valid path. Is FileScope Legacy still correct?


I get the message "Unfortunately MIT AI2 Companion has stopped."

  1. This is an absolute path, not a full path.
  1. You cannot write to a removable (micro) SD card on devices with Android ≥ 4.4 (KitKat, API 19). It's read-only.

It seems odd not to be able to move a file to the sd card. Using a file manager I can move an image from phone memory to the sd card. Is this strictly an ai2 restriction?

No, from Android.

How can I make an app like the Canva tool..?

Do not link to any (Play Store) app, but describe your goal, your problems in detail and show us what you have tried so far (your blocks).

See also post #2: