androidsamsung-knox

How does a Samsung Knox compatible app tell if it's in a Knox container?


I have developed an application to work within the Samsung Knox environment. Due to the restrictions on the Knox environment, I need the app to respond differently depending on whether it's in a Knox container or outside of it. How can an app tell programmatically if it's been deployed inside the container?


Solution

  • I have a similar problem, though our application is NOT made to work within the Knox environment, but some users will place it in there anyway... So I am looking for a similar feature. I found the following which might help you. Sadly for us it doesn't work as it seems to only work when including the Knox Premium SDK: https://seap.samsung.com/faq/how-does-app-detect-if-container-was-created

    In short there are two ways to check. Either call this in code:

    KnoxContainerManager.getContainers()
    

    Or add this to your Manifest and add a Broadcast listener:

        <receiver
            android:name=".receiver.KnoxContainerReceiver"
            android:exported="true" >
            <intent-filter>
                <action android:name="com.samsung.knox.container.creation.status" />
            </intent-filter>
        </receiver>
    
    public class KnoxContainerReceiver extends BroadcastReceiver{
        @Override public void onReceive(Context context, Intent intent ){
        //do something
        }
    }
    

    If anyone finds a solution that works without the SDK I am very interested to hear it.