<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Antonin Fouques</title>
    <description>Antonin Fouques, Android Staff Engineer at Qonto. Compose, AI for Android, and a decade of community work across PAUG, Droidcon Paris and AndroidMakers.
</description>
    <link>https://cmoatoto.com/</link>
    <atom:link href="https://cmoatoto.com/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Mon, 06 Jul 2026 10:03:04 +0000</pubDate>
    <lastBuildDate>Mon, 06 Jul 2026 10:03:04 +0000</lastBuildDate>
    <generator>Jekyll v3.10.0</generator>
    
      <item>
        <title>How to change default Font in Genymotion Devices (or in any rooted Android device)</title>
        <description>&lt;p&gt;Today, while I surveyed, as all days, the “&lt;a href=&quot;https://twitter.com/search?f=realtime&amp;amp;q=genymotion&amp;amp;src=typd&quot;&gt;genymotion&lt;/a&gt;” results in Twitter, &lt;a href=&quot;https://twitter.com/colriot&quot;&gt;Sergey Ryabov&lt;/a&gt; asked this question:&lt;/p&gt;

&lt;blockquote class=&quot;twitter-tweet&quot; data-lang=&quot;fr&quot;&gt;&lt;p lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;&lt;a href=&quot;https://twitter.com/Genymotion?ref_src=twsrc%5Etfw&quot;&gt;@Genymotion&lt;/a&gt; Consider a feature request. How about adding Custom Locale with Redacted [&lt;a href=&quot;http://t.co/OlEatJYH87&quot;&gt;http://t.co/OlEatJYH87&lt;/a&gt;] font? Is it even possible?&lt;/p&gt;&amp;mdash; Sergey Ryabov (@colriot) &lt;a href=&quot;https://twitter.com/colriot/status/588645473164140544?ref_src=twsrc%5Etfw&quot;&gt;16 avril 2015&lt;/a&gt;&lt;/blockquote&gt;
&lt;script async=&quot;&quot; src=&quot;https://platform.twitter.com/widgets.js&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;

&lt;p&gt;&lt;br /&gt;
As I answered that it could be possible, there is almost no chance to add it to a close backlog…&lt;/p&gt;

&lt;p&gt;And by the way, why would he want to do that? Font is Font, Locale is Locale, there is no real point to change the Font when changing the Locale. Maybe for different languages with different symbols, graphemes or writing systems but not much more. Let’s assume he just wanted to change the Font, using the Locale settings.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What do we want here:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Showcase an app with private data&lt;/li&gt;
  &lt;li&gt;Hide the text from the app as it is private using an alternative special font&lt;/li&gt;
  &lt;li&gt;Don’t change the app source code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The easiest way will be to use an emulated rooted device (so we can do what we want, break it and trash it after the shwocase). We will use &lt;a href=&quot;https://genymotion.com&quot;&gt;Genymotion&lt;/a&gt;. As an example showcased application, we will use Twitter. So we start here:&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;https://cmoatoto.com/assets/images/genymotion_fonts_genymotion_twitter_base.png&quot; alt=&quot;Twitter in Genymotion without modification&quot; style=&quot;width: 300px; margin-left: auto; margin-right: auto&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Then we download the desired font. Here, the &lt;a href=&quot;https://github.com/christiannaths/Redacted-Font&quot;&gt;Redacted Script Font&lt;/a&gt; will hide the text behind a beautiful scratch.&lt;/p&gt;

&lt;p&gt;We will now use the functionalities of &lt;a href=&quot;https://developer.android.com/studio/command-line/adb&quot;&gt;ADB&lt;/a&gt; (Android Debug Bridge) to communicate and modify the Android system fonts.&lt;/p&gt;

&lt;p&gt;As &lt;a href=&quot;https://genymotion.com&quot;&gt;Genymotion&lt;/a&gt; devices are already rooted, we will just remount the system partition in write mode:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;adb remount
remount succeeded&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Then we will replace the default system fonts &lt;em&gt;Roboto&lt;/em&gt; (Normal, Light and Bold) by the Redacted ones.&lt;/p&gt;

&lt;p&gt;In order to backup the existing font, we just rename them by adding &lt;em&gt;.old&lt;/em&gt; at the end:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;filename &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;adb shell &lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; /system/fonts/Roboto&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;adb shell &lt;span class=&quot;nb&quot;&gt;mv&lt;/span&gt; /system/fonts/&lt;span class=&quot;nv&quot;&gt;$filename&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;,.old&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;done&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;We now copy all the Redacted Light font in the system folder, with the Roboto Light and Thin fonts names:&lt;/p&gt;

&lt;p&gt;Light:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;adb push ~/Downloads/Redacted-Font-old-sources/fonts/redacted-script-light.ttf /system/fonts/Roboto-Light.ttf
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;adb push ~/Downloads/Redacted-Font-old-sources/fonts/redacted-script-light.ttf /system/fonts/Roboto-LightItalic.ttf
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;adb push ~/Downloads/Redacted-Font-old-sources/fonts/redacted-script-light.ttf /system/fonts/Roboto-Thin.ttf
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;adb push ~/Downloads/Redacted-Font-old-sources/fonts/redacted-script-light.ttf /system/fonts/Roboto-ThinItalic.ttf
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;adb push ~/Downloads/Redacted-Font-old-sources/fonts/redacted-script-light.ttf /system/fonts/RobotoCondensed-Light.ttf
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;adb push ~/Downloads/Redacted-Font-old-sources/fonts/redacted-script-light.ttf /system/fonts/RobotoCondensed-LightItalic.ttf&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Regular:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;adb push ~/Downloads/Redacted-Font-old-sources/fonts/redacted-script-regular.ttf /system/fonts/Roboto-Italic.ttf
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;adb push ~/Downloads/Redacted-Font-old-sources/fonts/redacted-script-regular.ttf /system/fonts/Roboto-Medium.ttf
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;adb push ~/Downloads/Redacted-Font-old-sources/fonts/redacted-script-regular.ttf /system/fonts/Roboto-MediumItalic.ttf
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;adb push ~/Downloads/Redacted-Font-old-sources/fonts/redacted-script-regular.ttf /system/fonts/Roboto-Regular.ttf
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;adb push ~/Downloads/Redacted-Font-old-sources/fonts/redacted-script-regular.ttf /system/fonts/RobotoCondensed-Italic.ttf
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;adb push ~/Downloads/Redacted-Font-old-sources/fonts/redacted-script-regular.ttf /system/fonts/RobotoCondensed-Regular.ttf&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Bold:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;adb push ~/Downloads/Redacted-Font-old-sources/fonts/redacted-script-bold.ttf /system/fonts/Roboto-Black.ttf
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;adb push ~/Downloads/Redacted-Font-old-sources/fonts/redacted-script-regular.ttf /system/fonts/Roboto-BlackItalic.ttf
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;adb push ~/Downloads/Redacted-Font-old-sources/fonts/redacted-script-regular.ttf /system/fonts/Roboto-Bold.ttf
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;adb push ~/Downloads/Redacted-Font-old-sources/fonts/redacted-script-regular.ttf /system/fonts/Roboto-BoldItalic.ttf
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;adb push ~/Downloads/Redacted-Font-old-sources/fonts/redacted-script-regular.ttf /system/fonts/RobotoCondensed-Bold.ttf
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;adb push ~/Downloads/Redacted-Font-old-sources/fonts/redacted-script-regular.ttf /system/fonts/RobotoCondensed-BoldItalic.ttf&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;and then, let’s restart the device&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;adb reboot&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;After the restart of the device, let’s reopen our showcased application, and &lt;em&gt;Voila&lt;/em&gt;:&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;https://cmoatoto.com/assets/images/genymotion_fonts_genymotion_twitter_redacted.png&quot; alt=&quot;Twitter in Genymotion without modification&quot; style=&quot;width: 300px; margin-left: auto; margin-right: auto&quot; /&gt;&lt;/p&gt;

