zoukankan      html  css  js  c++  java
  • 通过intent启动Activity

    android应用程序内部通过Intent来实现Activity间的跳转。也知道通过Intent调用系统程序。但若想在应用程序A内开启应用程序B(前提是A、B均已安装),该如何去实现?
    记录下实现过程。

    在应用程序A内添加如下代码:

    1     Intent i = new Intent();  
    2     i.setClassName("com.example.b",  
    3             "com.example.b.BActivity");  
    4     startActivity(i);  

    或者:

    1     Intent i = new Intent();  
    2     ComponentName cn = new ComponentName("com.example.b",  
    3     "com.example.b.BActivity");  
    4     i.setComponent(cn);  
    5     startActivity(i);  

    注:
    com.example.b是应用程序B的包名
    com.example.b.BActivity是应用程序B你将要启动的Activtiy

    当然也可以通过Intent启动同一包内的Activity。

    1 Intent i = new Intent(XXX.this, OOO.class);
    2 startActivity(i);
  • 相关阅读:
    2021.3.3
    2021.3.2
    2021.3.1
    2021.2.28(每周总结)
    2021.2.27
    2021.2.26
    2021.2.25
    2021.2.23
    Redis系统学习之五大基本数据类型(List(列表))
    Redis系统学习之五大基本数据类型(String(字符串))
  • 原文地址:https://www.cnblogs.com/hei-da-mi/p/4885084.html
Copyright © 2011-2022 走看看