1. Camera Code:
1 PackageCom.example.paizhao;2 3 ImportJava.io.File;4 5 ImportAndroid.net.Uri;6 ImportAndroid.os.Bundle;7 ImportAndroid.provider.MediaStore;8 Importandroid.app.Activity;9 Importandroid.content.Intent;Ten ImportAndroid.view.Menu; One ImportAndroid.view.View; A - Public classMainactivityextendsActivity { - the @Override - protected voidonCreate (Bundle savedinstancestate) { - Super. OnCreate (savedinstancestate); - Setcontentview (r.layout.activity_main); + } - + A Public voidPai (view view) { atIntent Intent =NewIntent (); -Intent.setaction ("Android.media.action.IMAGE_CAPTURE"); -Intent.addcategory ("Android.intent.category.DEFAULT"); - //indicate where the photo was taken and specify the file name -File File =NewFile ("/sdcard/myimage.jpg"); -Uri uri =uri.fromfile (file); in Intent.putextra (Mediastore.extra_output, URI); - to startactivity (intent); + } - the}
2. VCR code:
1 PackageCom.example.paizhao;2 3 ImportJava.io.File;4 5 ImportAndroid.net.Uri;6 ImportAndroid.os.Bundle;7 ImportAndroid.provider.MediaStore;8 Importandroid.app.Activity;9 Importandroid.content.Intent;Ten ImportAndroid.view.Menu; One ImportAndroid.view.View; A - Public classMainactivityextendsActivity { - the @Override - protected voidonCreate (Bundle savedinstancestate) { - Super. OnCreate (savedinstancestate); - Setcontentview (r.layout.activity_main); + } - + A Public voidPai (view view) { atIntent Intent =NewIntent (); -Intent.setaction ("Android.media.action.VIDEO_CAPTURE"); -Intent.addcategory ("Android.intent.category.DEFAULT"); -File File =NewFile ("/sdcard/myvideo.3gp"); -Uri uri =uri.fromfile (file); - Intent.putextra (Mediastore.extra_output, URI); inStartactivityforresult (Intent, 0); - } to + - @Override the protected voidOnactivityresult (intRequestcode,intResultCode, Intent data) { * //TODO auto-generated Method Stub $ Super. Onactivityresult (Requestcode, ResultCode, data);Panax Notoginseng } - the + A}
Using the system's camera and VCR