Skip to content

Instantly share code, notes, and snippets.

@haidong94
Created June 14, 2017 04:32
Show Gist options
  • Save haidong94/e2ead0311e746759803556adc4b4bb7d to your computer and use it in GitHub Desktop.
Save haidong94/e2ead0311e746759803556adc4b4bb7d to your computer and use it in GitHub Desktop.
code
final static int RQS_RECORDING = 1;
Uri savedUri;
Button buttonRecord;
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
buttonRecord = (Button) findViewById(R.id.record);
buttonRecord.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent(
MediaStore.Audio.Media.RECORD_SOUND_ACTION);
startActivityForResult(intent, RQS_RECORDING);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
if (requestCode == RQS_RECORDING) {
savedUri = data.getData();
Toast.makeText(MainActivity.this,
"Saved: " + savedUri.getPath(), Toast.LENGTH_LONG).show();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment