문제

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>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top