</description>
        <pubDate>Thu, 16 Apr 2015 18:51:00 +0000</pubDate>
        <link>https://cmoatoto.com/2015/04/16/how-to-change-default-font-in-genymotion-devices.html</link>
        <guid isPermaLink="true">https://cmoatoto.com/2015/04/16/how-to-change-default-font-in-genymotion-devices.html</guid>
        
        <category>android</category>
        
        <category>genymotion</category>
        
        <category>english</category>
        
        <category>system</category>
        
        <category>font</category>
        
        <category>tutorial</category>
        
        
      </item>
    
      <item>
        <title>MiraSlide : Développer une application Android (4.2+) multi-écran exploitant le WiDi par l&apos;exemple</title>
        <description>&lt;p&gt;Dans ce billet, je vais vous présenter les différentes étapes pour développer une application Android exploitant le WiDi. A l’issue de cette lecture, vous devriez connaitre les bases pour développer vos propres solutions multi-écrans sous Android. Cependant, le WiDi est loin d’être une solution cantonnée au monde Android et je vous invite à lire l’article de &lt;a href=&quot;http://software.intel.com/fr-fr/user/991216&quot;&gt;Pierre S&lt;/a&gt; sur le &lt;a href=&quot;http://software.intel.com/fr-fr/blogs/2013/12/10/d-velopper-une-application-winjs-20-windows-81-multi-crans-avec-widi&quot;&gt;développement d’application WinJS (Windows 8.1)&lt;/a&gt;.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#prerequis-1&quot;&gt;Prérequis&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#intro-miraslide-2&quot;&gt;MiraSlide : Une application de Présentations&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#widi-dans-android-3&quot;&gt;Utiliser le WiDi dans Android&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#implem-miraslide-4&quot;&gt;Implémentation du code dans MiraSlide&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#conclusion-5&quot;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;#sources-6&quot;&gt;Sources&lt;/a&gt;&lt;/p&gt;

  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Avant tout, il va falloir se familiariser avec certaines connaissances.&lt;/p&gt;

&lt;p&gt;&lt;a name=&quot;prerequis-1&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;prérequis&quot;&gt;Prérequis&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Android :&lt;/strong&gt; Si vous débutez sur le développement Android, je vous conseille très fortement de lire tous les guides de démarrage sur &lt;a href=&quot;http://developer.android.com/index.html&quot;&gt;le site des développeurs Android&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wireless Display (ou WiDi) :&lt;/strong&gt; Cette technologie de diffusion de flux audio et vidéo développée par Intel est une alternative aux technologies Miracast du consortium Wi-Fi Alliance, et AirPlay d’Apple. Cependant, la technologie WiDi permet aux appareils le supportant de communiquer avec les récepteurs Miracast. Finalement le WiDi se veut être une “super-surcouche” à Miracast. Afin d’en apprendre plus sur le WiDi, je vous conseille de lire cette présentation par &lt;a href=&quot;http://software.intel.com/fr-fr/user/991216&quot;&gt;Pierre S&lt;/a&gt; : &lt;a href=&quot;http://software.intel.com/fr-fr/blogs/2013/12/09/tout-savoir-sur-le-widi&quot;&gt;Tout savoir sur le WiDi&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Enfin, si vous voulez pousser encore plus loin vos connaissances sur le Wireless Display pour Android, vous pouvez consulter la vidéo de la conférence au Paris Android User Group sur la &lt;a href=&quot;http://www.youtube.com/watch?v=gZopNFkeHH4&quot;&gt;présentation du WiDi pour Android&lt;/a&gt; par &lt;a href=&quot;http://ph0b.com/&quot;&gt;Xavier Hallade&lt;/a&gt; (&lt;a href=&quot;http://fr.slideshare.net/bemyapp/wi-di-android-applications-development&quot;&gt;slides ici&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Assez de liens, passons au développement !&lt;/p&gt;

&lt;p&gt;&lt;a name=&quot;intro-miraslide-2&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;miraslide--une-application-de-présentations&quot;&gt;MiraSlide : Une application de Présentations&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;https://cmoatoto.com/assets/images/miraslide_logo.png&quot; alt=&quot;MiraSlide logo&quot; style=&quot;width: 300px; margin-left: auto; margin-right: auto&quot; /&gt;&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;a href=&quot;https://github.com/CmoaToto/MiraSlide&quot;&gt;Code source du projet MiraSlide&lt;/a&gt;&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;a href=&quot;https://play.google.com/store/apps/details?id=fr.cmoatoto.miraslide&quot;&gt;Page Google Play de l’application&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Le but de cette application est de répondre à un besoin simple : les conférenciers sont soit encombrés, soit esclaves du matériel prêté, soit les deux. Ici, le Wireless Display associé à un appareil plus léger qu’un ordinateur et pouvant donc être utilisé en télécommande nous permettrait de diffuser et commander les slides depuis son téléphone/tablette, en ayant en plus dans la main les informations supplémentaires que nous apporte un ordinateur (chronomètre, notes…).&lt;/p&gt;

