I am making a project in which i want to select multiple photos from gallery and want to save that in imageview array. I am able to import single image and save at imageview
This is manifest file code for app to get consider you are sending images to your app
Program code...
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d("MainActivity", "on Create ");
if (Intent.ACTION_SEND_MULTIPLE.equals(getIntent().getAction())&& getIntent().hasExtra(Intent.EXTRA_STREAM))
{
ArrayList list =
getIntent().getParcelableArrayListExtra(Intent.EXTRA_STREAM);
for (Parcelable parcel : list) {
Uri uri1 = (Uri) parcel;
Log.d("MainActivity", "on Create uri1 " + uri1);
String sourcepath=getPath(uri1);
Log.d("MainActivity", "on Create sourcepath " + sourcepath);
/// do things here with each image source path.
}
//Commented by Aishwary coz I want to open the app after selecting images otherwise uncomment to just select
//finish();
}else{
// This part is of single image by Aishwary
Uri imageUri =(Uri) getIntent().getExtras().get(Intent.EXTRA_STREAM);
Log.d("MainActivity", "on Create ImageUri " + imageUri);
}
}
public String getPath(Uri uri) {
String[] projection = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(uri, projection, null, null, null);
startManagingCursor(cursor);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
}
This will allow you to get source path and images url . Now you can make array for url and use this url as you want...