MutiPhotoChoser 是一款支持多选的图片选择器,支持 Android2.0+。
1、添加权限:
<!--SD卡读写权限--> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="ANDROID.PERMISSION.WRITE_EXTERNAL_STORAGE" />
2、声明GalleryActivity:
<activity android:name="com.ns.mutiphotochoser.GalleryActivity"> <intent-filter> <!--***改成应用的包名--> <action android:name="***.action.CHOSE_PHOTOS" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter></activity>
/*改成应用的包名*/ Intent intent = new Intent("***.action.CHOSE_PHOTOS"); startActivityForResult(intent, REQUEST_PICK_PHOTO);
@Overridepublic void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode != Activity.RESULT_OK) { return; } switch (requestCode) { case REQUEST_PICK_PHOTO: ArrayList<String> images = data.getStringArrayListExtra(Constant.EXTRA_PHOTO_PATHS); mAdaper.swapDatas(images); break; }}