Andrey Lebed
May 29, 2018
6:57 am

ACTION_PACKAGE_ADDED for Containers

Hello,

I am working on developing software for Android Knox Containers using SEAP API.
https://seap.samsung.com/api-references/android-premium/reference/com/se...

When application is installed it is possible to receive intent using android api
https://developer.android.com/reference/android/content/Intent#ACTION_PA...

What api can be used if I want to get information after application installation/uninstallation for containers?
It would be good to subscribe to similar intent, but standard receiver is not called after container application change it's state.

 

 

Kamil Kaszubski
May 29, 2018
10:40 am

Unfortunately, this intent is not send outside of Container.

The only workaround is using additional listener inside Knox container which is running activity from your application outside Container with intent added to allowed intents.

Intents can be whitelisted since Android N using addCrossProfileIntentFilter API.

Andrey Lebed
May 29, 2018
5:56 pm

Is it possible to get working example of function addCrossProfileIntentFilter ?

I use 2 different applications, which are communicating well outside the container. When I put one application inside the container, and call startActivity inside it, I receive exception, that called activity can not be found.
addCrossProfileIntentFilter is called according to docs without errors:
https://seap.samsung.com/api-references/android-premium/reference/com/se...(android.content.ComponentName,%20android.content.IntentFilter,%20int)

Kamil Kaszubski
May 30, 2018
8:22 am

I have created apk, however I am not able to attach it here at this point.

Please take a look at below solution explanation with sampe code.

Application 1:
- activates device admin
- activates Knox license
- creates container and installs Application 2 inside it.
- add cross profile intent as below

    public static final String INTENT_FOR_SECOND_ACTIVITY = "com.samsung.android.sdk.b2b.samples.crossprofileintentdemo.RUN_ACTIVITY";
    ...
    IntentFilter intentFilter = new IntentFilter(INTENT_FOR_SECOND_ACTIVITY);
    intentFilter.addCategory(Intent.CATEGORY_DEFAULT);
    containerConfigurationPolicy.addCrossProfileIntentFilter(DeviceAdminController.getAdmin(this), intentFilter, DevicePolicyManager.FLAG_PARENT_CAN_ACCESS_MANAGED);

- includes second Activity declared as below

        <activity android:name=".Main2Activity">
            <intent-filter>
                <action android:name="com.samsung.android.sdk.b2b.samples.crossprofileintentdemo.RUN_ACTIVITY"/>
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        
Application 2.
- is installed inside Knox container
- sends intent as below

    public static final String INTENT_RUNNING_APP_FROM_PERSONAL = "com.samsung.android.sdk.b2b.samples.crossprofileintentdemo.RUN_ACTIVITY";
    ...
    Intent intent = new Intent(INTENT_RUNNING_APP_FROM_PERSONAL);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        try {
            startActivity(intent);
        } catch (ActivityNotFoundException e){
            Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
        }
        
Please note that cross profile intents work on devices with Android N and higher