&lt;p&gt;Voici donc le but très simple de MiraSlide :&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Vous sélectionnez votre fichier de présentation, vous connectez votre appareil à un écran récepteur Wireless Display puis vous lancez la présentation.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Sur l’écran récepteur, la première page de votre présentation s’affiche.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;L’écran de votre appareil vous propose alors un chronomètre, ainsi qu’une télécommande affichant le slide courant, les notes éventuelles, et des boutons précédent / suivant.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;https://cmoatoto.com/assets/images/miraslide_presentation.png&quot; alt=&quot;MiraSlide presentation&quot; style=&quot;width: 600px; margin-left: auto; margin-right: auto&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Maintenant que nous avons une idée plus précise de l’application que nous voulons développer, nous allons nous pencher sur les APIs.&lt;/p&gt;

&lt;p&gt;&lt;a name=&quot;widi-dans-android-3&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;utiliser-le-widi-dans-android&quot;&gt;Utiliser le WiDi dans Android&lt;/h2&gt;

&lt;p&gt;Pour ceux qui n’auraient pas bien lu les prérequis, le WiDi (et plus largement la notion d’écran externe) apparaît dans le framework d’Android avec l’API 17 (Android 4.2.2). Deux éléments essentiels sont alors créés :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Le &lt;strong&gt;&lt;a href=&quot;http://developer.android.com/reference/android/hardware/display/DisplayManager.html&quot;&gt;Display Manager&lt;/a&gt;&lt;/strong&gt; va être l’interface permettant à l’application de connaitre les écrans disponibles et d’interagir avec.&lt;/li&gt;
  &lt;li&gt;Une &lt;strong&gt;&lt;a href=&quot;http://developer.android.com/reference/android/app/Presentation.html&quot;&gt;Presentation&lt;/a&gt;&lt;/strong&gt; est une vue similaire à une &lt;strong&gt;&lt;a href=&quot;http://developer.android.com/reference/android/app/Dialog.html&quot;&gt;Dialog&lt;/a&gt;&lt;/strong&gt; (dont elle est étendue) mais projetée sur un &lt;strong&gt;&lt;a href=&quot;http://developer.android.com/reference/android/view/Display.html&quot;&gt;Display&lt;/a&gt;&lt;/strong&gt; donné. Une des notions les plus importantes à comprendre du fait que la &lt;strong&gt;Presentation&lt;/strong&gt; est une extension d’une &lt;strong&gt;Dialog&lt;/strong&gt; est qu’elle est forcément attachée à une &lt;strong&gt;&lt;a href=&quot;http://developer.android.com/reference/android/app/Activity.html&quot;&gt;Activity&lt;/a&gt;&lt;/strong&gt;. Ainsi, si cette dernière est mise en pause (si elle n’est plus visible à l’écran, en gros), alors la &lt;strong&gt;Presentation&lt;/strong&gt; n’apparaîtra plus sur le &lt;strong&gt;Display&lt;/strong&gt; associé (et le mode d’écran clone par défaut s’activera). Si vous retournez ensuite à votre &lt;strong&gt;Activity&lt;/strong&gt;, la &lt;strong&gt;Presentation&lt;/strong&gt; reviendra s’afficher sur le &lt;strong&gt;Display&lt;/strong&gt;.
L’implémentation est finalement très simple :&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;#recuperation-display-31&quot;&gt;Récupération du Display&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#creation-affichage-32&quot;&gt;La création et l’affichage de la Presentation&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;#ajout-listeners-33&quot;&gt;Ajout de listeners&lt;/a&gt;&lt;/p&gt;

  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a name=&quot;recuperation-display-31&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;1-la-récupération-du-display&quot;&gt;1. La récupération du Display&lt;/h3&gt;

&lt;p&gt;Elle peut se faire de deux façons. Ou bien en utilisant le &lt;strong&gt;&lt;a href=&quot;http://developer.android.com/reference/android/media/MediaRouter.html&quot;&gt;MediaRouter&lt;/a&gt;&lt;/strong&gt; introduit avec l’API 16 :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;nc&quot;&gt;MediaRouter&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mediaRouter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;MediaRouter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getSystemService&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;MEDIA_ROUTER_SERVICE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;MediaRouter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;RouteInfo&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;route&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mediaRouter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getSelectedRoute&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;route&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nc&quot;&gt;Display&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;presentationDisplay&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;route&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getPresentationDisplay&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;presentationDisplay&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;// Your code...&lt;/span&gt;

    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Ou bien en utilisant le &lt;strong&gt;&lt;a href=&quot;http://developer.android.com/reference/android/hardware/display/DisplayManager.html&quot;&gt;Display Manager&lt;/a&gt;&lt;/strong&gt; :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;nc&quot;&gt;DisplayManager&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;displayManager&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DisplayManager&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mActivity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getSystemService&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;DISPLAY_SERVICE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Selecting DISPLAY_CATEGORY_PRESENTATION prevents the DisplayManager from returning inapropriate Display,&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// like the own device display.&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;Display&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;displays&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;displayManager&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getDisplays&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DisplayManager&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;DISPLAY_CATEGORY_PRESENTATION&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;displays&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;// If there is no external display connected, we launch the Display settings. We could launch&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// the Wifi display settings with ACTION_WIFI_DISPLAY_SETTINGS but it is a hidden static value&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// because there may be not such settings (if the device does not have Wireless display but&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// have API &amp;gt;= 17).&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;startActivity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Intent&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Settings&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;ACTION_DISPLAY_SETTINGS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;));&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;// We should show a DialogBox to let the user select the display if there is more than one but&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// for this example we only choose the first one&lt;/span&gt;
    &lt;span class=&quot;nc&quot;&gt;Display&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;display&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;displays&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;];&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;a name=&quot;creation-affichage-32&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;2-la-création-et-laffichage-de-la-presentation&quot;&gt;2. La création et l’affichage de la Presentation&lt;/h3&gt;

