欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

android Activity跳转汇总

程序员文章站 2022-06-24 19:07:52
应用内跳转: 隐式跳转主要用于打开系统界面这里不做介绍1.最简单的://MainActivity :当前activityIntent intent = new Intent(MainActivity.this,SdpActivity.class);//"15710833644" 账号 string类型;intent.putExtra("phoneNo","15710833333");startActivity(intent);或者Intent intent = new Int....

应用内跳转:  隐式跳转主要用于打开系统界面这里不做介绍

1.最简单的:

//MainActivity :当前activity
Intent intent = new Intent(MainActivity.this,SdpActivity.class);
//"15710833644"  账号 string类型;
intent.putExtra("phoneNo","15710833333");
startActivity(intent);

或者

Intent intent = new Intent();  
intent.setClass(MainSdpActivity.this, SdpActivity.class);   
intent.putExtra("phoneNo","15710833333");
startActivity(intent);

SdpActivity中接收参数

phoneNo = getIntent().getStringExtra("phoneNo");

2.可用与应用间的intent 跳转

Intent intent1 = new Intent();
intent1.setComponent(new ComponentName("com.czj.componentnamedemo",
        "com.czj.componentnamedemo.SecondActivity"));
startActivity(intent1);

3.URL 跳转  

private void intentSdp(){
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("zznodesdp://intent?phoneNo=18117252660"));
    startActivity(intent);
}

manifest 文件对应的activity需要配置

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <!-- Accepts URIs that begin with YOUR_SCHEME://YOUR_HOST -->
    <data
        android:scheme="zznodesdp"
        android:host="intent"
        />
</intent-filter>

本文地址:https://blog.csdn.net/kailengchen/article/details/108733084

相关标签: android