Unable to select multiple images via Display.getInstance().openGalellery(ActionListener, Display.GALLERY_IMAGE_MULTI)

48 views
Skip to first unread message

carlo...@gmail.com

unread,
Sep 30, 2018, 1:11:36 PM9/30/18
to CodenameOne Discussions
CN 5.0
Netbeans 8.0.2
Windows 10

I am trying to select in a single action several files to upload to a remote server. Currently I can only select one picture at a time, which makes the process unacceptable for users when you need to upload more than a couple of pictures, which is the regular user case. I have found another thread where it states that this feature is already available in the simulator and Android builds, and I can certainly attain it with the simulator but not with Android. My test device is a Samsung s7 edge with Android 7.0 (don't know api level but should be recent enough). On another thread I have read this feature is still not available.

I find it hard to believe that it is not included, then CN1 wouldn't be developed enough to ask for paid suscriptions and enterprise accounts. I am essaying to port an application from Xamarin, where I have reached implementing this features, however Xamarin has other complications to deal with, and CN1 makes life much easier, specially for Java developers. which is my case.

I really need this feature in and won't be able to sell the project in my company if I can't reach to include that feature in my app. I believe it should be doable. After following various documents I seem to be doing things correctly, but I am not reaching it. Find attached the piece of code that triggers what I am trying to code. Would be thankful if anyone can point me in the right direction. 

In Xamarin you can access any device capacity via Dependency Injection. Is there any similar feature in CN1 available?

Many thanks for reading me.

Regards,

Carlos.


Code:

Button b3 = new Button("Cargar Fotos");
        b3.addActionListener(e->{
            Display.getInstance().openGallery(new ActionListener(){

                @Override
                public void actionPerformed(ActionEvent evt) {
                    int y = 2;
                }
                
            }, Display.GALLERY_IMAGE_MULTI);  //have tried also GALLERY_ALL_MULTI but no luck!
        });






Shai Almog

unread,
Sep 30, 2018, 11:19:53 PM9/30/18
to CodenameOne Discussions
It's implemented and should work when picking the multi option. We fire an Android intent internally and because Android sucks in that regard the gallery you choose can ignore the multi flag.

You can write native code using Codename One to access any device functionality you want https://www.codenameone.com/how-do-i---use-the-include-sources-feature-to-debug-the-native-code-on-iosandroid-etc.html

E.g. you can access the camera directly via native code https://github.com/codenameone/CameraKitCodenameOne

Neither one of these features is important for everyone or any indicator of missing functionality or maturity of the framework.

Carlos Conti

unread,
Oct 1, 2018, 5:44:59 AM10/1/18
to codenameone...@googlegroups.com
Hi Shai,

thanks for your quick answer. 
Is there any Demo that includes the functionality? Perhaps I am missing any setting? Should I use a different flag? Any trick for Android to take it into account? 
I plan to use in the future sockets to implement a chat app. I have seen there's a set of CN1Libs that seem to include it. Do you have any idea how reliable it is? Have other developers used it on a regular basis. Is there any example in production?

Sorry for all the questions, but I am eager to start developing at full speed with CN1.
Love its simplicity since it focuses on the essential code and saves plenty of boilerplate code and configurations. Thanks I believe it is a great piece of work.

Thanks in advance.

Carlos.

--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/-ihNMfjrXHQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/08b61d65-38fe-484c-a0c7-4fb7534e1439%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Shai Almog

unread,
Oct 2, 2018, 12:44:21 AM10/2/18
to CodenameOne Discussions
Hi,
I haven't used the multipicker myself so Steve might be able to better answer that. I think we should probably update the old camera demo to support multi picker options.

I assume you mean websockets?
Quite a few people contact us about websockets so I'm guessing they are in use. Since we can't see developers code or usage I can't give you exact numbers. We use them for our apps and will use them for our upcoming whatsapp clone tutorial. Since they are implemented as a cn1lib the code is very easy to grok and as you will see calls directly to the native implementation, that means the sockets are as mature as the native implementation.

There are a few chat apps already implemented in Codename One but I can't tell you if they use WebSockets or something else because we have no access to their code.

Carlos Conti

unread,
Oct 2, 2018, 7:46:07 AM10/2/18
to codenameone...@googlegroups.com
Thanks for your answer Shai.
Will keep exploring.

Regards,

Carlos Conti.

--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/-ihNMfjrXHQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.

Steve Hannah

unread,
Oct 2, 2018, 8:09:35 AM10/2/18
to codenameone...@googlegroups.com

Button b3 = new Button("Cargar Fotos");
        b3.addActionListener(e->{
            Display.getInstance().openGallery(new ActionListener(){

                @Override
                public void actionPerformed(ActionEvent evt) {
                    int y = 2;
                }
                
            }, Display.GALLERY_IMAGE_MULTI);  //have tried also GALLERY_ALL_MULTI but no luck!
        });


That snippet looks generally correct.  This is a test case that I use for the gallery multiselect features, if you want to take a look.

Steve 

Carlos Conti

unread,
Oct 2, 2018, 12:04:57 PM10/2/18
to codenameone...@googlegroups.com
Hi Steve thanks. Have you tested running it on an Android device? On the simulator I am being able to perform a multiselection, but not on the device.

Regards.

Carlos Conti.

--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/-ihNMfjrXHQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.

Steve Hannah

unread,
Oct 2, 2018, 12:06:09 PM10/2/18
to codenameone...@googlegroups.com
Yes.  I've tested it on several devices.  What device are you running it on / what version of Android?

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.

For more options, visit https://groups.google.com/d/optout.


--
Steve Hannah
Software Developer
Codename One

Carlos Conti

unread,
Oct 2, 2018, 12:12:31 PM10/2/18
to codenameone...@googlegroups.com
Hi Steve,

I have run it on an Android 7.0 (don't know the api level but should be recent enough its a Samsung S7 Edge)
Ok. I will firstly test your code snippets, perhaps we find a surprise, and it only has to do with the code structure/argument type, etc.... since this is an abstraction layer we cannot exclude that possibility. I am figuring out that the fact that there's an explicit declaration of the action listener instead of the lambda expression shouldn't affect. Should it? Let me run first your code and then will come back to you.

Many thanks.

Regards,

Carlos.

Carlos Conti

unread,
Oct 8, 2018, 7:51:41 AM10/8/18
to codenameone...@googlegroups.com
Hi Steve,

I have run your test, and in my device

Android 7.0
Samsung S7 Edge

it doesn't allow me to select multiple images. The behavior is the same I get with my application, I can effectively select multiple images in the simulator, but not on the device.

Don't know how to proceed. Can you give me any hints?

Many thanks for your time.

Regards,

Carlos.

Shai Almog

unread,
Oct 9, 2018, 12:32:01 AM10/9/18
to CodenameOne Discussions
Hi,
did you use capture as part of the flow?
Is it possible that this fix is relevant?

Carlos Conti

unread,
Oct 13, 2018, 5:59:38 AM10/13/18
to codenameone...@googlegroups.com
Hi Shai,

don't know exactly what you mean by "capture as part of the flow". I am currently only checking it on android devices not iOS, that will be the next step. I am not interested in capturing, just in selecting from the gallery, but currently I would have to open the gallery as many times as different photos I want to upload, quite uncomfortable for the user. There seems not to be an easy fix. 


This post states what I mean. Apparently should be fixed in the Simulator and Android. I have effectively verified it in the Simulator, but Android keeps failing. The device doesn't raise any exception, it only doesn't allow multiple selection.
Should I delve deeper and see if there's anything to attain in native code or similar? 

Regards,

Carlos.





--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/-ihNMfjrXHQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.

Shai Almog

unread,
Oct 14, 2018, 12:17:03 AM10/14/18
to CodenameOne Discussions
The issue that was fixed for #2383 was caused by using the capture API then opening the gallery. If it's still happening in current builds then it's a separate issue. Assuming it happens to you in a hello world scenario then this is probably a device specific issue.

Here's what you need to do:

- Try to get another device and see if it happens there too, if you can get multiple devices that would be interesting
- File a new issue with: test case, ideally device video and full details of the device (model, manufacturer, exact Android version number).

Carlos Conti

unread,
Oct 14, 2018, 2:34:23 PM10/14/18
to codenameone...@googlegroups.com
Hi Shai,

find attached the documents related for three different devices: Huawei, Asus and Samsung. For all of them you will see there's video demonstrating the problem, the user can only select one image, and not several at a time. You will find aswell a correspondent image file with the android and device specs. 

Huawei PLite
Asus X00DD
Samsung S7 Edge

If there's any additional info you might need let me know pls. Thanks for taking the time to analyze my case.

Since videos are 80Mb big, here by the shareable googledrive links


Regards,

Carlos Conti.

--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/-ihNMfjrXHQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.
ASUS 2.jpg
SAMSUNG 2.png
HUAWEI 2.jpg

Shai Almog

unread,
Oct 15, 2018, 12:20:24 AM10/15/18
to CodenameOne Discussions
Hi,
thanks for the details. The right place for this is the issue tracker here: http://github.com/codenameone/CodenameOne/issues/

That way we can track the issue specifically, assign it and monitor potential regressions/fix failed without it getting buried under the pile of discussions.

Thanks.
Reply all
Reply to author
Forward
0 new messages