&lt;p&gt;Ici non plus, rien de très compliqué. La &lt;strong&gt;Presentation&lt;/strong&gt; n’a besoin que de l’&lt;strong&gt;Activity&lt;/strong&gt; parente et du &lt;strong&gt;Display&lt;/strong&gt; où être affiché pour être créé. Ensuite, la méthode &lt;strong&gt;&lt;em&gt;show()&lt;/em&gt;&lt;/strong&gt; affiche la &lt;strong&gt;Presentation&lt;/strong&gt; sur le &lt;strong&gt;Display&lt;/strong&gt;. Comme une &lt;strong&gt;Dialog&lt;/strong&gt;, la &lt;strong&gt;Presentation&lt;/strong&gt; comprend une méthode &lt;strong&gt;&lt;em&gt;setContentView()&lt;/em&gt;&lt;/strong&gt; grâce à laquelle vous pourrez définir la vue à afficher :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;showPresentation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;mPresentation&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MyPresentation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mDisplay&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;mPresentation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MyPresentation&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Presentation&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

    &lt;span class=&quot;cm&quot;&gt;/* constructors ... */&lt;/span&gt;

    &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Bundle&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;savedInstanceState&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;savedInstanceState&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;nc&quot;&gt;View&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;getLayoutInflater&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;inflate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;layout&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;presentation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;setContentView&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;a name=&quot;ajout-listeners-33&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;3-ajout-de-listeners&quot;&gt;3. Ajout de listeners&lt;/h3&gt;

&lt;p&gt;Pour rendre votre système plus fiable, vous pouvez rajouter des listeners au &lt;strong&gt;DisplayManager&lt;/strong&gt; afin d’être prévenu lorsque des &lt;strong&gt;Display&lt;/strong&gt; sont ajoutés ou retirés. Ceci est particulièrement pratique pour éviter à une &lt;strong&gt;Presentation&lt;/strong&gt; de tenter de continuer à fonctionner alors que le &lt;strong&gt;Display&lt;/strong&gt; qui lui est associé a été déconnecté :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;n&quot;&gt;mDisplayManager&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;registerDisplayListener&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;DisplayListener&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

    &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onDisplayRemoved&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;displayId&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// Stop presentation ...&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// Show a message to the user to reconnect the display&lt;/span&gt;

    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onDisplayChanged&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;displayId&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// Something happend. You should check if everything is ok before continuing&lt;/span&gt;

    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onDisplayAdded&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;displayId&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// If you were waiting for a display, maybe you should use it !&lt;/span&gt;

    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;a name=&quot;implem-miraslide-4&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;implémentation-du-code-dans-miraslide&quot;&gt;Implémentation du code dans MiraSlide&lt;/h2&gt;

&lt;p&gt;Nous n’allons bien évidemment pas revenir sur tout le code de MiraSlide, ce serait long et inutile, car finalement le code concernant le &lt;strong&gt;Wireless Display&lt;/strong&gt; est assez court face au reste du code. Nous allons donc nous focaliser sur les points suivants :&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;#recuperation-display-41&quot;&gt;La récupération du Display&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#selection-display-42&quot;&gt;La sélection du Display&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#creation-affichage-43&quot;&gt;La création et l’affichage de la Presentation&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;#controle-presentation-44&quot;&gt;Le contrôle de la Presentation&lt;/a&gt;&lt;/p&gt;

  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Cependant, je vais rapidement expliquer la structure générale du code qui se divise en 4 éléments principaux.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;la &lt;strong&gt;MainActivity&lt;/strong&gt; est l’unique &lt;strong&gt;Activity&lt;/strong&gt; de l’application. Ainsi, si la &lt;strong&gt;Presentation&lt;/strong&gt; est en cours et que l’on se déplace entre les différentes vues, la &lt;strong&gt;Presentation&lt;/strong&gt; ne s’arrête pas.&lt;/li&gt;
  &lt;li&gt;le &lt;strong&gt;SelectionFragment&lt;/strong&gt; est la première vue, qui va permettre à l’utilisateur de sélectionner le fichier (PDF) contenant les slides, ainsi que le &lt;strong&gt;Display&lt;/strong&gt; sur lequel afficher la &lt;strong&gt;Presentation&lt;/strong&gt;. Enfin, il permet de lancer la-dite &lt;strong&gt;Presentation&lt;/strong&gt;.&lt;/li&gt;
  &lt;li&gt;le &lt;strong&gt;ControllerFragment&lt;/strong&gt; est la vue s’affichant lorsque l’on lance la &lt;strong&gt;Presentation&lt;/strong&gt;. Elle comprend un chronomètre, le slide courant ainsi que des boutons précédent et suivant.&lt;/li&gt;
  &lt;li&gt;le &lt;strong&gt;PdfViewerPresentation&lt;/strong&gt; est la vue &lt;strong&gt;Presentation&lt;/strong&gt; gérant ce qui est affiché sur le &lt;strong&gt;Display&lt;/strong&gt;. Il comprend le moteur permettant de récupérer et d’afficher les images des slides demandés par le &lt;strong&gt;ControllerFragment&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a name=&quot;recuperation-display-41&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;1-la-récupération-du-display-1&quot;&gt;1. La récupération du Display&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;À la création du &lt;strong&gt;SelectionFragment&lt;/strong&gt;, on récupère le &lt;strong&gt;DisplayManager&lt;/strong&gt; et on déclare les listeners.&lt;/li&gt;
  &lt;li&gt;Chaque fois que le &lt;strong&gt;SelectionFragment&lt;/strong&gt; est lancé ou relancé (dans le &lt;strong&gt;&lt;em&gt;onResume(…)&lt;/em&gt;&lt;/strong&gt;), on va vérifier l’état des &lt;strong&gt;Display&lt;/strong&gt;s. Si il n’yen a aucun, on propose d’afficher les paramètres d’affichages, si il y en a un seul, on le sélectionne automatiquement, et s’il yen a plus, on propose de sélectionner le &lt;strong&gt;Display&lt;/strong&gt; voulu.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Voici le code associé :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SelectionFragment&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Fragment&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;implements&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;OnClickListener&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;DisplayListener&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;// ...&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;// The display manager is the object to get information about the different displays&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;DisplayManager&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mDisplayManager&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Bundle&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;savedInstanceState&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;savedInstanceState&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;// ...&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;// We get the display manager to get info about the display. We also register to any change&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// about the (dis)connection of the displays.&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;mDisplayManager&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DisplayManager&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mActivity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getSystemService&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;DISPLAY_SERVICE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;mDisplayManager&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;registerDisplayListener&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onResume&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;onResume&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;// On resume, we check the state of each buttons.&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;checkLaunchable&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getView&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;// We check the selection of the pdf file and the display, and we update the color of the buttons and we update&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// if the &quot;Launch Projection&quot; button should be enabled&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// @param v : the global view of the fragment&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;checkLaunchable&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;View&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;checkDisplay&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;TextView&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;findViewById&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;fragment_selection_button_selectwirelessdisplay&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;));&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mActivity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getDislay&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;findViewById&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;fragment_selection_button_selectwirelessdisplay&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setBackgroundResource&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;drawable&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;button_green&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;findViewById&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;fragment_selection_button_selectwirelessdisplay&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setBackgroundResource&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;drawable&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;button_red&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;// ...&lt;/span&gt;

    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;// We check the state of the external displays, update the text of the display button, and if there is only&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// one external display, we auto select it&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;checkDisplay&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;TextView&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;displayButton&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nc&quot;&gt;Display&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;displays&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mDisplayManager&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getDisplays&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DisplayManager&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;DISPLAY_CATEGORY_PRESENTATION&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;displays&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mActivity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getDislay&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;displayButton&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Select a wireless display&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;displays&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;mActivity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setDisplay&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;displays&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]);&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;displayButton&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Display selected &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;displays&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getName&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;mActivity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setDisplay&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;displayButton&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Connect to a wireless display&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;// Methods called when a display is added or removed. We change the button state if we add or remove a&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// display, and we stop the presentation if there is a display removed.&lt;/span&gt;

    &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onDisplayAdded&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;displayId&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;checkLaunchable&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getView&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onDisplayChanged&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;displayId&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onDisplayRemoved&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;displayId&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mActivity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getDislay&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;displayId&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mActivity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getDislay&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getDisplayId&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;mActivity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;stopPresentation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;checkLaunchable&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getView&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;a name=&quot;selection-display-42&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;2-la-sélection-du-display&quot;&gt;2. La sélection du Display&lt;/h3&gt;

