Passing action to Android Intent using constructor and setter method -
i have written run simple android camera application run on android 4.
the code had camera intent defined
intent cameraintent = new intent(); cameraintent.settype(android.provider.mediastore.action_image_capture);
when tried run application throwing below exception :-
07-07 12:44:09.755: e/androidruntime(11533): android.content.activitynotfoundexception: no activity found handle intent { typ=android.media.action.image_capture }
however when tried run same program defining "cameraintent" below worked fine -
intent cameraintent = new intent(android.provider.mediastore.action_image_capture);
i thought passing "action" intent through setter or through constructor same.
but doesn't seems so, passing "action" through setter method throws exception while passing through constructor new intent works fine. idea why so?
this code work fine:
intent cameraintent = new intent(); cameraintent.setaction(android.provider.mediastore.action_image_capture);
instead of
intent cameraintent = new intent(); cameraintent.settype(android.provider.mediastore.action_image_capture);
becuase
settype(string type) used for:
set explicit mime data type.
and
setaction(string action) used for:
set general action performed.
Comments
Post a Comment