当前位置:   article > 正文

android intent跳转声音,android intent 跳转

android intent跳转原生录音

转自:http://blog.sina.com.cn/s/blog_7309444701014u2d.html

一、不需要返回值的跳转

Intent intent=new Intent();

intent.setClass(目前的acitivy.this, 目标activity.class);

startActivity(intent);

二、需要返回值的跳转

Intent intent=new Intent();

intent.setClass(发出请求的acitivy.this, 目标activity.class);

startActivityForResult(intent, 状态值(int类型));

状态值作为接收目标返回值的验证。目标activity 关闭才能返回发出请求的activity

例如:

1、请求页面

public class MainActivy extends Activity {

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

Intent intent=new Intent();

intent.setClass(MainActivy.this, ReceiveMSG.class);

startActivityForResult(intent, 0);

}

requestCode 接收返回的状态值

resultCode :RESULT_OK  RESULT_CANCELED 可以自己赋值,按返回键时,系统默认赋值为:RESULT_CANCELED

protected void onActivityResult(int requestCode, int resultCode, Intent data) {

// TODO Auto-generated method stub

super.onActivityResult(requestCode, resultCode, data);

if (requestCode==0) {

if (resultCode==RESULT_OK) {

Toast.makeText(this, "Send SMS RESULT_OK", Toast.LENGTH_SHORT).show();

}else if (resultCode==RESULT_CANCELED) {

Toast.makeText(this, "result cancel", Toast.LENGTH_SHORT).show();

}else {

Toast.makeText(this, resultCode, Toast.LENGTH_SHORT).show();

}

}else {

Toast.makeText(this, "requsetcode not 0", Toast.LENGTH_SHORT).show();

}

}

}

2、接收返回值界面

public class ReceiveMSG extends Activity{

protected void onCreate(Bundle savedInstanceState) {

// TODO Auto-generated method stub

super.onCreate(savedInstanceState);

ReceiveMSG.this.setResult(RESULT_OK);

this.finish();

}

}

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/175233
推荐阅读
相关标签
  

闽ICP备14008679号