&lt;p&gt;Comme décrit plus haut, le bouton de sélection du &lt;strong&gt;Display&lt;/strong&gt; va évoluer en fonction des &lt;strong&gt;Display&lt;/strong&gt;s connectés à l’appareil :&lt;/p&gt;

&lt;p&gt;Si aucun &lt;strong&gt;Display&lt;/strong&gt; n’est connecté, le bouton affiche &lt;strong&gt;&lt;em&gt;Connect to a wireless display&lt;/em&gt;&lt;/strong&gt;. Si l’utilisateur clique dessus, le code suivant est appelé. La fenêtre des paramètres d’affichage du téléphone est alors affiché. Si l’appareil est compatible Wireless Display, un bouton &lt;strong&gt;Screen mirroring&lt;/strong&gt;, ou &lt;strong&gt;Wireless Display&lt;/strong&gt; ou une traduction devrait apparaitre (cf image ci dessous). En cliquant dessus, la liste des appareils visibles compatible Miracast apparait. L’utilisateur n’a plus qu’à cliquer dessus pour s’y connecter.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;displays&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// If there is no external display connected, we launch the Display settings. We could launch the Wifi display&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// settings with ACTION_WIFI_DISPLAY_SETTINGS but it is a hidden static value because there may be not such settings&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// (if the device does not have Wireless display but have API &amp;gt;= 17).&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;startActivity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Intent&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Settings&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;ACTION_DISPLAY_SETTINGS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;));&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;img src=&quot;https://cmoatoto.com/assets/images/miraslide_connect.png&quot; alt=&quot;Connecting a Wireless Display on Android&quot; style=&quot;width: 800px; margin-left: auto; margin-right: auto&quot; /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Si un seul &lt;strong&gt;Display&lt;/strong&gt; est connecté, ou si un &lt;strong&gt;Display&lt;/strong&gt; a déjà été sélectionné, le bouton affiche &lt;strong&gt;&lt;em&gt;Display selected NOM_DU_DISPLAY&lt;/em&gt;&lt;/strong&gt;. Si l’utilisateur clique dessus, le même code que lors du cas où plusieurs &lt;strong&gt;Display&lt;/strong&gt;s sont connectés est executé.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Si plusieurs &lt;strong&gt;Display&lt;/strong&gt;s sont connectés, le bouton affiche &lt;strong&gt;&lt;em&gt;Select a wireless display&lt;/em&gt;&lt;/strong&gt;. Si l’utilisateur clique dessus, le code suivant est appelé. Une &lt;strong&gt;Dialog&lt;/strong&gt; box s’ouvre, listant la liste des &lt;strong&gt;Display&lt;/strong&gt;s disponibles. Si l’utilisateur clique sur un des &lt;strong&gt;Display&lt;/strong&gt;s, ce dernier est alors sélectionné et on se retrouve dans le cas précédent.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;c1&quot;&gt;// If there is one or more external display, we show a dialog box with the list of the display.&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// The user can select the display he wants, or close the dialog.&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;final&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ArrayAdapter&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;arrayAdapter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ArrayAdapter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mActivity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;android&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;layout&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;select_dialog_singlechoice&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;displays&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;arrayAdapter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;displays&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getName&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

 &lt;span class=&quot;nc&quot;&gt;AlertDialog&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;Builder&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;builder&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;AlertDialog&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;Builder&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mActivity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setIcon&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;drawable&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;ic_launcher&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setTitle&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Select a display&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setNegativeButton&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;cancel&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setAdapter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;arrayAdapter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;DialogInterface&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;OnClickListener&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

            &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
            &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DialogInterface&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dialog&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;which&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;c1&quot;&gt;// When the user choose a display through the dialog, we set it in the parent Activity and update&lt;/span&gt;
                &lt;span class=&quot;c1&quot;&gt;// the state of the buttons.&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;mActivity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setDisplay&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;displays&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;which&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]);&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;checkLaunchable&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getView&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;});&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;a name=&quot;creation-affichage-43&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;3-la-création-et-laffichage-de-la-presentation&quot;&gt;3. La création et l’affichage de la Presentation&lt;/h3&gt;

&lt;p&gt;Lorsque le &lt;strong&gt;Display&lt;/strong&gt; est sélectionné, ainsi qu’un fichier PDF, le bouton &lt;strong&gt;&lt;em&gt;Launch Projection&lt;/em&gt;&lt;/strong&gt; est activé. Lorsque l’utilisateur clique dessus, la &lt;strong&gt;Presentation&lt;/strong&gt; est créée et affichée. On bascule alors l’utilisateur sur la vue &lt;strong&gt;Controller&lt;/strong&gt;. Voici le code exécuté :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;c1&quot;&gt;// SelectionFragment.java&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// ...&lt;/span&gt;


&lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;View&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getId&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;fragment_selection_button_launchprojection&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// On click on the &quot;launch projection&quot; button, we... launch the projection&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;mActivity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;launchPresentation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;c1&quot;&gt;// MainActivity.java&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// ...&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Set the presentation (created in the selection fragment). This method creates listeners to control the visibility of the controller fragment and if the&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// mShowHideControllerActionBarButton should be enabled. Then it shows the presentation.&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;//&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// @param presentation : the presentation to show&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;//&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;launchPresentation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;mPresentation&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;PdfViewerPresentation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mDisplay&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mPdfPath&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;mPresentation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setOnShowListener&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;OnShowListener&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

        &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onShow&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DialogInterface&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dialog&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

            &lt;span class=&quot;n&quot;&gt;showHideController&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;enableShowHideControllerActionBarButton&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;mControllerFragment&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;notifyViewPager&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;});&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;mPresentation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setOnDismissListener&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;OnDismissListener&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

        &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onDismiss&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;DialogInterface&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dialog&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;showHideController&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;enableShowHideControllerActionBarButton&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;});&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;mPresentation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;L’initialisation de la &lt;strong&gt;Presentation&lt;/strong&gt; est très simple mais le code peut paraître un peu compliqué. Ceci est dû à la préparation du PDF et de son affichage. Ce qu’il faut retenir est que l’initialisation se fait dans le constructeur, et que la création de la vue à afficher, et l’affichage du premier slide, se fait dans le &lt;strong&gt;&lt;em&gt;OnCreate(Bundle)&lt;/em&gt;&lt;/strong&gt;, et est appliqué grâce à la méthode &lt;strong&gt;&lt;em&gt;setContentView(View)&lt;/em&gt;&lt;/strong&gt;. Voici le code très simplifié.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;c1&quot;&gt;// PdfViewerPresentation.java&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// ...&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Constructor. It creates the Presentation, then load the display info and the Pdf to show&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;PdfViewerPresentation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Context&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Display&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pdfFilePath&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;mPdfFilePath&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pdfFilePath&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;// ...&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Bundle&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;savedInstanceState&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;savedInstanceState&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;createContentView&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;showPage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Create the imageView to show the pdf pages Bitmaps&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;createContentView&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;mImageView&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ImageView&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;getLayoutInflater&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;inflate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;layout&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;presentation_main&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;setContentView&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mImageView&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Show the current page on the Presentation view&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;showPage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;mImageView&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setImageBitmap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getPage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mPage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;));&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// return the Bitmap of the pdf specified page&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Bitmap&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getPage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;// ...&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;a name=&quot;controle-presentation-44&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;4-le-contrôle-de-la-presentation&quot;&gt;4. Le contrôle de la Presentation&lt;/h3&gt;

&lt;p&gt;Une fois la &lt;strong&gt;Presentation&lt;/strong&gt; lancée, l’utilisateur peut la contrôler grâce au &lt;strong&gt;ControllerFragment&lt;/strong&gt;. Ce dernier comprend un &lt;strong&gt;ViewPager&lt;/strong&gt; qui affiche les slides du PDF. Lorsque l’utilisateur change de slide (soit en faisant glisser, soit en appuyant sur les boutons &lt;em&gt;Précédent&lt;/em&gt; et &lt;em&gt;Suivant&lt;/em&gt;), le &lt;strong&gt;ControllerFragment&lt;/strong&gt; prévient l’&lt;strong&gt;Activity&lt;/strong&gt; parente du nouveau slide sélectionné, et l’&lt;strong&gt;Activity&lt;/strong&gt; fait remonter l’information à la &lt;strong&gt;Presentation&lt;/strong&gt; afin qu’elle se mette à jour. Voici le code correspondant :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;c1&quot;&gt;// ControllerFragment.java&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// ...&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// We create the viewpager which shows the pages of the pdf file. If the user changes the slide, the listeners&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// updates tell the parent Activity to change the image in the presentation.&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;//&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// @param v : the fragment view&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;//&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;createViewPager&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;View&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;mSlidesPagerAdapter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SlidesPagerAdapter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(((&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;FragmentActivity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;getActivity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getSupportFragmentManager&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;mSlidesViewPager&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;ViewPager&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;findViewById&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;fragment_controller_pager&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;mSlidesViewPager&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setAdapter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mSlidesPagerAdapter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;mSlidesViewPager&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setOnPageChangeListener&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SimpleOnPageChangeListener&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

        &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onPageSelected&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;MainActivity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;getActivity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getPresentation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;moveTo&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;});&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;View&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getId&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;fragment_controller_button_pageprev&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// On click on the prev button, we move the viewpager one slide back (which will move the presentation slide as well)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;mSlidesViewPager&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setCurrentItem&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mSlidesViewPager&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getCurrentItem&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getId&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;fragment_controller_button_pagenext&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// On click on the next button, we move the viewpager one slide next (which will move the presentation slide as well)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;mSlidesViewPager&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setCurrentItem&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mSlidesViewPager&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getCurrentItem&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;c1&quot;&gt;// MainActivity.java&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// ...&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// return the Presentation if it has been created. A presentation needs a display and a pdf file&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;PdfViewerPresentation&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getPresentation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mPresentation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;c1&quot;&gt;// PdfViewerPresentation.java&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// ...&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Move the presentation to the page &apos;page&apos;&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;moveTo&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;page&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;page&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;getPageCount&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;mPage&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;showPage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Show the current page on the Presentation view&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;showPage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;mImageView&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setImageBitmap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getPage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mPage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;));&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// return the Bitmap of the pdf specified page&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Bitmap&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getPage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;// ...&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;a name=&quot;conclusion-5&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Développer une application exploitant les écrans externes n’est vraiment pas compliqué sous Android. Le framework est simple et fonctionne bien. Cependant, l’application développée, malgré son potentiel, est très loin de repousser le WiDi dans ses retranchements, comme pourrait le faire une application de jeu 3D, ou de streaming vidéo. Enfin, il existe une partie de l’API sur le Wireless Display qui est actuellement cachée dans le code Android et non disponible dans le SDK. Cette API permet de contrôler soi-même la découverte et la connexion aux écrans externes. L’exploitation de cette API est donc dangereuse car elle peut évoluer sans prévenir ou bien ne pas fonctionner comme espéré d’un appareil à un autre. Cependant, si cela est bien fait, l’exploitation de cette API peut simplifier grandement l’utilisation de l’application par l’utilisateur.&lt;/p&gt;

