Reputation: 3004
Want to set the value RESULT
from the following part and should retrieve it in the onActivityResult
...
Following is the code.
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
System.out.println("Select Display Picture, but");
intent.putExtra("RESULT", "RESULT");
activity.startActivityForResult(
Intent.createChooser(intent, "Select Display Picture"),
Credentials.BROWSE_PIC);
activity.setResult(Credentials.BROWSE_PIC, intent);
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == Credentials.BROWSE_PIC
&& resultCode == Activity.RESULT_OK && null != data) {
//returning null always here..
System.out.println("OnActivityResult came in::: "
+ data.getStringExtra("RESULT"));
Uri selectedImage = data.getData();
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(selectedImage,
filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
cursor.close();
}
Upvotes: 1
Views: 547
Reputation: 6166
You are using implicit Intent, you can not put anything in this intent because every implicit intent is defined by others.
If you want to add something then you can use your own Global Bundle object for the same.
Here are important link for you:
You can see answer By Lavekush Agrawer for using Global Bundle Object. here access the variable in activity in another class
Upvotes: 2