/**
* @param v 设置按钮点击事件
*/
@Override
public void onClick(View v) {
super.onClick(v);
switch (v.getId()) {
case R.id.tv_content://跳转点击事件
//ComponentName 做跳转,第一个参数传递是B应用的包名,第二个参数传递的是你所需要跳转到B应用的界面
try {
ComponentName componentName = new ComponentName("com.example.intentActivity2", "com.example.intentActivity2.SecondActivity");
Intent intent = new Intent();
// Intent intent = new Intent("chroya.foo");
Bundle bundle = new Bundle();
bundle.putString("args", "我就是跳转过来的");
intent.putExtras(bundle);
intent.setComponent(componentName);
startActivity(intent);
} catch (ActivityNotFoundException e) {
//判断是否安装B应用,提供下载链接
NameToast.show(mContext, "请下载----" + "com.example.intentActivity2");
e.printStackTrace();
}
break;
}
}
public class MainActivity extends Activity {
private TextView tv_content;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
this.tv_content = (TextView) this.findViewById(R.id.tv_content);
Intent intent = getIntent();
String value = intent.getStringExtra("args");
ToastUtils.show(value);
}
}