why i can download image file on device and displaythe image?

15 views
Skip to first unread message

Housseini Moussa

unread,
May 28, 2018, 12:53:21 PM5/28/18
to CodenameOne Discussions
Hi
I am working on a projet where i have to download image. I do not understand why on the device simulator i succed in download image but when i install the app in my
android mobile phone i can not download image. Here is the code i use to download the image.

public void Download(String token,String format,String matricule,String annee,String mois) throws IOException{
        
       
       
        String url= "http://195.24.198.42/handlers/mycenadiapi.ashx?matricle="+matricule+"&type=getslipImage&dtype="+format+"&sy="+annee+"&sm="+mois+"&r=0&token="+token;
               

        String home = FileSystemStorage.getInstance().getAppHomePath();
        char sep = FileSystemStorage.getInstance().getFileSystemSeparator();
        FileSystemStorage.getInstance().mkdir(home + sep + "photos"+sep+"images");
        Util.downloadUrlToFile(url,home+sep+"photos"+sep+"images"+sep+"photos.jpeg", true);
        String filename = home+sep+"photos"+sep+"images"+sep+"photos.jpeg";
        InputStream stream = FileSystemStorage.getInstance().openInputStream(filename);
        OutputStream out = FileSystemStorage.getInstance().openOutputStream(home+sep+"mphoto.jpeg");

        Util.copy(stream, out);
        Util.cleanup(stream);
        Util.cleanup(out);
        Display.getInstance().execute(home+sep+"mphoto.jpeg");
       
    }

please i need your help


Shai Almog

unread,
May 30, 2018, 12:27:39 AM5/30/18
to CodenameOne Discussions
That looks like a local subnet IP which might be unreachable outside of your network. You would need to connect to the same network to download the image or put it in a public location.
Reply all
Reply to author
Forward
0 new messages