Home > Mobile >  Android call recording system cannot keep to the specified file
Android call recording system cannot keep to the specified file

Time:10-31

code is as follows, you can call recording system, but cannot be saved to the specified folder, only on their own recording system folder, please help
 public void onClick (View v) {
//create a File to like, use the saved File after recording

Videoname=new Date (). GetTime () + "mp3";

The File outputVideo=new File (getActivity () getExternalFilesDir (" video "), videoname);
The Context Context=getContext ();
String path=context. GetExternalFilesDir (" video "). GetPath ();
If (Build) VERSION) SDK_INT & gt; 24)={
VideoUri=FileProvider. GetUriForFile (getActivity (), "com. Example. I_space. FileProvider", outputVideo);
} else {
VideoUri=Uri. FromFile (outputVideo);
}//machine process under phase sequence
Intent Intent=new Intent (MediaStore. Audio. Media. RECORD_SOUND_ACTION);
Intent. PutExtra (MediaStore. EXTRA_OUTPUT videoUri);
//intent. AddFlags (Inten. FLAG_GRANT_READ_URI_PERMISSION);
//intent. PutExtra (MediaStore EXTRA_VIDEO_QUALITY, 1);
StartActivityForResult (intent, TAKE_VIDEO);
}});

CodePudding user response:

A big help to solve the ah

CodePudding user response:

Use file copying, may

CodePudding user response:

Only after completion of the recording operation

 
@ Override
Protected void onActivityResult (int requestCode, int the resultCode, Intent Intent) {
Super. OnActivityResult (requestCode, the resultCode, intent);

If (the resultCode==RESULT_OK & amp; & RequestCode==TAKE_VIDEO & amp; & Intent. GetData ()!=null) {
String sourcePath=FileUtil. GetPath (this, intent. GetData ());//get absolute path
String videoname=new Date (). GetTime () + "mp3";
The File outputVideo=new File (getExternalFilesDir (" video "), videoname);
The File sourceF=new File (sourcePath);
Try {
Boolean success=sourceF. RenameTo (outputVideo);//rewriting to the new path
LogUtils. D + success (" success ");
} the catch (Exception e) {
Toast. MakeText (this, "Error:" + um participant etMessage (), Toast. LENGTH_LONG), show ();
}
}
}

CodePudding user response:

The
reference 3 floor jklwan response:

only after completion of the recording operation
 
@ Override
Protected void onActivityResult (int requestCode, int the resultCode, Intent Intent) {
Super. OnActivityResult (requestCode, the resultCode, intent);

If (the resultCode==RESULT_OK & amp; & RequestCode==TAKE_VIDEO & amp; & Intent. GetData ()!=null) {
String sourcePath=FileUtil. GetPath (this, intent. GetData ());//get absolute path
String videoname=new Date (). GetTime () + "mp3";
The File outputVideo=new File (getExternalFilesDir (" video "), videoname);
The File sourceF=new File (sourcePath);
Try {
Boolean success=sourceF. RenameTo (outputVideo);//rewriting to the new path
LogUtils. D + success (" success ");
} the catch (Exception e) {
Toast. MakeText (this, "Error:" + um participant etMessage (), Toast. LENGTH_LONG), show ();
}
}
}

FileUtile complains in the utility class is written in the code, then I through the URI path, after debugging is not successful, the following is the debug results, please bosses analysis analysis

CodePudding user response:

language reference 4 floor wind sound response:
Quote: refer to the third floor jklwan response:

Only after completion of the recording operation

 
@ Override
Protected void onActivityResult (int requestCode, int the resultCode, Intent Intent) {
Super. OnActivityResult (requestCode, the resultCode, intent);

If (the resultCode==RESULT_OK & amp; & RequestCode==TAKE_VIDEO & amp; & Intent. GetData ()!=null) {
String sourcePath=FileUtil. GetPath (this, intent. GetData ());//get absolute path
String videoname=new Date (). GetTime () + "mp3";
The File outputVideo=new File (getExternalFilesDir (" video "), videoname);
The File sourceF=new File (sourcePath);
Try {
Boolean success=sourceF. RenameTo (outputVideo);//rewriting to the new path
LogUtils. D + success (" success ");
} the catch (Exception e) {
Toast. MakeText (this, "Error:" + um participant etMessage (), Toast. LENGTH_LONG), show ();
}
}
}

FileUtile complains in the utility class is written in the code, then I through the URI path, after debugging is not successful, the following is the debug results, please bosses analysis analysis

You don't have import??????????????????????

CodePudding user response:

reference 5 floor YXTS122 reply:
no import??????????????????????????

This class is to write their own, your new class, from the absolute path to the uri can refer to this link
  • Related