App Shielding Screen Mirroring API
  • 22 Jan 2025
  • 1 Minute à lire
  • Sombre
    Lumière
  • PDF

App Shielding Screen Mirroring API

  • Sombre
    Lumière
  • PDF

The content is currently unavailable in French. You are viewing the default English version.
Résumé de l’article

This section describes how to use the screen mirroring API with your Android Studio project.

Screen Mirroring Customized Layout

App Shielding includes the option to provide a customized screen mirroring layout. This can be used to inform the user regarding the application’s security features. There are two layout types you can currently provide to block screen mirroring. Portrait layout is designed for phone and tablet screens, and landscape layout is designed for TV screens. You can provide these layouts for one build, and the feature will automatically detect the screen type. When using this feature, the landscape layout is optional. If there is no definition for landscape layout, the portrait layout will be used for any screen type.

Application integration

To use this feature:

  1. Enable the checkScreenMirroring and blockScreenMirroring options in the App Shielding configuration file.

    Config.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <shield>
      <config>
        <checkScreenMirroring v="true" />
        <blockScreenMirroring v="true" />
        ...
      </config>
    </shield>
  2. Add the no.promon.shield:ShieldSDK-screen-mirroring:7.0.2 library to your project's dependencies section.

    MyApplication/app/build.gradle

    dependencies {
    ...
    implementation 'no.promon.shield:ShieldSDK-screen-mirroring:7.0.2'
    }
  3. Design a layout for your screenMirroring blocking.

    The file should be inside the res/layout/ folder (e.g., res/layout/portrait_layout.xml).

    portrait_layout.xml

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent">
    
      <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:textSize="10dp"
        android:id="@+id/company_logo"
        android:src="@drawable/company_logo" />
    
      ...
    
    </RelativeLayout>

  4. (Optional) Design a second layout that is used for landscape mode (e.g., res/layout/landscape_layout.xml)

    landscape_layout.xml

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent">
    
      <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:textSize="14dp"
        android:id="@+id/company_logo_landscape"
        android:src="@drawable/company_logo" />
    
      ...
    
    </RelativeLayout>
  5. Import no.promon.shield.ui.ScrenMirroringLayoutName in your application class.

  6. Apply the @ScrenMirroringLayoutName annotation to your application class with the name of the layout resource as the string argument.

    ApplicationClass.java

    import android.app.Application;
    import no.promon.shield.ui.ScreenMirroringLayoutName;
    
    @ScreenMirroringLayoutName(value = "portrait_layout", landscape = "landscape_layout")
    public class MyApplicationClass extends Application {
      ...
    }
  7. If you do not need the landscape layout you can omit the landscape attribute in the @ScrenMirroringLayoutName annotation:

    ApplicationClass.java

    import android.app.Application;
    import no.promon.shield.ui.ScreenMirroringLayoutName;
    
    @ScreenMirroringLayoutName("portrait_layout")
    public class MyApplicationClass extends Application {
      ...
    }
  8. Add your application class in the AndroidManifest.xml file as follows:

    AndroidManifest.xml

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.test.myapplication">
    
      <application
        android:name=".MyApplicationClass">
        ...
      </application>
    
    </manifest>

If your app uses the Android default application class, you need to define an empty application class.


Cet article vous a-t-il été utile ?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.
ESC

Ozzy, facilitant la découverte de connaissances grâce à l’intelligence conversationnelle