怎么在一个APP中调用另外一个APP

        声明:下文中把去调用的APP称谓A,把被调用的APP称谓B。

        首先在B中的清单文件中找到A调用时需要进入到的activity,并把在属性中增加:

       <pre class="html" name="code"><pre class="html" name="code"><activity
            android:name="org.ebookdroid.pdfdroid.activity.MainFunctionActivity"
            android:hardwareAccelerated="true"
            android:label="@string/app_name"
            android:launchMode="singleTask"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar" 
            <span style="color:#ff0000;"><strong>android:exported="true"</strong> </span>>
          <intent-filter>
                <action android:name="<strong><span style="color:#ff0000;">com.esa2000.azt.asignon1.startViewer</span></strong>" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

     然后在A中的activity中去调用这个action。
 
 

    即

Intent intent = new Intent("com.esa2000.azt.asignon1.startViewer");
intent.putExtra("name", str1);
intent.putExtra("password", str2);
startActivity(intent);


如果不需要带参数的话,就不需要加上

intent.putExtra("name", str1);
intent.putExtra("password", str2);
在B的MainFunctionActivity中getIntent()就能获得参数。
 
另外,如果想在手机桌面只显示A而不显示B,则需要在B的清单文件中把跳入到的activity中属性<category android:name="android.intent.category.LAUNCHER" />给改成<category android:name="android.intent.category.DEFAULT" />。
 
还有想在同一部手机中既能安装B的本身APP,又能安装A调用的B,则需要把被调用的APP也是B中的包名给改掉。
例如B本身的包名为<manifest xmlns:android="<a target=_blank href="http://schemas.android.com/apk/res/android">http://schemas.android.com/apk/res/android</a>"
    <strong><span style="color:#ff0000;">package="com.example</span></strong>"
    android:versionCode="1"
    android:versionName="1.0" >	

改成为<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.test"
    android:versionCode="1"
    android:versionName="1.0" >。


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值