- 17 Jan 2025
- 1 Minute à lire
- SombreLumière
- PDF
App Shielding Screen Mirroring API
- Mis à jour le 17 Jan 2025
- 1 Minute à lire
- SombreLumière
- PDF
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:
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>
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' }
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>
(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>
Import no.promon.shield.ui.ScrenMirroringLayoutName in your application class.
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 { ... }
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 { ... }
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.