&lt;p&gt;&lt;a name=&quot;sources-6&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;sources&quot;&gt;Sources&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;http://www.youtube.com/watch?v=gZopNFkeHH4&quot;&gt;présentation du WiDi pour Android&lt;/a&gt; par &lt;a href=&quot;http://ph0b.com/&quot;&gt;Xavier Hallade&lt;/a&gt; (&lt;a href=&quot;http://fr.slideshare.net/bemyapp/wi-di-android-applications-development&quot;&gt;slides&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://developer.android.com/index.html&quot;&gt;le site de développement Android&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/CmoaToto/MiraSlide&quot;&gt;Code source du projet MiraSlide&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://play.google.com/store/apps/details?id=fr.cmoatoto.miraslide&quot;&gt;Page Google Play de l’application&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Sat, 14 Dec 2013 12:00:00 +0000</pubDate>
        <link>https://cmoatoto.com/2013/12/14/miraslide-dev-une-app-miracast.html</link>
        <guid isPermaLink="true">https://cmoatoto.com/2013/12/14/miraslide-dev-une-app-miracast.html</guid>
        
        <category>android</category>
        
        <category>miracast</category>
        
        <category>application</category>
        
        <category>french</category>
        
        <category>tutorial</category>
        
        
      </item>
    
      <item>
        <title>Stuff I did during my studies</title>
        <description>&lt;p&gt;What I did from 2008 to 2009 during my studies?&lt;/p&gt;

&lt;p&gt;It was the 2nd of my 3 years of engineering school, at the &lt;em&gt;Institut Supérieur de l’Électronique et du Numérique&lt;/em&gt; (ISEN), in Brest, France, in a &lt;strong&gt;software engineering specialization&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Between partying, sleeping in class or working on my personal projects, I also did some stuff in order to have my degree. Here is two of my last works.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;database-project&quot;&gt;Database project&lt;/h2&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Deployment of an incident tickets management system The purpose of this project was the study of a database management system *(SGBD)*, and the design and development of a website managing incident tickets, with users and administrators access. The *SGBD* used here was **MySQL**, and the website was coded with **PHP**, **HTML** (4), **CSS** (2) and some hidden **javascript**.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href=&quot;https://drive.google.com/file/d/0B0HTe73HF5BcOUs4azJJTjE1cWc/view?usp=sharing&quot;&gt;You can retrieve the report here&lt;/a&gt; (in full French)&lt;/p&gt;

&lt;h2 id=&quot;virtual-lab-project&quot;&gt;Virtual Lab project&lt;/h2&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Deployment of the Virtual Lab, part of the project Emulaction
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;In june 2004, a study has been done concerning the students of the ISEN-Brest in order to better understand the way they use their laptops. This study revealed that 80% of the time they used their computer was for surfing on the internet, doing school work or playing video games. From this study was born the idea to create a &lt;strong&gt;system of learning through an online video-gaming tool&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In 2005, the ISEN set up a &lt;strong&gt;Virtual Electronic Laboratory&lt;/strong&gt; (VELab), in order to give the users the possibility to do electronics  experiments in a 3D environment, on the web. Very innovative and answering most of the needs, it still has some problems: the user  had to install the 3D rendering plugin , and the Java plugin creating the link to the server. Moreover, the techno used in 2005 were, in 2008, obsolete, as the Microsoft Java virtual machine.&lt;/p&gt;

&lt;p&gt;The Virtual Lab was &lt;strong&gt;developed in VRML&lt;/strong&gt; and the sharing of the labs between several users used an &lt;strong&gt;obsolete technology: Deepmatrix&lt;/strong&gt;. The work asked was to find a way to make the virtual laboratory up to date and usable.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://drive.google.com/file/d/0B0HTe73HF5BcS0NhZVJZZGhBQmM/view?usp=sharing&quot;&gt;You can retrieve the report here&lt;/a&gt; (in full French)&lt;/p&gt;
</description>
        <pubDate>Tue, 01 Jun 2010 12:00:00 +0000</pubDate>
        <link>https://cmoatoto.com/2010/06/01/what-i-did-studies.html</link>
        <guid isPermaLink="true">https://cmoatoto.com/2010/06/01/what-i-did-studies.html</guid>
        
        <category>isen</category>
        
        <category>studies</category>
        
        <category>web</category>
        
        <category>development</category>
        
        <category>english</category>
        
        <category>whatidid</category>
        
        
      </item>
    
      <item>
        <title>AcceSnake : Learn Symbian OS through a great Snake game development</title>
        <description>&lt;p&gt;What I did from 2008 to 2009? I was bored so I learned &lt;strong&gt;Python&lt;/strong&gt; and &lt;strong&gt;Symbian OS&lt;/strong&gt; development and created a popular Snake game using the accelerometer.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#why-1&quot;&gt;Why?&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#accesnake-2&quot;&gt;AcceSnake : A Snake Game using the accelerometer&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#end-3&quot;&gt;End of the project&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;#links-4&quot;&gt;Links&lt;/a&gt;&lt;/p&gt;

  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a name=&quot;why-1&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;why&quot;&gt;Why?&lt;/h2&gt;

&lt;p&gt;During summer 2008, I worked 1 month in England (I’m French), mentoring teenagers during their English class trip. Main of my work was to wait during their English lessons. At that time, I didn’t have a computer with me, but a great &lt;strong&gt;Nokia N95 8Go&lt;/strong&gt; under &lt;strong&gt;Symbian v5&lt;/strong&gt;. This awesome smartphone had no touchscreen but &lt;strong&gt;a nice T9 keyboard&lt;/strong&gt;, plus many navigation buttons (11 keys, with the D-pad). It’s &lt;strong&gt;2,8 inches screen&lt;/strong&gt; (240x320px) was pretty big at this time. And the great thing was all the new sensors we were not familiar with. GPS, 5MP Camera, TvOutput, a fast 332MHz Dual CPU and it’s proper 3D Graphics HW Accelerator GPU! But the awesomeness was &lt;strong&gt;the accelerometer&lt;/strong&gt;. It was so brand new that there was no released driver for… and so no game, no application, nothing using it. But the specs said it was there!&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://cmoatoto.com/assets/images/accesnake_n958gb.jpg&quot; alt=&quot;N95 8GB&quot; style=&quot;width: 400px; margin-left: auto; margin-right: auto&quot; /&gt;&lt;/p&gt;

