在当前activity中启动自己另一个程序的activity

现在有个需求,需要在现有的app中调用另一个app,并且传入相应的参数

查了一下,还是蛮方便的

假设现有的app::com.sqlhelp.app2

需用启动的app为:com.sqlhelp.app1


具体步骤如下:


1.修改app2的AndroidManifest.xml的配置,在原来启动的activity中增加一个<intent-filter>,如下图标识的

    <application android:icon="@drawable/icon" android:label="@string/app_name">  
        <activity android:name=".appMain"  
                  android:label="@string/app_name">  
            <intent-filter>  
                <action android:name="android.intent.action.MAIN" />  
                <category android:name="android.intent.category.LAUNCHER" />  
            </intent-filter>  
            <intent-filter>  
                <action android:name="com.sqlhelp.app2.appMain" />  
                <category android:name="android.intent.category.DEFAULT" />  
            </intent-filter> 
        </activity>  
    </application>


2.修改app1的AndroidManifest.xml的配置,增加一个新的activity

        <activity android:name="com.sqlhelp.app2.appMain"
                  android:label="@string/app_name">
        </activity>


3.在app2中调用app1的启动intent,通过Bundle传递参数

Intent testIntent = new Intent("com.sqlhelp.app2.appMain");
Bundle m_bundle = new Bundle();
m_bundle.putBoolean("Show",true);
testIntent.putExtras(m_bundle);
startActivity(testIntent);

4.在app1中接受参数,做相应的操作

Bundle m_Bundle = this.getIntent().getExtras();
boolean m_Show = m_Bundle.getBoolean("Show");
....












  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值