I am creating an instant app, which include application module, base feature module, instant app module and an another feature module. Problem is i am not able to access the activities of application module from base-feature and feature module and same between base-feature module and feature module but i am able to access activity of base-feature module from application module.
Right now i am accessing the activities using :
Intent i = new Intent(this,
Class.forName("com.demo.test.appmodule.TextActivity"));
by this method studio don't show me any errors at compile time.
Can i have a link which define the project structure for an instant app
Thanks in advance
The reason why you can't communicate directly between features is because they're independent from one another.
The correct way to handle this is calling it with its URL, example: android-instant-apps/hello-feature-module/HelloActivity.java
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("https://hello-feature.instantappsample.com/goodbye"));
intent.addCategory(Intent.CATEGORY_BROWSABLE);
startActivity(intent);
In an instant-app structure, the base acts as a library for the feature modules, and the features are built into APKs . In an installed-app structure, both the base and features act as libraries for the application module. Some explanation can be found here:
There used to be a page @ https://g.co/instantapps that explained the structure of instant apps, but looks like it's missing. However, you can take a look at:
And no, you won't be able to directly access activities of the application from a feature. As an installed-app, com.android.feature
modules are compiled/behave as com.android.library
modules, so apply the same rules here: the application depends on the library, not the other way around. To traverse that direction, you will need to use the same kind of Intent as shown above.
Anything in com.android.application
will be isolated from the feature modules of the instant-app, and will only appear in the installed-app.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.