我在我的代码中使用选项卡,在一个选项卡中我使用的是startActivityForResult()。现在startActivityForResult()
正在运作,但无论我做什么,都不会调用onActivityResult()
。有人可以帮我解决这个问题。我不知道实际上没有警告或错误是什么问题。以下是代码
TabActivity:
TabHost.TabSpec spec = tabHost.newTabSpec(LIST2_TAB_TAG);
spec.setIndicator("RingTones");
Intent content = new Intent(this, TestClass.class);
spec.setContent(content);
tabHost.addTab(spec);
识别TestClass:
public class TestClass extends Activity
{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_ALARM);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select Tone");
/* intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI,
("chosenRingtone" ==null) ? (Uri)null :Uri.parse("chosenRingtone"));*/
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri) null);
this.startActivityForResult(intent, 5);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
switch (requestCode) {
case 1:
{
Uri uri = intent.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
if (uri != null)
{
intent.putExtra("ToneUriI", uri.toString());
}
else
{
// this.chosenRingtone = null;
}
break;
}
default: {
break;
}
}
}
}
我尝试了以下解决方案,但它们没有任何帮助。
任何帮助将不胜感激....:)