Android 显性意图与隐性意图

Android 显性意图与隐性意图

  1,认识显性意图与隐性意图

    顾名思义,显性意图就是能在源码中看得出Intent跳转的activity对象

   Intent intent1=new Intent(this,Main2Activity.class);
        intent1.putExtra("one","one");
        intent1.putExtra("two","two");
        startActivity(intent1);

 

    隐性意图即看不到跳转的对象 

    一般情况下,即在AndroidManifest.xml修改

    

        <intent-filter>
                <action android:name="com.example.Login"/>
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

    在activity 逻辑文件中写Intent

    

 Intent intent=new Intent(/*this,Main2Activity.class*/);

        intent.setAction("com.example.Login");
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        intent.putExtra("zh",countText);
        intent.putExtra("pass",passText);
        startActivity(intent);

 

posted @ 2019-10-11 20:54  骚人文客  阅读(595)  评论(0编辑  收藏  举报