android调用其他apk的activity
<img src="https://img-blog.csdn.net/20160322114625025" alt="" />启动另一个apk的工程
public class MainActivity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.e("nafio","start load1");
ComponentName componetName = new ComponentName(
//这个是另外一个应用程序的包名
"com.example.t2",
//这个参数是要启动的Activity
"com.a.cc.TActivity");
try {
Intent intent = new Intent();
intent.setComponent(componetName);
startActivity(intent);
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "可以在这里提示用户没有找到应用程序,或者是做其他的操作!", 0).show();
Log.e("nafio",e.getMessage());
}
Log.e("nafio","end load");
}
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.n.tlaunchotherapk"
android:versionCode="1"
android:versionName="1.0" > <uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" /> <application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" > <activity
android:name=".MainActivity"
android:configChanges="keyboardHidden|navigation"
android:label="@string/app_name"
android:screenOrientation="portrait"> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application> </manifest>
被启动的工程,包名为com.example.t2 ,因为TActivity为非Action.Main,要想外部访问,要加android:exported="true"
package com.example.t2;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log; public class MainActivity extends Activity{ @Override
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.e("nafio","T2---------------"); } }
package com.a.cc; import android.app.Activity;
import android.os.Bundle;
import android.util.Log; public class TActivity extends Activity{ @Override
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.e("nafio","TActivity!!!!!---------------"); } }
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.t2"
android:versionCode="1"
android:versionName="1.0" > <uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" /> <application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" > <activity
android:name=".MainActivity"
android:configChanges="keyboardHidden|navigation"
android:label="@string/app_name"
android:screenOrientation="portrait"> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity> <activity
android:name="com.a.cc.TActivity"
android:configChanges="keyboardHidden|navigation"
android:label="@string/app_name"
<span style="color:#ff0000;">android:exported="true"</span>
android:screenOrientation="portrait">
</activity> </application> </manifest>
android调用其他apk的activity的更多相关文章
- 两个android程序间的相互调用(apk互调)
通常我们用到的只是activity之间的互相跳转和调用,很少会用到apk级别的互相调用. 往往在一些应用上会用到,比如一个支付系统,可能会有很多的一系列的程序调用到:彩票系统.订票系统.团购网……全部 ...
- 实现Android 动态载入APK(Fragment or Activity实现)
尊重原创:http://blog.csdn.net/yuanzeyao/article/details/38565345 近期由于项目太大了.导致编译通只是(Android对一个应用中的方法个数貌似有 ...
- Android四大组件应用系列——Activity与Service交互实现APK下载
Servic与Activity相比它没有界面,主要是在后台执行一些任务,Service有两种启动方法startService()和bindService(),startService方式Service ...
- 不同apk的activity互相调用
目标:CHFSAsk.apk调用CHFSAdviser.apk中的AppStart和MainActivity两种activity. CHFSAsk.apk:去调用的apk, 包名为com.chfs.a ...
- android开发中关于继承activity类中方法的调用
android开发中关于继承activity类中的函数,不能在其他类中调用其方法. MainActivity.java package com.example.testmain; import and ...
- Android提升篇系列:Activity recreate(Activity 重新创建/自我恢复)机制(一)
注:本文中的recreate是指当内存不足时,Activity被回收,但再次来到此Activity时,系统重新恢复的过程.例如:当Activity A到Activity B时,如果内存不足,A被回收, ...
- Android 调用系统照相机拍照和录像
本文实现android系统照相机的调用来拍照 项目的布局相当简单,只有一个Button: <RelativeLayout xmlns:android="http://schemas.a ...
- Android调用天气预报的WebService简单例子
下面例子改自网上例子:http://express.ruanko.com/ruanko-express_34/technologyexchange5.html 不过网上这个例子有些没有说明,有些情况不 ...
- Android调用相机并将照片存储到sd卡上
Android中实现拍照有两种方法,一种是调用系统自带的相机,然后使用其返回的照片数据. 还有一种是自己用Camera类和其他相关类实现相机功能,这种方法定制度比较高,洗染也比较复杂,一般平常的应用只 ...
随机推荐
- 搭建React Native开发环境
搭建React Native开发环境 本文档是Mac下搭建的环境,针对的目标平台不同,以及开发 iOS 和 Android 的不同,环境搭建也有差异. Github地址:https://github. ...
- 【BZOJ2625】[Neerc2009]Inspection 最小流
[BZOJ2625][Neerc2009]Inspection Description You are in charge of a team that inspects a new ski reso ...
- jsp页面中文乱码解决方案
一.JSP页面中文乱码 在JSP页面中,中文显示乱码有两种情况:一种是HTML中的中文乱码,另一种是在JSP中动态输出的中文乱码. 先看一个JSP程序: <%@ page language=&q ...
- ECMAscript 没有对该方法进行标准化,因此反对使用它。 es 日期格式化
JavaScript substr() 方法 http://www.w3school.com.cn/jsref/jsref_substr.asp 注释:substr() 的参数指定的是子串的开始位置和 ...
- xcode环境变量设置(转载)
一般我们在xcode里面配置包含工程目录下头文件的时候,都要关联着相对路径和绝对路径,如果只是自己用这个项目,用绝对路径的问题不大,但是如果你把工程发给别人,别人就要在改这个绝对路径,这时候绝对路径的 ...
- Codeforces Round #376 (Div. 2) A. Night at the Museum —— 循环轴
题目链接: http://codeforces.com/contest/731/problem/A A. Night at the Museum time limit per test 1 secon ...
- HTML(DOM)与JavaScript嵌套数组之间相互转换
html2ja:将html目标元素解析为JavaScript数组字面量,每项的值为tagName, className, id等CSS选择器组合: showJa:将html2ja生成的数组缩进格式化显 ...
- 值域线段树 (玲珑OJ 1117)
点击打开题目链接 题目意思很简单: 1.插入x 2.把小于x的数变成x 3.把大于x的数变成x 4.求集合中第x小数 5.求集合中小于x的数个数 思路: 线段树,节点是值的分数,你可以离散,也可以不离 ...
- boost replace_if replace_all_regex_copy用法
#include <boost/algorithm/string.hpp> // for is_any_of #include <boost/range/algorithm/repl ...
- 2019腾讯广告算法大赛 Rank23
由于官方审核代码,代码将在2019年6月28号后开源 写在前面 这次腾讯的第三届广告算法大赛,是我第一次参加,取得了初赛与复赛均为23名的成绩,毕竟我只是初打比赛不久的小白.我想在此分享下我的基本解题 ...