Package com. Cons. DCG. Collect;
Import java. Io. file;
Import java. Text. simpledateformat;
Import java. util. arraylist;
Import java. util. date;
Import java. util. hashmap;
Import java. util. List;
Import Android. App. activity;
Import Android. App. notification;
Import Android. App. icationicationmanager;
Import Android. App. pendingintent;
Import Android. App. progressdialog;
Import Android. content. intent;
Import Android. database. cursor;
Import android.net. Uri;
Import Android. OS. asynctask;
Import Android. OS. Bundle;
Import Android. OS. environment;
Import Android. provider. mediastore;
Import Android. View. keyevent;
Import Android. View. Menu;
Import Android. View. menuinflater;
Import Android. View. menuitem;
Import Android. View. view;
Import Android. View. View. onclicklistener;
Import Android. widget. adapterview;
Import Android. widget. arrayadapter;
Import Android. widget. Button;
Import Android. widget. edittext;
Import Android. widget. spinner;
Import Android. widget. Toast;
Public class problemreport extends activity implements onclicklistener {
Private Static final int result_capture_image = 1; // the photo's requestcode
Private Static final int request_code_take_video = 2; // The requestcode of the camera.
Private Static final int result_capture_recorder_sound = 3; // requestcode of the recording
private string strimgpath = ""; // absolute path of the photo file
private string strvideopath = ""; // absolute path of the video file
private string strrecorderpath = ""; // absolute path of the recording file
@ Override
Protected void oncreate (bundle savedinstancestate ){
Super. oncreate (savedinstancestate );
This. setcontentview (R. layout. problem_report );
Arrears
}
@ Override
Protected void onactivityresult (INT requestcode, int resultcode, intent data ){
Super. onactivityresult (requestcode, resultcode, data );
Switch (requestcode ){
Case result_capture_image: // take a photo
If (resultcode = result_ OK ){
Toast. maketext (this, strimgpath, Toast. length_short). Show ();
}
Break;
Case request_code_take_video: // video shooting
If (resultcode = result_ OK ){
Uri urivideo = data. getdata ();
Cursor cursor = This. getcontentresolver (). Query (urivideo, null );
If (cursor. movetonext ()){
/* _ DATA: absolute path of the file, _ display_name: file name */
Strvideopath = cursor. getstring (cursor. getcolumnindex ("_ DATA "));
Toast. maketext (this, strvideopath, Toast. length_short). Show ();
}
}
Break;
Case result_capture_recorder_sound: // recording
If (resultcode = result_ OK ){
Uri urirecorder = data. getdata ();
Cursor cursor = This. getcontentresolver (). Query (urirecorder, null );
If (cursor. movetonext ()){
/* _ DATA: absolute path of the file, _ display_name: file name */
Strrecorderpath = cursor. getstring (cursor. getcolumnindex ("_ DATA "));
Toast. maketext (this, strrecorderpath, Toast. length_short). Show ();
}
}
Software Development
Break;
}
}
/**
* Photography
*/
Private void cameramethod (){
Intent imagecaptureintent = new intent (mediastore. action_image_capture );
Strimgpath = environment. getexternalstoragedirectory (). tostring () + "/consdcgmpic/"; // folder for storing photos
String filename = new simpledateformat ("yyyymmddhhmmss"). Format (new date () + ". jpg"; // name the photo
File out = new file (strimgpath );
If (! Out. exists ()){
Out. mkdirs ();
}
Out = new file (strimgpath, filename );
Strimgpath = strimgpath + filename; // the absolute path of the photo
Uri uri = URI. fromfile (out );
Imagecaptureintent. putextra (mediastore. extra_output, Uri );
Imagecaptureintent. putextra (mediastore. extra_video_quality, 1 );
Startactivityforresult (imagecaptureintent, result_capture_image );
}
/**
* video shooting
*/
private void videomethod () {
intent = new intent (mediastore. action_video_capture);
intent. putextra (mediastore. extra_video_quality, 0);
startactivityforresult (intent, request_code_take_video);
}
/**
* recording function
*/
private void soundrecordermethod () {
intent = new intent (intent. action_get_content);
intent. settype ("audio/AMR");
startactivityforresult (intent, result_capture_recorder_sound);
}
/**
* message
* @ Param text
* @ Param duration
*/
private void showtoast (string text, int duration) {
toast. maketext (problemreport. this, text, duration ). show ();
}