I am calling a image from url for my image view, but it does not appear.
my emulator browser run perfectly but any app that use internet does not run,
i have given user permission in manifest file.
anyone please help.
this is my code
package com.example.simpleimage;
import java.io.InputStream;
import java.net.URL;
import android.os.Bundle;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;
public class Simpleimage extends Activity {
private String Url;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Url = "http://developer.android.com/images/dialog_progress_bar.png";
ImageView iv = (ImageView)findViewById(R.id.iv);
Drawable drawable = LoadImageFromWebOperations(Url);
iv.setImageDrawable(drawable);
}
private Drawable LoadImageFromWebOperations(String url) {
try {
InputStream is = (InputStream) new URL(url).getContent();
Drawable d = Drawable.createFromStream(is, "src name");
return d;
} catch (Exception e) {
System.out.println("Exc=" + e);
return null;
}
}
}
See that you are not on proxy network,if you are then set the proxy in emulator,or use the mobile to test your app.
The simplest and the best way is to do the following: This has been done for Android Emulator 2.2
Click on Menu
Click on Settings
Click on Wireless & Networks
Go to Mobile Networks
Go to Access Point Names
Here you will Telkila Internet, click on it.
In the Edit access point section, input the “proxy” and “port”
Also provide the Username and Password,
rest of the fields leave them blank.