{"id":3342,"date":"2017-06-27T12:01:47","date_gmt":"2017-06-27T10:01:47","guid":{"rendered":"http:\/\/www.benoitfreslon.com\/?p=3342"},"modified":"2024-07-28T09:13:26","modified_gmt":"2024-07-28T07:13:26","slug":"unity-get-the-max-android-volume-with-jni-without-native-plugin","status":"publish","type":"post","link":"https:\/\/benoitfreslon.com\/fr\/news\/unity-get-the-max-android-volume-with-jni-without-native-plugin\/","title":{"rendered":"Unity &#8211; Get the max android volume with JNI without native plugin"},"content":{"rendered":"<p class=\"qtranxs-available-languages-message qtranxs-available-languages-message-fr\">D\u00e9sol\u00e9, cet article est seulement disponible en <a href=\"https:\/\/benoitfreslon.com\/en\/wp-json\/wp\/v2\/posts\/3342\" class=\"qtranxs-available-language-link qtranxs-available-language-link-en\" title=\"English\">English<\/a>.<\/p><p>In the <a href=\".\/2017\/06\/unity-get-current-android-volume-jni-with-no-plugin\/\">previous post<\/a> we learn how to get the current volume.<\/p>\n<p>As I said the max volume can be different according the OS version or de device.<\/p>\n<p>Now let&rsquo;s get the max volume in c# without native plugin:<\/p>\n<pre class=\"lang:default decode:true\" title=\"Get the max volume value of an Android device\">public int GetMaxVolume ()\r\n{\r\n\tAndroidJavaObject currentActivity = unityPlayerClass.GetStatic ( \"currentActivity\" );\r\n\tAndroidJavaObject packageManager = currentActivity.Call ( \"getPackageManager\" );\r\n\tAndroidJavaObject context = currentActivity.Call ( \"getApplicationContext\" );\r\n\tAndroidJavaClass audioManagerClass = new AndroidJavaClass ( \"android.media.AudioManager\" );\r\n\tAndroidJavaClass contextClass = new AndroidJavaClass ( \"android.content.Context\" );\r\n\tint AudioManager_STREAM_MUSIC = audioManagerClass.GetStatic&lt;int&gt; ( \"STREAM_MUSIC\" );\r\n\tstring Context_AUDIO_SERVICE = contextClass.GetStatic&lt;string&gt; ( \"AUDIO_SERVICE\" );\r\n\tAndroidJavaObject systemService = context.Call&lt;AndroidJavaObject&gt; ( \"getSystemService\", Context_AUDIO_SERVICE );\r\n\treturn systemService.Call&lt;int&gt; ( \"getStreamMaxVolume\", AudioManager_STREAM_MUSIC );\r\n}<\/pre>\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>D\u00e9sol\u00e9, cet article est seulement disponible en English.In the previous post we learn how to get the current volume. As&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1,390],"tags":[306,291,323,322,309,325,270,324],"class_list":["post-3342","post","type-post","status-publish","format-standard","hentry","category-news","category-tutorial","tag-android","tag-c","tag-java","tag-jni","tag-plugin","tag-sound","tag-unity","tag-volume","wpcat-1-id","wpcat-390-id"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Unity - Get the max android volume with JNI without native plugin - Beno\u00eet Freslon<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/benoitfreslon.com\/fr\/news\/unity-get-the-max-android-volume-with-jni-without-native-plugin\/\" \/>\n<meta name=\"twitter:label1\" content=\"\u00c9crit par\" \/>\n\t<meta name=\"twitter:data1\" content=\"Benoit Freslon\" \/>\n\t<meta name=\"twitter:label2\" content=\"Dur\u00e9e de lecture estim\u00e9e\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/benoitfreslon.com\\\/news\\\/unity-get-the-max-android-volume-with-jni-without-native-plugin\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/benoitfreslon.com\\\/news\\\/unity-get-the-max-android-volume-with-jni-without-native-plugin\\\/\"},\"author\":{\"name\":\"Benoit Freslon\",\"@id\":\"https:\\\/\\\/benoitfreslon.com\\\/#\\\/schema\\\/person\\\/fe9fe28a6b6c2b56648448b977fd6b78\"},\"headline\":\"Unity &#8211; Get the max android volume with JNI without native plugin\",\"datePublished\":\"2017-06-27T10:01:47+00:00\",\"dateModified\":\"2024-07-28T07:13:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/benoitfreslon.com\\\/news\\\/unity-get-the-max-android-volume-with-jni-without-native-plugin\\\/\"},\"wordCount\":53,\"keywords\":[\"Android\",\"c#\",\"java\",\"jni\",\"plugin\",\"sound\",\"unity\",\"volume\"],\"articleSection\":[\"Actualit\u00e9s\",\"Tutoriels\"],\"inLanguage\":\"fr-FR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/benoitfreslon.com\\\/fr\\\/news\\\/unity-get-the-max-android-volume-with-jni-without-native-plugin\\\/\",\"url\":\"https:\\\/\\\/benoitfreslon.com\\\/fr\\\/news\\\/unity-get-the-max-android-volume-with-jni-without-native-plugin\\\/\",\"name\":\"Unity - Get the max android volume with JNI without native plugin - Beno\u00eet Freslon\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/benoitfreslon.com\\\/fr\\\/#website\"},\"datePublished\":\"2017-06-27T10:01:47+00:00\",\"dateModified\":\"2024-07-28T07:13:26+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/benoitfreslon.com\\\/#\\\/schema\\\/person\\\/fe9fe28a6b6c2b56648448b977fd6b78\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/benoitfreslon.com\\\/fr\\\/news\\\/unity-get-the-max-android-volume-with-jni-without-native-plugin\\\/#breadcrumb\"},\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[[\"https:\\\/\\\/benoitfreslon.com\\\/fr\\\/news\\\/unity-get-the-max-android-volume-with-jni-without-native-plugin\\\/\"]]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/benoitfreslon.com\\\/fr\\\/news\\\/unity-get-the-max-android-volume-with-jni-without-native-plugin\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/benoitfreslon.com\\\/fr\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Unity &#8211; Get the max android volume with JNI without native plugin\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/benoitfreslon.com\\\/fr\\\/#website\",\"url\":\"https:\\\/\\\/benoitfreslon.com\\\/fr\\\/\",\"name\":\"Beno\u00eet Freslon\",\"description\":\"[:en]Game designer | D\u00e9veloppeur de jeux ind\u00e9pendant | Freelance | Enseignant | Blogueur[:fr]Game designer | Independent game developer | Freelance | Teacher | Blogger[:]\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/benoitfreslon.com\\\/fr\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fr-FR\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/benoitfreslon.com\\\/#\\\/schema\\\/person\\\/fe9fe28a6b6c2b56648448b977fd6b78\",\"name\":\"Benoit Freslon\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0b828da2527f91fb7c86dab67050492f4303279afa245d6e718ea1c6e6f00bb2?s=96&d=identicon&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0b828da2527f91fb7c86dab67050492f4303279afa245d6e718ea1c6e6f00bb2?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0b828da2527f91fb7c86dab67050492f4303279afa245d6e718ea1c6e6f00bb2?s=96&d=identicon&r=g\",\"caption\":\"Benoit Freslon\"},\"sameAs\":[\"https:\\\/\\\/benoitfreslon.com\",\"https:\\\/\\\/www.instagram.com\\\/benoitfreslon\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/benoitfreslon\",\"https:\\\/\\\/x.com\\\/BenoitFreslon\",\"https:\\\/\\\/www.youtube.com\\\/benoitfreslon\"],\"url\":\"https:\\\/\\\/benoitfreslon.com\\\/fr\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Unity - Get the max android volume with JNI without native plugin - Beno\u00eet Freslon","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/benoitfreslon.com\/fr\/news\/unity-get-the-max-android-volume-with-jni-without-native-plugin\/","twitter_misc":{"\u00c9crit par":"Benoit Freslon","Dur\u00e9e de lecture estim\u00e9e":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/benoitfreslon.com\/news\/unity-get-the-max-android-volume-with-jni-without-native-plugin\/#article","isPartOf":{"@id":"https:\/\/benoitfreslon.com\/news\/unity-get-the-max-android-volume-with-jni-without-native-plugin\/"},"author":{"name":"Benoit Freslon","@id":"https:\/\/benoitfreslon.com\/#\/schema\/person\/fe9fe28a6b6c2b56648448b977fd6b78"},"headline":"Unity &#8211; Get the max android volume with JNI without native plugin","datePublished":"2017-06-27T10:01:47+00:00","dateModified":"2024-07-28T07:13:26+00:00","mainEntityOfPage":{"@id":"https:\/\/benoitfreslon.com\/news\/unity-get-the-max-android-volume-with-jni-without-native-plugin\/"},"wordCount":53,"keywords":["Android","c#","java","jni","plugin","sound","unity","volume"],"articleSection":["Actualit\u00e9s","Tutoriels"],"inLanguage":"fr-FR"},{"@type":"WebPage","@id":"https:\/\/benoitfreslon.com\/fr\/news\/unity-get-the-max-android-volume-with-jni-without-native-plugin\/","url":"https:\/\/benoitfreslon.com\/fr\/news\/unity-get-the-max-android-volume-with-jni-without-native-plugin\/","name":"Unity - Get the max android volume with JNI without native plugin - Beno\u00eet Freslon","isPartOf":{"@id":"https:\/\/benoitfreslon.com\/fr\/#website"},"datePublished":"2017-06-27T10:01:47+00:00","dateModified":"2024-07-28T07:13:26+00:00","author":{"@id":"https:\/\/benoitfreslon.com\/#\/schema\/person\/fe9fe28a6b6c2b56648448b977fd6b78"},"breadcrumb":{"@id":"https:\/\/benoitfreslon.com\/fr\/news\/unity-get-the-max-android-volume-with-jni-without-native-plugin\/#breadcrumb"},"inLanguage":"fr-FR","potentialAction":[{"@type":"ReadAction","target":[["https:\/\/benoitfreslon.com\/fr\/news\/unity-get-the-max-android-volume-with-jni-without-native-plugin\/"]]}]},{"@type":"BreadcrumbList","@id":"https:\/\/benoitfreslon.com\/fr\/news\/unity-get-the-max-android-volume-with-jni-without-native-plugin\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/benoitfreslon.com\/fr\/"},{"@type":"ListItem","position":2,"name":"Unity &#8211; Get the max android volume with JNI without native plugin"}]},{"@type":"WebSite","@id":"https:\/\/benoitfreslon.com\/fr\/#website","url":"https:\/\/benoitfreslon.com\/fr\/","name":"Beno\u00eet Freslon","description":"[:en]Game designer | D\u00e9veloppeur de jeux ind\u00e9pendant | Freelance | Enseignant | Blogueur[:fr]Game designer | Independent game developer | Freelance | Teacher | Blogger[:]","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/benoitfreslon.com\/fr\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fr-FR"},{"@type":"Person","@id":"https:\/\/benoitfreslon.com\/#\/schema\/person\/fe9fe28a6b6c2b56648448b977fd6b78","name":"Benoit Freslon","image":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/secure.gravatar.com\/avatar\/0b828da2527f91fb7c86dab67050492f4303279afa245d6e718ea1c6e6f00bb2?s=96&d=identicon&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/0b828da2527f91fb7c86dab67050492f4303279afa245d6e718ea1c6e6f00bb2?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0b828da2527f91fb7c86dab67050492f4303279afa245d6e718ea1c6e6f00bb2?s=96&d=identicon&r=g","caption":"Benoit Freslon"},"sameAs":["https:\/\/benoitfreslon.com","https:\/\/www.instagram.com\/benoitfreslon","https:\/\/www.linkedin.com\/in\/benoitfreslon","https:\/\/x.com\/BenoitFreslon","https:\/\/www.youtube.com\/benoitfreslon"],"url":"https:\/\/benoitfreslon.com\/fr\/author\/admin\/"}]}},"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/pLAe3-RU","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/benoitfreslon.com\/fr\/wp-json\/wp\/v2\/posts\/3342","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/benoitfreslon.com\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/benoitfreslon.com\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/benoitfreslon.com\/fr\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/benoitfreslon.com\/fr\/wp-json\/wp\/v2\/comments?post=3342"}],"version-history":[{"count":6,"href":"https:\/\/benoitfreslon.com\/fr\/wp-json\/wp\/v2\/posts\/3342\/revisions"}],"predecessor-version":[{"id":39144,"href":"https:\/\/benoitfreslon.com\/fr\/wp-json\/wp\/v2\/posts\/3342\/revisions\/39144"}],"wp:attachment":[{"href":"https:\/\/benoitfreslon.com\/fr\/wp-json\/wp\/v2\/media?parent=3342"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/benoitfreslon.com\/fr\/wp-json\/wp\/v2\/categories?post=3342"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/benoitfreslon.com\/fr\/wp-json\/wp\/v2\/tags?post=3342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}