Activity跳转显示方法及隐式方法
public class AActivity extends AppCompatActivity { private Button btnJump; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_aactivity); btnJump=findViewById(R.id.jump); btnJump.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { //显式跳转方法1 Intent intent=new Intent(AActivity.this,BActivity.class); startActivity(intent); //显式跳转方法二 //Intent intent=new Intent(); //intent.setClass(AActivity.this,BActivity.class); //startActivity(intent); //显示跳转方法三 //Intent intent=new Intent(); //intent.setClassName(AActivity.this, "com.example.first.jump.BActivity"); //startActivity(intent); //显式跳转方法四 //Intent intent=new Intent(); //intent.setComponent(new ComponentName(AActivity.this, "com.example.first.jump.BActivity")); //startActivity(intent); //隐式跳转 //Intent intent=new Intent(); //intent.setAction("com.example.test.BActivity"); //startActivity(intent); //隐式跳转需要在AndroidMainifest.xml文件中要跳转的activity下设置<intent-filter>标签,像这样 /*<intent-filter> <action android:name="com.example.test.BActivity" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter>/>*/ } }); } }