डिटैचेबल कीबोर्ड के कॉन्फ़िगरेशन में किए गए बदलावों को मैनेज करना
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
जब भी किसी कीबोर्ड को डिवाइस से जोड़ा या हटाया जाता है, तब Android सिस्टम कॉन्फ़िगरेशन में बदलाव करता है. डिटैचेबल कीबोर्ड वाले बड़े स्क्रीन वाले डिवाइसों पर, उपयोगकर्ताओं को बेहतर अनुभव देने और उनकी प्रोडक्टिविटी बढ़ाने के लिए, आपके ऐप्लिकेशन को कीबोर्ड के कॉन्फ़िगरेशन में होने वाले बदलावों को असरदार तरीके से मैनेज करना होगा.
कीबोर्ड बदलने पर गतिविधि को फिर से शुरू होने से रोकना
डिटैचेबल कीबोर्ड को अटैच या डिटैच करने पर, अपनी गतिविधि को फिर से बनाने से रोकने के लिए, अपने ऐप्लिकेशन मेनिफ़ेस्ट के configChanges एट्रिब्यूट में कीबोर्ड से जुड़ी वैल्यू जोड़ें. साथ ही, गतिविधि की व्यू हैरारकी में एक व्यू जोड़ें, ताकि आपका ऐप्लिकेशन कॉन्फ़िगरेशन में हुए बदलावों को सुन सके.
1. configChanges एट्रिब्यूट की वैल्यू सबमिट करना
पहले से मैनेज किए जा रहे कॉन्फ़िगरेशन में हुए बदलावों की सूची में keyboard|keyboardHidden वैल्यू जोड़कर, ऐप्लिकेशन मेनिफ़ेस्ट में <activity> एलिमेंट को अपडेट करें:
android:configChanges: ऐप्लिकेशन मेनिफ़ेस्ट के <activity> एलिमेंट का एट्रिब्यूट. सिस्टम को कॉन्फ़िगरेशन में हुए उन बदलावों के बारे में बताता है जिन्हें ऐप्लिकेशन मैनेज करता है.
इस पेज पर मौजूद कॉन्टेंट और कोड सैंपल कॉन्टेंट के लाइसेंस में बताए गए लाइसेंस के हिसाब से हैं. Java और OpenJDK, Oracle और/या इससे जुड़ी हुई कंपनियों के ट्रेडमार्क या रजिस्टर किए हुए ट्रेडमार्क हैं.
आखिरी बार 2025-02-06 (UTC) को अपडेट किया गया.
[[["समझने में आसान है","easyToUnderstand","thumb-up"],["मेरी समस्या हल हो गई","solvedMyProblem","thumb-up"],["अन्य","otherUp","thumb-up"]],[["वह जानकारी मौजूद नहीं है जो मुझे चाहिए","missingTheInformationINeed","thumb-down"],["बहुत मुश्किल है / बहुत सारे चरण हैं","tooComplicatedTooManySteps","thumb-down"],["पुराना","outOfDate","thumb-down"],["अनुवाद से जुड़ी समस्या","translationIssue","thumb-down"],["सैंपल / कोड से जुड़ी समस्या","samplesCodeIssue","thumb-down"],["अन्य","otherDown","thumb-down"]],["आखिरी बार 2025-02-06 (UTC) को अपडेट किया गया."],[],[],null,["# Manage detachable keyboard configuration changes\n\n\u003cbr /\u003e\n\nThe Android system triggers a configuration change every time a keyboard is\nattached to or detached from a device. To ensure a seamless user experience and\nmaximize user productivity on large screen devices with detachable keyboards,\nyour app needs to effectively manage keyboard configuration changes.\n\nPrevent activity recreation on keyboard change\n----------------------------------------------\n\nTo prevent your activity from being recreated when a detachable keyboard is\nattached or detached, add keyboard-related values to the `configChanges`\nattribute of your app manifest and add a view to the activity's view hierarchy\nso your app can listen for configuration changes.\n\n### 1. Declare the `configChanges` attribute\n\nUpdate the `\u003cactivity\u003e` element in the app manifest by adding the\n`keyboard|keyboardHidden` values to the list of already managed configuration\nchanges: \n\n \u003cactivity\n ...\n android:configChanges=\"...|keyboard|keyboardHidden\"\u003e\n\n### 2. Add an empty view to the view hierarchy\n\nDeclare a new view and add your handler code inside the view's\n`onConfigurationChanged()` method: \n\n### Kotlin\n\n```kotlin\nval v = object : View(this) {\n override fun onConfigurationChanged(newConfig: Configuration?) {\n super.onConfigurationChanged(newConfig)\n // Handler code here.\n }\n}\n```\n\n### Java\n\n```java\nView v = new View(this) {\n @Override\n protected void onConfigurationChanged(Configuration newConfig) {\n super.onConfigurationChanged(newConfig);\n // Handler code here.\n }\n};\n```\n| **Note:** Compose-based hierarchies require the addition of a view because the view's configuration handler is the only method that is always called for configuration changes.\n\nKey points\n----------\n\n- [`android:configChanges`](/guide/topics/manifest/activity-element#config): Attribute of the app manifest's `\u003cactivity\u003e` element. Informs the system about configuration changes the app manages.\n- [`View#onConfigurationChanged()`](/develop/ui/compose/quick-guides/content/(/reference/kotlin/android/view/View#onconfigurationchanged)) : Method that reacts to propagation of a new app configuration.\n\nResults\n-------\n\nYour app now responds to an external keyboard being attached or detached\nwithout recreating the running activity.\n\nCollections that contain this guide\n-----------------------------------\n\nThis guide is part of these curated Quick Guide collections that cover\nbroader Android development goals: \n\n### Optimize for large screens\n\nEnable your app to support an optimized user experience on tablets, foldables, and ChromeOS devices. \n[Quick guide collection](/quick-guides/collections/optimize-for-large-screens) \n\nHave questions or feedback\n--------------------------\n\nGo to our frequently asked questions page and learn about quick guides or reach out and let us know your thoughts. \n[Go to FAQ](/quick-guides/faq) [Leave feedback](https://issuetracker.google.com/issues/new?component=1573691&template=1993320)"]]