&lt;p&gt;So there was this game, &lt;strong&gt;3D snake&lt;/strong&gt;, a great snake game reborn. I spent all my time on it and finished it once, twice then was bored. I was even more bored because the game was great but it didn’t use 2 things I wanted in it: an accelerometer control, and a 360° liberty of move.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://cmoatoto.com/assets/images/accesnake_snake3d.jpg&quot; alt=&quot;Snake 3D&quot; style=&quot;width: 200px; margin-left: auto; margin-right: auto&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Then what to do when you want something you don’t have? You make it! But &lt;em&gt;I didn’t have computer with me&lt;/em&gt;, and no data most of the time. So I texted my brother who know well computer science and asked what can I do. &lt;em&gt;“Learn Python, and find an interpreter.”&lt;/em&gt;. So I did. I found almost immediately an awesome small community of Symbian developers, &lt;strong&gt;an official (!!!) python interpreter and API made by Nokia&lt;/strong&gt;, and also, and that’s the great part, &lt;strong&gt;a leaked accelerometer driver&lt;/strong&gt; with it’s API made by the community. Then all I needed was a notepad (easy part, of course).&lt;/p&gt;

&lt;p&gt;&lt;a name=&quot;accesnake-2&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;accesnake--a-snake-game-using-the-accelerometer&quot;&gt;AcceSnake : A Snake Game using the accelerometer&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;https://cmoatoto.com/assets/images/accesnake_logo.png&quot; alt=&quot;AcceSnake logo&quot; style=&quot;width: 200px; margin-left: auto; margin-right: auto&quot; /&gt;&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;a href=&quot;https://code.google.com/p/accesnake/downloads/list&quot;&gt;Source code and download page&lt;/a&gt;&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;a href=&quot;http://cmoatoto.fr/accesnake.html&quot;&gt;Official page of the game&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;AcceSnake is a “Snake-like game” using the accelerometer of your phone.&lt;/p&gt;

  &lt;p&gt;Developed in Python, this game has been entirely coded with a text-editor, on a N95 8Go. I never used a computer to make it.&lt;/p&gt;

  &lt;p&gt;For the first time in a snake game, you can move in any direction, slow down, and accelerate just by moving the phone. You can cross your tail but don’t touch the wall or you will lose a life.&lt;/p&gt;

  &lt;p&gt;If you don’t have an accelerometer, or if you prefer to use the keyboard, just choose the right option.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I will not explain everything about the development. It’s not that interesting now. I did the first version during the summer, released it on &lt;strong&gt;october 2008&lt;/strong&gt; and release some new version &lt;strong&gt;until january 2009&lt;/strong&gt;. I did a lot of communication on game forums so I had quite a success.&lt;/p&gt;

&lt;p&gt;My last version was downloaded &lt;strong&gt;more than 50,000 times&lt;/strong&gt; on the &lt;a href=&quot;https://code.google.com/p/accesnake/downloads/list&quot;&gt;official download page&lt;/a&gt; and &lt;strong&gt;more than 200,000 times&lt;/strong&gt; on various specialized website.&lt;/p&gt;

&lt;p&gt;Here is some notes about the development:&lt;/p&gt;

&lt;hr /&gt;
&lt;p&gt;Free Open Source game available on &lt;a href=&quot;https://code.google.com/p/accesnake&quot;&gt;code.google&lt;/a&gt; and &lt;a href=&quot;cmoatoto.fr/accesnake&quot;&gt;CmoaToto.fr&lt;/a&gt;.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The goal was to actually learn mobile development&lt;/li&gt;
  &lt;li&gt;UI development (menus, dialog boxes, graphics…)&lt;/li&gt;
  &lt;li&gt;Management of UI and life of the game (gameLoop).&lt;/li&gt;
  &lt;li&gt;Plugin management (for accelerometer use).&lt;/li&gt;
  &lt;li&gt;Event management of the accelerometer.&lt;/li&gt;
  &lt;li&gt;Managing the distribution and advertising.&lt;/li&gt;
  &lt;li&gt;Internationalization (assisted by community for regionalization).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;https://cmoatoto.com/assets/images/accesnake_screenshot.png&quot; alt=&quot;AcceSnake logo&quot; style=&quot;width: 240px; margin-left: auto; margin-right: auto&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;a name=&quot;end-3&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;end-of-the-project&quot;&gt;End of the project&lt;/h2&gt;

&lt;p&gt;During february 2009, I rewrote all the code, using better Objects, creating &lt;strong&gt;multiplayer&lt;/strong&gt; gamemode, special funny things etc… &lt;strong&gt;I had an awesome v3 in my hands&lt;/strong&gt;. &lt;em&gt;Then I broke my phone&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;*sigh*&lt;/p&gt;

&lt;p&gt;So I bought a new one. a &lt;strong&gt;Nokia N96&lt;/strong&gt;. Without T9 but &lt;strong&gt;a complete landscape keyboard, a touchscreen, no D-pad, and with Symbian v6&lt;/strong&gt;. I had to rewrite everything to make it work.&lt;/p&gt;

&lt;p&gt;So I started…&lt;/p&gt;

&lt;p&gt;Then I stopped. &lt;em&gt;(but I started again, on Android, in december 2011 ;) )&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a name=&quot;links-4&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;links&quot;&gt;Links&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;http://cmoatoto.fr/accesnake.html&quot;&gt;Official website&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://cmoatoto.fr/presentation.html&quot;&gt;presentation&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://cmoatoto.fr/screenshot.html&quot;&gt;screenshots&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://cmoatoto.fr/installation.html&quot;&gt;installation&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://cmoatoto.fr/links.html&quot;&gt;links &amp;amp; help&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://cmoatoto.fr/highscore.php&quot;&gt;high scores&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href=&quot;https://code.google.com/p/accesnake&quot;&gt;Google Code&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Fri, 09 Jan 2009 12:00:00 +0000</pubDate>
        <link>https://cmoatoto.com/2009/01/09/what-i-did-accesnake.html</link>
        <guid isPermaLink="true">https://cmoatoto.com/2009/01/09/what-i-did-accesnake.html</guid>
        
        <category>symbian</category>
        
        <category>python</category>
        
        <category>application</category>
        
        <category>game</category>
        
        <category>english</category>
        
        <category>whatidid</category>
        
        
      </item>
    
  </channel>
</rss>
