如何将上传的图像从服务器检索到android应用程序
我将图像作为如何将上传的图像从服务器检索到android应用程序,android,json,Android,Json,我将图像作为Base64编码方法上传到服务器,并将其作为字符串发送。我可以从服务器检索该字符串并对其进行解码吗 you have link for that..json parsing ,xml parsing u can get the address and then u can implement that image in ur apps. 公共类LoadImageFromURLActivity扩展活动{ @凌驾 创建时的公共void(Bundle savedInstanceSta
Base64
编码方法上传到服务器,并将其作为字符串发送。我可以从服务器检索该字符串并对其进行解码吗
you have link for that..json parsing ,xml parsing u can get the address and then u can implement that image in ur apps.
公共类LoadImageFromURLActivity扩展活动{
@凌驾
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//加载程序图像-将在加载图像之前显示
int loader=R.drawable.loader;
//要显示的图像视图
ImageView图像=(ImageView)findViewById(R.id.image);
//图像url
字符串图像\u url=”http://images4.fanpop.com/image/photos/18900000/Cute-couples-_-love-18948423-500-334.jpg";
//ImageLoader类实例
ImageLoader imgLoader=新的ImageLoader(getApplicationContext());
//每当您想从url加载图像时
//调用DisplayImage函数
//url-要加载的图像url
//加载器-加载器图像,将在获取图像之前显示
//图像-图像视图
DisplayImage(图像\ url、加载程序、图像);
}
}
是否可以检索相同的编码字符串并使用您上传的图像获取图像。现在您尝试在应用程序中使用它…使用Asynctask。。。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Loading image from url"
android:layout_margin="10dip" />
<ImageView android:id="@+id/image"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_margin="10dip"/>
</LinearLayout>
public class LoadImageFromURLActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Loader image - will be shown before loading image
int loader = R.drawable.loader;
// Imageview to show
ImageView image = (ImageView) findViewById(R.id.image);
// Image url
String image_url = "http://images4.fanpop.com/image/photos/18900000/Cute-couples-_-love-18948423-500-334.jpg";
// ImageLoader class instance
ImageLoader imgLoader = new ImageLoader(getApplicationContext());
// whenever you want to load an image from url
// call DisplayImage function
// url - image url to load
// loader - loader image, will be displayed before getting image
// image - ImageView
imgLoader.DisplayImage(image_url, loader, image);
}
}
<!-- Internet Permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Permission to write to external storage -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />