android - speichere das Bild vom Webserver und setze es als Hintergrund

Kann mir jemand eine Idee / Anleitung geben, wie ein Bild von einem Webserver gespeichert und als Hintergrundbild festgelegt werden kann? Ich entwickle eine Android-Anwendung, die das tun muss und ich bin neu in Android. Danke vielmals.

Ich habe versucht, meinen eigenen Code zu schreiben, aber es funktioniert nicht, da ich meine Bilder nach dem Download nicht finden kann, aber das Hintergrundbild hat sich zu dem heruntergeladenen Bild geändert. Hier ist mein bestehender Code.

Bitmap bmImg;

void downloadFile(String fileUrl) {
    URL myFileUrl = null;
    try {
        myFileUrl = new URL(fileUrl);
    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    try {
        HttpURLConnection conn = (HttpURLConnection) myFileUrl
                .openConnection();
        conn.setDoInput(true);
        conn.connect();
        int length = conn.getContentLength();

        InputStream is = conn.getInputStream();

        bmImg = BitmapFactory.decodeStream(is);
        // this.imView.setImageBitmap(bmImg);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    try {
        String filepath=Environment.getExternalStorageDirectory().getAbsolutePath(); 
        FileOutputStream fos = new FileOutputStream(filepath + "/" + "output.jpg"); 
        bmImg.compress(CompressFormat.JPEG, 75, fos);
        fos.flush();
        fos.close();

        Context context = this.getBaseContext();
        context.setWallpaper(bmImg);
    } catch (Exception e) {
        //Log.e("MyLog", e.toString());
        TextView tv = (TextView) findViewById(R.id.txt_name);
        tv.setText(e.toString());
    }

}

Antworten auf die Frage(1)

Ihre Antwort auf die Frage