Reputation: 55
I have one application "Master" installed on phone. Is it possible to access resource from other app "Slave" as instant app ?
I know that it's possible between 2 installed apps using :
Resources resources = getPackageManager().getResourcesForApplication(packageName);
String slaveAppName = resources.getString(resources.getIdentifier("app_name", "string", packageName));
Thx
L.E :
I also try to send data from the instant app to the installed application ( reverse from above ) using :
Intent intent = new Intent("com.test.MainActivity");
intent.putExtra("data","data string");
startActivity(intent);
on the installed app i have in AndroidManifest :
<intent-filter>
<action android:name="com.text.MainActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
All good when i try to send data as installed app... but once i build the instant app.....it crash with :
Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.text.MainActivity (has extras) }
L.E (2)
i also try just for testing to find out how many apps are installed on the phone with the instant app build using :
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> pkgAppsList =
this.getPackageManager().queryIntentActivities( mainIntent, 0);
Log.d("log","installed apps : "+pkgAppsList.size());
This was a test just to find out if the instant app build can "touch" the local phone settings. And it works
Upvotes: 0
Views: 321
Reputation: 591
Instant app can access an installed app’s resources with
Resources resources = getPackageManager().getResourcesForApplication(packageName); String slaveAppName = resources.getString(resources.getIdentifier("app_name", "string", packageName));
code when installable app is visible to instant.
Add the following to your installed app to make it visible for instant apps:
android:visibleToInstantApps="true"
to the
component<meta-data android:name="instantapps.clients.allowed" android:value="true"/>
to <application>
More details at How to expose component from installed app to be visible to instant app?
To get instant app metadata from the installed app use LaunchData API
As for sending data from instant to installed app, on pre-O devices instant app crashes with
java.lang.SecurityException: Not allowed to start activity Intent
, this suggests that it’s not supported in Instant Apps, see Not able to launch Gallery from Android Instant app.
Upvotes: 1