AppArg on Simulator

26 views
Skip to first unread message

P5music

unread,
Oct 20, 2020, 5:04:29 PM10/20/20
to CodenameOne Discussions
My CodenamOne app can respond to the user selecting a file with a certain extension (that is registered in the info.plist file on the iOS side).
I would like to test this functionality in the Simulator in a way as similar to how the iOS native build would work as possible.
I am using a Linux machine. I think at least I could pass the file url as a command line parameter.
How to achieve that?

Shai Almog

unread,
Oct 20, 2020, 9:28:18 PM10/20/20
to CodenameOne Discussions
See the "Send App Argument" entry in the simulator menu. This should act similarly to Android though.

P5music

unread,
Oct 21, 2020, 3:18:07 PM10/21/20
to CodenameOne Discussions
What do you mean? I am using the cross-platform instructions.
Maybe you mean adding the prefix file:/// ?
I am interested in iOS url format, how to simulate that?
The AppArg is correctly passed and retrieved in the onStart() method.
I passed a path to a file (on Linux) like /home/pc/folder/myFile.ext
but 
try(InputStream is = Storage.getInstance().createInputStream(url);) 
fails.

Shai Almog

unread,
Oct 21, 2020, 10:35:37 PM10/21/20
to CodenameOne Discussions
That's not a path for the simulator. Simulator URLs look like file://home/filepath but they point to ~/.cn1/...
iOS files have random file path names I'm not sure what you're asking for?

P5music

unread,
Oct 22, 2020, 5:29:21 AM10/22/20
to CodenameOne Discussions
The only way to test the onStart() method with AppArg for me was to put a file in the ~/.cn1/ folder and the pass just the file name with "Send AppArg".
So it simulates the method call itself. I can test the app at least. As I can understand the real iOS url opening can only be tested on a real device.
So can I say that
Storage.getInstance().createInputStream(url);
on the simulator is a special API?
I mean, it accepts internal "private" files, not urls from the system, for example when the user wants to open a file with the registered extension as per the info.plist entry, as it is in my case.

Shai Almog

unread,
Oct 23, 2020, 12:17:57 AM10/23/20
to CodenameOne Discussions
You need to use FileSystemStorage not Storage and then it will accept correctly formed URLs starting with file://home/... prefix.
Reply all
Reply to author
Forward
0 new messages