图片上传、显示网络图片、相册选取、拍照选取、图片裁剪

左右滑动倒影:http://blog.csdn.net/ryantang03/article/details/8053643

显示网络图片:http://www.cnblogs.com/dyllove98/p/3191916.html

http子线程下显示图片:http://bbs.9ria.com/thread-232411-1-1.html

上传图片(含照像、从SD卡选取、裁剪等):

http://blog.csdn.net/liangjiu2009/article/details/18978891

http://blog.csdn.net/ryantang03/article/details/8656278



————————————————华丽丽的分割线————————————————————————————


主线程显示网络图片:

	public static Bitmap GetInternetBitMap(String _url) {
		StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().detectNetwork().penaltyLog().build());		
		Bitmap bitmap = null;
		try{
			HttpURLConnection conn = (HttpURLConnection)(new URL(_url).openConnection());
			conn.connect();
			if(conn.getResponseCode()==200){
				InputStream input = conn.getInputStream();
				bitmap = BitmapFactory.decodeStream(input);
				input.close();
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		return bitmap;	
    }

子线程显示网络图片:

	public static void GetHttpBitMap(final String url,final Handler handle,final boolean timeout) {
		new Thread(){
			@Override
			public void run() {
				  try {				  
					    DefaultHttpClient dhc = new DefaultHttpClient();
					    if(timeout){
					    	dhc.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 2000); //请求超时时间
					    	dhc.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, 2000); //等待数据时间
					    }
			            handle.obtainMessage(1,BitmapFactory.decodeStream(dhc.execute(new HttpGet(url)).getEntity().getContent())).sendToTarget();				  					
				  }catch (Exception e) { handle.obtainMessage(0,"服务器出错,请稍候重试!").sendToTarget();}
			}
		}.start();		
    }

需要权限:

<uses-permission android:name="android.permission.INTERNET" />

————————————————华丽丽的分割线————————————————————————————


让HTML5支持上传图片(android版本兼容性差):

http://www.android100.org/html/201306/28/3325.html

http://sinykk.iteye.com/blog/1493580

http://www.tuicool.com/articles/buu6ji


————————————————华丽丽的分割线————————————————————————————


本地上传图片正常,发布版点击图片上传没反映?

解决:“代码混淆”功能导致的问题,需在proguard-project.txt中加入:

-keepclassmembers class * extends android.webkit.WebChromeClient {public void openFileChooser(...);}

该解决方法出自: http://stackoverflow.com/questions/5907369/file-upload-in-webview

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值