我想通过一些音频的名字在我的Android App.I以前的活动尝试了很多ways.I的不知道在哪里我正在犯错误了。我想将记录音频名称发送到上一课。为什么不传球意图之前的活动中的Android
这是我的代码record_Audio。
btnSaveRecord = (Button)findViewById(R.id.buttonSaveRecord);
btnSaveRecord.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
/* Intent intent = new Intent(Record_Audio.this , AddPost.class);
intent.putExtra("STRING_I_NEED", newAudioFile);
setResult(REQUEST_CODE, intent);
finish();*/
Intent intent = new Intent(Record_Audio.this, AddPost.class);
// Add any data that you wish to send
intent.putExtra("DATA", newAudioFile);
startActivityForResult(intent, REQUEST_CODE);
//Intent intent = new Intent(Record_Audio.this , AddPost.class);
//startActivity(intent);
//finish();
}
});
在以前的代码,我想收到AudioName = AddPost活动
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
try
{
if (requestCode == REQUEST_CODE)
{
if (resultCode == RESULT_OK)
{
String newString = data.getExtras().getString("STRING_I_NEED");
Log.e("newString "," = "+newString);
String valueToChange = data.getExtras().getString("DATA");
Log.e("valueToChange "," = " + valueToChange);
}
}
if (requestCode == CAMERA_REQUEST)
{ //Capture Camera Image }
if (requestCode == RESULT_LOAD_IMG)
{ // //Capture Gallery Image}
没有人知道什么是你当前活动的,哪些是你以前提到activity.Please活动名称 –
@androidTag:我觉得你的代码是不完整的.. !! – AndiGeeky
你想将数据从Record_Audio传递给AddPost?或从AddPost到Record_Audio? –