开发者

listen to camera events android

I am trying to implement camera events in android开发者_运维知识库. I am a newbie at this. How exactly does one go about listening to events like didCancel and didFinishPickingMedia? please advise. I am quite desperate as a quick search has not been able to lead me anywhere.


I really think you are looking for this:

MediaStore ACTION_IMAGE_CAPTURE

If you create an intent with this:

Uri uri = ... // where I want a full sized photo to be.
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri)
startActivityForResult(intent, MY_CALLBACK_ID);

Then somewhere in the same activity:

public void onActivityResult(int  requestId, int resultCode, Intent data) {
if (requestId == MY_CALLBACK_ID) {
   if (resultCode == Activity.RESULT_CANCELLED) {
       onCancelled();
   } else if (resultCode == Activity.RESULT_OK) {
      onFinishedPickingMedia();
   }
}

or if you really just want the Gallery to just show up, you might be able to get away with similar code, except that instead of using MediaStore.ACTION_IMAGE_CAPTURE, try this (I haven't verified it):

Intent intent = new Intent(Intent.ACTION_PICK);
intent.setData(MediaStore.Images.Media.INTERNAL_CONTENT_URI);
startActivityForResult(intent, MY_CALLBACK_ID);

I don't think the specific callbacks you are asking for exist in Android. Where have you heard them referenced?


Android provides the some of the callbacks to listen for the Camera events.Those callbacks are declared inside the Camera class.By using those callbacks you can handle the camera events. follow this link..

http://developer.android.com/reference/android/hardware/Camera.html

http://marakana.com/forums/android/examples/39.html


Try this,

<uses-permission android:name="android.permission.CAMERA" />

   <receiver
        android:name="com.android.application.CameraEventReciver"
        android:enabled="true" >
        <intent-filter>
            <action android:name="com.android.camera.NEW_PICTURE" />
            <data android:mimeType="image/*" />
        </intent-filter>
    </receiver>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