第一种:ComponentName()

使用ComponentName()可以跳转到任何一个activity,不论是不是main activity。也不必写修改被调用的apk的AndroidManifest.xml任何内容,如下:

ComponentName componetName = new ComponentName(                 //这个是另外一个应用程序的包名                 "com.hooy.apk2",                //这个参数是要启动的Activity                 "com.hooy.apk2.Pay_Activity"); //        Intent intent= new Intent("chroya.foo");        Intent intent= new Intent();        //我们给他添加一个参数表示从apk1传过去的        Bundle bundle = new Bundle();        bundle.putString("arge1", "这是跳转过来的!来自apk1");        intent.putExtras(bundle);        intent.setComponent(componetName);        startActivity(intent);

第二种方法Intent+AndroidManifest.xml

顾名思义,此方法是用Intent和修改AndroidManifest.xml达成的。
<intent-filter>
<action android:name="com.foo"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>

  • Intent intent = new Intent("com.foo");
  • startActivity(intent);

  • 更多相关文章

    1. Handler sendMessage 与 obtainMessage (sendToTarget)比较
    2. 【Android】获取手机中已安装apk文件信息(PackageInfo、ResolveI
    3. Android(安卓)Studio 3.0后出现AAPT2和“android.enableAapt2”
    4. Android(安卓)实现定时任务之一 - 使用Handler的postDelayed
    5. Android4.0 隐藏虚拟按键 实现全屏
    6. android 组件生命周期
    7. Android中SharedPreferences的使用
    8. 安卓应用-去掉标题栏
    9. WebRTC-M68-官方编译文档-Android'

    随机推荐

    1. Android 打开关闭闪光灯工具类
    2. android 的C++代码都加 namespace androi
    3. [置顶] 调用Android发短信接口Intent.ACT
    4. Internal error. Please report to https
    5. Android多点触摸缩放图片-android学习之
    6. 对View DrawingCache的理解
    7. Android ListView+image的使用
    8. [Android] 代码实现按钮/图片自旋转(中心
    9. Andorid在布局文件中中文加粗
    10. (20120808)(01)android菜单与对话框--之日期