Is "AppArg" property of Display.getInstance() also useful when the app is already launched?

22 views
Skip to first unread message

P5music

unread,
Sep 22, 2020, 5:39:20 AM9/22/20
to CodenameOne Discussions
I read in the documentation that it is possible to let the user open the CodenameOne app by means of selecting an associated file type.
The instruction (let aside all settings necessary) is something like
String arg=Display.getInstance().getProperty("AppArg",null);
From the documentation I see that this is at startup, that is, the app gets launched with that if the user wants the file. Value is null when the app is started by tapping on its icon, if I am not wrong.

But what if the app is already running, in both case it's in foreground or in background?

Thanks in advance

Steve Hannah

unread,
Sep 22, 2020, 8:00:59 AM9/22/20
to codenameone...@googlegroups.com
Yes.  If the app is already started and it receives a call to open it with an argument, the app's start() method will be run again, and this time the AppArg will contain the new value.

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/bc969123-5366-4785-9eca-44ed804d8e19n%40googlegroups.com.


--
Steve Hannah
Software Developer
Codename One

P5music

unread,
Sep 22, 2020, 10:06:41 AM9/22/20
to CodenameOne Discussions
Thanks for the response.
I need two questions to be addressed:
1-Said that the start() method is called, this means that it is like the app starts again and what is going on (or was going on when it went to background) is lost? (except for that some methods are called before it happens to let the app save its state)
2-How the incoming url has to managed? I mean, permissions, access to filesystem and so on.
Thanks in advance
Regards

Shai Almog

unread,
Sep 22, 2020, 10:21:47 PM9/22/20
to CodenameOne Discussions
This is suspend/resume behavior. A different app gained control that means stop() was invoked. If your app is actually killed during that time destroy MIGHT be called too.

If the app is cold launched you will get init(Object) then start() with the app args.
If the app is warm started only the start() method is invoked with the app args set into place.

If the incoming URI is a file it should be accessible at least as read-only. You should be able to use standard file system APIs to read it.
Reply all
Reply to author
Forward
0 new messages