If you are experiencing an issue please mention the full platform your issue applies to: IDE:- Eclipse Desktop Windows 7 Simulator Nexus 5 Device
Hey guys. I want to open the gallery of the device and display the image selected bythe user back. I make a button and and an ActionListener should deflect me to the device's gallery. But the simulator shows a blank screen even if I omit the opening of the gallery part and just add the button. Also, It gives the following exception in the log:- > Jul 20, 2017 4:11:00 PM java.util.prefs.WindowsPreferences <init> > WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at > root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5. > java.io.UTFDataFormatException: malformed input around byte 64 > at java.io.DataInputStream.readUTF(Unknown Source) > at java.io.DataInputStream.readUTF(Unknown Source) > at com.codename1.ui.util.Resources.loadTheme(Resources.java:1270) > at com.codename1.ui.util.Resources.openFileImpl(Resources.java:303) > at com.codename1.ui.util.Resources.openFile(Resources.java:269) > at com.codename1.ui.util.Resources.<init>(Resources.java:189) > at com.codename1.ui.util.Resources.open(Resources.java:768) > at com.codename1.ui.util.Resources.open(Resources.java:688) > at com.codename1.impl.javase.JavaSEPort$4.run(JavaSEPort.java:1720) > at com.codename1.ui.Display.processSerialCalls(Display.java:1056) > at com.codename1.ui.Display.mainEDTLoop(Display.java:873) > at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120) > at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176) > > The following is my main java file made on an empty new bare bone project:- package com.mycompany.myapp; import com.codename1.ui.Display; import com.codename1.ui.Form; import com.codename1.ui.Image; import com.codename1.ui.Button; import com.codename1.ui.Dialog; import com.codename1.ui.Label; import com.codename1.ui.plaf.UIManager; import com.codename1.ui.util.Resources; import com.codename1.components.ImageViewer; import com.codename1.io.Log; import com.codename1.media.MediaManager; import com.codename1.ui.Toolbar; import com.codename1.ui.events.ActionEvent; import com.codename1.ui.events.ActionListener; import java.io.IOException; /** * This file was generated by <a href="https://www.codenameone.com/">Codename One</a> for the purpose * of building native mobile applications using Java. */ public class MyApplication { private Form current; private Resources theme; public void init(Object context) { theme = UIManager.initFirstTheme("/theme"); // Enable Toolbar on all Forms by default Toolbar.setGlobalToolbar(true); // Pro only feature, uncomment if you have a pro subscription // Log.bindCrashProtection(true); } public void start() { if(current != null){ current.show(); return; } Form hi = new Form("Hi World"); hi.addComponent(new Label("Hi World")); Button gallery = new Button("Browse"); hi.add(gallery); gallery.addActionListener(new ActionListener<ActionEvent>() { @Override public void actionPerformed(ActionEvent evt) { // TODO Auto-generated method stub Display.getInstance().openGallery((e) -> { if(e != null && e.getSource() != null) { // String file = (String)e.getSource(); // try { // Label path = new Label(file); // hi.add(path); // // } catch(Exception err) { // Log.e(err); // } } }, Display.GALLERY_IMAGE); } }); } public void stop() { current = Display.getInstance().getCurrent(); if(current instanceof Dialog) { ((Dialog)current).dispose(); current = Display.getInstance().getCurrent(); } } public void destroy() { } } -- 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 [email protected]. 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/c09dd89b-4d08-4f75-884f-7d40e1999c35%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
