android学习笔记12 - apk应用间的调用

本文介绍了在Android中两种不同的应用间调用方法。一种是通过指定包名和路径来直接启动特定的Activity;另一种是利用Intent过滤器,通过名称来调用目标Activity。文章详细解释了每种方法的具体实现步骤。

调用方式共两种

一 包名加路径的方式:

Intent intent = new Intent();
intent.setComponent(new ComponentName("com.landi.android.ccbpay ","com.landi.android.ccbpay.MainActivity"));
intent.putExtra("Date1", "name");
intent.putExtra("Date2", "count");
startActivityForResult(intent, 0); 
ComponentName的第一个参数是包路径,第二个参数是activity类。

二 使用activity名进行调用:


<span style="font-size:18px;">Intent intent = new Intent("CCBC");        
Bundle bundle = new Bundle();
bundle.putString("CallStr", "String");
intent.putExtras(bundle);
startActivityForResult(intent,0);</span>
使用名为CCBC名字的activity进行调用。调用前需要给目标activity进行命名,在配置文件AndroidManifest.xml中更改,命名方式如下:

<span style="font-size:18px;">        <activity
            android:name=".CCBCScriptActivity" android:screenOrientation="nosensor"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="CCBC" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity></span>



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值