代码如下,获取本地计算机上图片;
(Ip为192.168.1.3,模拟器中为10.0.2.2)
public class MainActivity extends Activity {
private ScrollView scrollview01;
private TextView content;
private ImageView img;
private getBitmap getbitmap;
private getBitmap bitmap1;
private Button btn;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
img=(ImageView)findViewById(R.id.img);
btn=(Button)findViewById(R.id.btnlogin);
btn.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v)
{
System.out.println("OK");
new Thread(new Runnable() {
public void run() {
System.out.println("OK!!");
bitmap1= new getBitmap();
String newurl = "http://192.168.1.3:56910/Web/upload/comm/2010-05-27/071b884b-f0b7-4937-ae6e-f37ec8273611.jpg";
final Bitmap bitmap = bitmap1.getBitmap(newurl);//从网络获取图片
img.post(new Runnable(){
public void run(){
img.setImageBitmap(bitmap);}});}}).start();}});}}
模拟器中能获取图片,真机中无数据log:请教到底是啥问题啊。通过u口测试
//另外: 局域网内有wifi时,通过U口测试与安装到真机测试有区别么?需要改什么?
清楚了,是服务器端没用iis发布
通过真机测试时,你模拟器改变了没。一个是本机测试一个是真机测试。在wp和win8开发是这样的。不知对楼主有用没
不清楚,模拟器要改变啥?