Reputation: 2172
I want to set an imageview
and let the user to set his own image, i found how to do that on another question, but all the answers contains attribute for startActivityForResult
function like PICK_IMAGE
or SELECT_IMAGE
or ACTIVITY_IMAGE_SELECTOR
but my eclipse says that those are not defined , why ?
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(
Intent.createChooser(intent, "Select Picture"), PICK_IMAGE);
Upvotes: 2
Views: 1885
Reputation: 13415
Declare this variable on top :
int PICK_IMAGE = 101;
This is just a request code to match on your activity result.
References :
How To Pick Image From Gallery in Android App
Thanks.
Upvotes: 2
Reputation: 473
in your MainActvity.java:
public class MainActivity extends Activity
{
static MainActivity instance= null;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
instance = this;
}
}
and in your class make:
MainActivity.instance.startActivityForResult(intent,request_code);
Upvotes: 1