sam.almighty85
Lurker
Hello All,
I am new to this forum. I am trying to invoke the default audio recorder using intents. I start intent using the startActivityForResult after the recording is complete my activity result always results 0 (which is Activity.RESULT_CANCELED) and my intent is null. My code is as below:
I am testing on Android 2.2.1 (device Samsung Galaxy POP). Am i missing out on something? Kindly help me with this.
Thanking you,
Regards,
S.A.Norton Stanley
I am new to this forum. I am trying to invoke the default audio recorder using intents. I start intent using the startActivityForResult after the recording is complete my activity result always results 0 (which is Activity.RESULT_CANCELED) and my intent is null. My code is as below:
Code:
package com.abc.audiointent;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
public class AudioActivity extends Activity implements OnClickListener {
/** Called when the activity is first created. */
private Button sampleButton;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout finalContainer=new LinearLayout(this);
sampleButton=new Button(this);
sampleButton.setOnClickListener(this);
sampleButton.setText("Start Audio Intent");
finalContainer.addView(sampleButton);
setContentView(finalContainer);
}
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION);
startActivityForResult(intent, 1); // intent and requestCode of 1
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
// TODO Auto-generated method stub
if (requestCode == 1) {
// is the resultCode OK?
if (resultCode == RESULT_OK) {
// lets get the uri
Uri audioUri = intent.getData();
audioUri.toString();
// lets play the uri or do something with it.
// playAudio(audioUri);
}
}
}
}
I am testing on Android 2.2.1 (device Samsung Galaxy POP). Am i missing out on something? Kindly help me with this.
Thanking you,
Regards,
S.A.Norton Stanley