作为依赖的工程如何intent到主工程中?

来源:互联网 发布:mac快捷键重启 编辑:程序博客网 时间:2024/05/02 02:43

概述

在将工程A作为依赖import module 工程B中,想使用A中的方法Intent跳转到B中的类中的时候,使用intent(contxt,class)的时候,会发现目的class是找不到的。

解决方法 ##

假如目的class为B中的b类,A中的a类为始发地

我们需要做的步骤如下:

  1. 在AndroidManifest.xml文件中找到b类的所在配置清单文件,然后加入action
    <intent-filter >
    <action android:name="com_demo"></action>
    <category android:name="android.intent.category.DEFAULT"></category>
    </intent-filter>

  2. 跳转方法使用:

 Intent intent=new Intent("com_demo");                startActivity(intent);
0 0