<فعالیت>

نحو:
<activity android:allowEmbedded=["true" | "false"]
          android:allowTaskReparenting=["true" | "false"]
          android:alwaysRetainTaskState=["true" | "false"]
          android:autoRemoveFromRecents=["true" | "false"]
          android:banner="drawable resource"
          android:canDisplayOnRemoteDevices=["true" | "false"]
          android:clearTaskOnLaunch=["true" | "false"]
          android:colorMode=[ "hdr" | "wideColorGamut"]
          android:configChanges=["colorMode", "density",
                                 "fontScale", "fontWeightAdjustment",
                                 "grammaticalGender", "keyboard",
                                 "keyboardHidden", "layoutDirection", "locale",
                                 "mcc", "mnc", "navigation", "orientation",
                                 "screenLayout", "screenSize",
                                 "smallestScreenSize", "touchscreen", "uiMode"]
          android:directBootAware=["true" | "false"]
          android:documentLaunchMode=["intoExisting" | "always" |
                                  "none" | "never"]
          android:enabled=["true" | "false"]
          android:enableOnBackInvokedCallback=["true" | "false"]
          android:excludeFromRecents=["true" | "false"]
          android:exported=["true" | "false"]
          android:finishOnTaskLaunch=["true" | "false"]
          android:forceQueryable=["true" | "false"]
          android:hardwareAccelerated=["true" | "false"]
          android:icon="drawable resource"
          android:immersive=["true" | "false"]
          android:intentMatchingFlags=["none" | "enforceIntentFilter" | "allowNullAction"]
          android:label="string resource"
          android:launchMode=["standard" | "singleTop" |
                              "singleTask" | "singleInstance" | "singleInstancePerTask"]
          android:lockTaskMode=["normal" | "never" |
                              "if_whitelisted" | "always"]
          android:maxRecents="integer"
          android:maxAspectRatio="float"
          android:minAspectRatio="float"
          android:multiprocess=["true" | "false"]
          android:name="string"
          android:noHistory=["true" | "false"]  
          android:parentActivityName="string" 
          android:persistableMode=["persistRootOnly" | 
                                   "persistAcrossReboots" | "persistNever"]
          android:permission="string"
          android:preferMinimalPostProcessing=["true" | "false"]
          android:process="string"
          android:recreateOnConfigChanges=["colorMode" | "keyboard" |
                                           "keyboardHidden" | "mcc" | "mnc" |
                                           "navigation" | "touchscreen"]
          android:relinquishTaskIdentity=["true" | "false"]
          android:requireContentUriPermissionFromCaller=["none" | "read" | "readAndWrite" |
                                                         "readOrWrite" | "write"] 
          android:resizeableActivity=["true" | "false"]
          android:screenOrientation=["unspecified" | "behind" |
                                     "landscape" | "portrait" |
                                     "reverseLandscape" | "reversePortrait" |
                                     "sensorLandscape" | "sensorPortrait" |
                                     "userLandscape" | "userPortrait" |
                                     "sensor" | "fullSensor" | "nosensor" |
                                     "user" | "fullUser" | "locked"]
          android:showForAllUsers=["true" | "false"]
          android:stateNotNeeded=["true" | "false"]
          android:supportsPictureInPicture=["true" | "false"]
          android:taskAffinity="string"
          android:theme="resource or theme"
          android:uiOptions=["none" | "splitActionBarWhenNarrow"]
          android:windowSoftInputMode=["stateUnspecified",
                                       "stateUnchanged", "stateHidden",
                                       "stateAlwaysHidden", "stateVisible",
                                       "stateAlwaysVisible", "adjustUnspecified",
                                       "adjustResize", "adjustPan"] >   
    ...
</activity>
مندرج در:
<application>
می‌تواند شامل موارد زیر باشد:
<intent-filter>
<meta-data>
<layout>
<property>
شرح:
یک فعالیت (یک زیرکلاس Activity ) را تعریف می‌کند که بخشی از رابط کاربری بصری برنامه را پیاده‌سازی می‌کند. همه فعالیت‌ها باید توسط عناصر <activity> در فایل manifest نمایش داده شوند. هر فعالیتی که در آنجا تعریف نشده باشد، توسط سیستم دیده نمی‌شود و هرگز اجرا نمی‌شود.
ویژگی‌ها:
android:allowEmbedded

نشان می‌دهد که اکتیویتی می‌تواند به عنوان فرزندِ تعبیه‌شده‌ی اکتیویتی دیگری راه‌اندازی شود، به خصوص در مواردی که فرزند در یک کانتینر، مانند یک Display متعلق به اکتیویتی دیگر، قرار دارد. به عنوان مثال، اکتیویتی‌هایی که برای اعلان‌های سفارشی Wear استفاده می‌شوند، این را اعلام می‌کنند تا Wear بتواند اکتیویتی را در جریان زمینه‌اش که در فرآیند دیگری قرار دارد، نمایش دهد.

مقدار پیش‌فرض این ویژگی false است.

android:allowTaskReparenting
اینکه آیا فعالیت می‌تواند از وظیفه‌ای که آن را آغاز کرده است به وظیفه‌ای که به آن وابستگی دارد، زمانی که آن وظیفه در مرحله بعدی قرار می‌گیرد، منتقل شود یا خیر. اگر بتواند منتقل شود، "true" و اگر در همان جایی که شروع شده باقی بماند، "false" است.

اگر این ویژگی تنظیم نشده باشد، مقداری که توسط ویژگی allowTaskReparenting مربوط به عنصر <application> تنظیم شده است، به فعالیت اعمال می‌شود. مقدار پیش‌فرض "false" است.

معمولاً وقتی یک فعالیت شروع می‌شود، با وظیفه‌ی فعالیتی که آن را شروع کرده مرتبط می‌شود و در تمام طول عمر خود در آنجا باقی می‌ماند. می‌توانید از این ویژگی استفاده کنید تا آن را مجبور کنید که وقتی وظیفه‌ی فعلی‌اش دیگر نمایش داده نمی‌شود، به وظیفه‌ای که به آن وابستگی دارد، دوباره والد شود. معمولاً، این ویژگی برای انتقال فعالیت‌های یک برنامه به وظیفه‌ی اصلی مرتبط با آن برنامه استفاده می‌شود.

برای مثال، اگر یک پیام ایمیل حاوی لینکی به یک صفحه وب باشد، کلیک روی لینک، یک activity را نمایش می‌دهد که می‌تواند صفحه را نمایش دهد. این activity توسط برنامه مرورگر تعریف شده است اما به عنوان بخشی از وظیفه ایمیل راه‌اندازی می‌شود. اگر به وظیفه مرورگر reparent شده باشد، وقتی مرورگر دوباره به جلو می‌آید، نمایش داده می‌شود و وقتی وظیفه ایمیل دوباره به جلو می‌آید، وجود ندارد.

وابستگی یک فعالیت توسط ویژگی taskAffinity تعریف می‌شود. وابستگی یک وظیفه با خواندن وابستگی فعالیت ریشه آن تعیین می‌شود. بنابراین، طبق تعریف، یک فعالیت ریشه همیشه در وظیفه‌ای با وابستگی یکسان قرار دارد. از آنجایی که فعالیت‌هایی با حالت‌های راه‌اندازی "singleTask" یا "singleInstance" فقط می‌توانند در ریشه یک وظیفه باشند، re-parenting به حالت‌های "standard" و "singleTop" محدود می‌شود. (همچنین به ویژگی launchMode مراجعه کنید.)

android:alwaysRetainTaskState
اینکه آیا وضعیت وظیفه‌ای که فعالیت در آن قرار دارد همیشه توسط سیستم حفظ می‌شود یا خیر. اگر چنین باشد، "true" و اگر سیستم بتواند در شرایط خاص، وظیفه را به حالت اولیه خود بازنشانی کند، "false "false" است. مقدار پیش‌فرض "false" است. این ویژگی فقط برای فعالیت ریشه یک وظیفه معنی‌دار است. برای سایر فعالیت‌ها نادیده گرفته می‌شود.

معمولاً، سیستم در شرایط خاصی که کاربر دوباره آن وظیفه را از صفحه اصلی انتخاب می‌کند، یک وظیفه را پاک می‌کند و تمام فعالیت‌های موجود در پشته بالای فعالیت ریشه را حذف می‌کند. معمولاً این کار در صورتی انجام می‌شود که کاربر برای مدت زمان مشخصی، مثلاً 30 دقیقه، از آن وظیفه بازدید نکرده باشد.

با این حال، وقتی این ویژگی "true" باشد، کاربران همیشه به آخرین وضعیت وظیفه برمی‌گردند، صرف نظر از اینکه چگونه به آنجا رسیده‌اند. این در برنامه‌هایی مانند مرورگر وب که در آنها وضعیت‌های زیادی مانند چندین تب باز وجود دارد که کاربران نمی‌خواهند آنها را از دست بدهند، مفید است.

android:autoRemoveFromRecents
آیا وظایفی که توسط فعالیتی با این ویژگی راه‌اندازی می‌شوند، تا زمان تکمیل آخرین فعالیت در آن وظیفه، در صفحه Recents باقی می‌مانند یا خیر. اگر true ، وظیفه به طور خودکار از صفحه Recents حذف می‌شود. این امر استفاده فراخواننده از FLAG_ACTIVITY_RETAIN_IN_RECENTS را لغو می‌کند. این مقدار باید یک مقدار بولی، یا "true" یا "false" باشد.
android:banner
یک منبع قابل ترسیم که یک بنر گرافیکی گسترده برای آیتم مرتبط با آن ارائه می‌دهد. از آن به همراه تگ <activity> برای ارائه یک بنر پیش‌فرض برای یک فعالیت خاص یا از آن به همراه تگ <application> برای ارائه یک بنر برای همه فعالیت‌های برنامه استفاده کنید.

سیستم از بنر برای نمایش یک برنامه در صفحه اصلی اندروید تی‌وی استفاده می‌کند. از آنجایی که بنر فقط در صفحه اصلی نمایش داده می‌شود، فقط توسط برنامه‌هایی که دارای فعالیتی هستند که هدف CATEGORY_LEANBACK_LAUNCHER را مدیریت می‌کند، مشخص می‌شود.

این ویژگی به عنوان مرجعی برای یک منبع قابل ترسیم حاوی تصویر، مانند "@drawable/banner" تنظیم می‌شود. هیچ بنر پیش‌فرضی وجود ندارد.

برای اطلاعات بیشتر، به بخش «ارائه بنر صفحه اصلی» در «شروع کار با برنامه‌های تلویزیونی» مراجعه کنید.

android:canDisplayOnRemoteDevices

نشان می‌دهد که آیا فعالیت می‌تواند روی یک دستگاه از راه دور که ممکن است اندروید را اجرا کند یا خیر، نمایش داده شود یا خیر. این مقدار باید یک مقدار بولی، یا "true" یا "false" باشد.

مقدار پیش‌فرض این ویژگی "true" است.

android:clearTaskOnLaunch
آیا هنگام اجرای مجدد وظیفه از صفحه اصلی، همه فعالیت‌ها، به جز فعالیت ریشه، از آن حذف می‌شوند یا خیر. اگر وظیفه همیشه به فعالیت ریشه‌اش محدود شود، "true" و اگر نه "false" را انتخاب کنید. مقدار پیش‌فرض "false" است. این ویژگی فقط برای فعالیت‌هایی که یک وظیفه جدید - فعالیت ریشه - را شروع می‌کنند، معنی‌دار است. برای سایر فعالیت‌های موجود در وظیفه نادیده گرفته می‌شود.

وقتی مقدار "true" باشد، هر بار که کاربران وظیفه را شروع می‌کنند، صرف نظر از اینکه آخرین بار در حال انجام چه کاری در وظیفه بوده‌اند و صرف نظر از اینکه از دکمه Back یا Home برای خروج از آن استفاده کرده‌اند یا خیر، به فعالیت ریشه آن هدایت می‌شوند. وقتی مقدار "false" باشد، در برخی شرایط، اما نه همیشه، می‌توان وظیفه را از فعالیت‌ها پاک کرد. برای اطلاعات بیشتر، به ویژگی alwaysRetainTaskState مراجعه کنید.

فرض کنید کاربر فعالیت P را از صفحه اصلی اجرا می‌کند و از آنجا به فعالیت Q می‌رود. کاربر سپس روی صفحه اصلی ضربه می‌زند و سپس به فعالیت P برمی‌گردد. معمولاً کاربر فعالیت Q را می‌بیند، زیرا این کاری است که آخرین بار در وظیفه P انجام داده است. با این حال، اگر P این پرچم را روی "true" تنظیم کند، تمام فعالیت‌های بالای آن - در این مورد، Q - هنگام اجرای فعالیت P از صفحه اصلی توسط کاربر حذف می‌شوند. بنابراین، کاربر هنگام بازگشت به وظیفه فقط P را می‌بیند.

اگر این ویژگی و allowTaskReparenting هر دو "true" باشند، هر فعالیتی که بتواند دوباره والد شود به وظیفه‌ای که با آن قرابت مشترک دارد منتقل می‌شود. سپس فعالیت‌های باقی‌مانده حذف می‌شوند.

اگر FLAG_ACTIVITY_RESET_TASK_IF_NEEDED تنظیم نشده باشد، این ویژگی نادیده گرفته می‌شود.

android:colorMode

حالت رنگ فعالیت را مشخص می‌کند. در صورت مشخص شدن، می‌تواند hdr یا wideColorGamut باشد.

اگر hdr ، درخواست می‌کند که فعالیت در محدوده دینامیکی بالا نمایش داده شود، البته اگر دستگاه از آن پشتیبانی کند.

اگر wideColorGamut درخواست کند که فعالیت در حالت طیف رنگ گسترده در دستگاه‌های سازگار نمایش داده شود. در حالت طیف رنگ گسترده، یک پنجره می‌تواند خارج از طیف رنگ SRGB رندر شود تا رنگ‌های پر جنب و جوش‌تری نمایش دهد. اگر دستگاه از رندر طیف رنگ گسترده پشتیبانی نمی‌کند، این ویژگی هیچ تاثیری ندارد. برای اطلاعات بیشتر در مورد رندر در حالت رنگ گسترده، به Enhance graphics with wide color content مراجعه کنید.

android:configChanges
تغییرات پیکربندی که اکتیویتی خودش مدیریت می‌کند را فهرست می‌کند. وقتی یک تغییر پیکربندی در زمان اجرا رخ می‌دهد، اکتیویتی به طور پیش‌فرض خاموش و مجدداً راه‌اندازی می‌شود، اما تعریف یک پیکربندی با این ویژگی از راه‌اندازی مجدد اکتیویتی جلوگیری می‌کند. در عوض، اکتیویتی در حال اجرا باقی می‌ماند و متد onConfigurationChanged() آن فراخوانی می‌شود.

توجه: از این ویژگی فقط در موارد خاص برای بهبود عملکرد و پاسخگویی برنامه استفاده کنید. برای اطلاعات بیشتر، به «مدیریت تغییرات پیکربندی» مراجعه کنید.

رشته‌های زیر مقادیر معتبری برای این ویژگی هستند. چندین مقدار با | از هم جدا می‌شوند، مانند "locale|navigation|orientation" .

ارزش توضیحات
"colorMode"

قابلیت‌های حالت رنگ صفحه نمایش (گستره رنگ یا محدوده دینامیکی) تغییر کرده‌اند.

نکته: حالت رنگی که اکتیویتی با استفاده از ویژگی colorMode یا در زمان اجرا درخواست می‌کند، با قابلیت حالت‌های رنگی مختلف متفاوت است. تغییر حالت رنگی که اکتیویتی استفاده می‌کند، باعث تغییر پیکربندی نمی‌شود، زیرا قابلیت‌های رنگی نمایشگر تغییر نکرده است.

"density"

تغییری در تراکم نمایشگر، مانند زمانی که کاربر مقیاس نمایشگر متفاوتی را مشخص می‌کند یا نمایشگر متفاوتی اکنون فعال است.

در سطح API 24 اضافه شد .

"fontScale" تغییر در ضریب مقیاس‌بندی فونت، مانند زمانی که کاربر یک اندازه فونت سراسری جدید انتخاب می‌کند.
"fontWeightAdjustment" میزان افزایش وزن فونت تغییر کرده است.
"grammaticalGender" جنسیت دستوری زبان تغییر کرده است. به GrammaticalInflectionManager مراجعه کنید.

در سطح API 34 اضافه شد .

"keyboard" تغییر در نوع صفحه کلید، مانند زمانی که کاربر یک صفحه کلید خارجی را وصل می‌کند.
"keyboardHidden" تغییر در دسترسی به صفحه کلید، مانند زمانی که کاربر صفحه کلید سخت افزاری را فاش می‌کند.
"layoutDirection"

تغییر در جهت طرح‌بندی، مثلاً از چپ به راست (LTR) به راست به چپ (RTL).

در سطح API 17 اضافه شد .

"locale" تغییر در زبان محلی، مانند زمانی که کاربر زبان جدیدی را انتخاب می‌کند که متن با آن زبان نمایش داده می‌شود.
"mcc" تغییر در کد کشور موبایل IMSI (MCC) هنگام شناسایی سیم‌کارتی که MCC را به‌روزرسانی می‌کند.
"mnc" تغییر در کد شبکه تلفن همراه IMSI (MNC) هنگام شناسایی سیم‌کارتی که MNC را به‌روزرسانی می‌کند.
"navigation" تغییر نوع ناوبری (ترک‌بال یا D-pad). معمولاً این اتفاق نمی‌افتد.
"orientation"

تغییر جهت صفحه نمایش، مانند زمانی که کاربر دستگاه را می‌چرخاند.

نکته: اگر برنامه شما اندروید ۳.۲ (سطح API ۱۳) یا بالاتر را هدف قرار می‌دهد، پیکربندی‌های "screenLayout" و "screenSize" را نیز تعریف کنید، زیرا طرح‌بندی صفحه و اندازه صفحه می‌توانند هنگام تغییر جهت دستگاه بین حالت عمودی و افقی تغییر کنند.

"screenLayout" تغییر در طرح‌بندی صفحه نمایش، مانند زمانی که یک نمایشگر متفاوت فعال می‌شود.
"screenSize"

تغییر در اندازه صفحه نمایش موجود فعلی.

این نشان دهنده تغییر در اندازه موجود فعلی، نسبت به نسبت ابعاد فعلی است، بنابراین وقتی کاربر بین حالت افقی و عمودی جابجا می‌شود، تغییر می‌کند.

در سطح API 13 اضافه شد .

"smallestScreenSize"

تغییر در اندازه فیزیکی صفحه نمایش.

این نشان‌دهنده تغییر در اندازه صرف نظر از جهت‌گیری است، بنابراین فقط زمانی تغییر می‌کند که اندازه فیزیکی واقعی صفحه نمایش تغییر کند، مانند تغییر به یک نمایشگر خارجی. تغییر در این پیکربندی معادل تغییر در پیکربندی کوچکترین عرض (the smallestWidth است.

در سطح API 13 اضافه شد .

"touchscreen" تغییر در حالت صفحه لمسی، مانند زمانی که کاربر یک وسیله جانبی ورودی را متصل یا جدا می‌کند یا برنامه را بین نمایشگرهای مختلف جابجا می‌کند.
"uiMode" تغییر در حالت رابط کاربری، مانند زمانی که کاربر دستگاه را روی میز یا داک ماشین قرار می‌دهد، یا تغییر حالت شب. برای اطلاعات بیشتر در مورد حالت‌های مختلف رابط کاربری، به UiModeManager مراجعه کنید.

در سطح API 8 اضافه شد .

تمام این تغییرات پیکربندی می‌توانند بر مقادیر منابع مشاهده شده توسط برنامه تأثیر بگذارند. بنابراین، هنگامی که onConfigurationChanged() فراخوانی می‌شود، معمولاً لازم است که دوباره تمام منابع، از جمله طرح‌بندی‌های نما و drawableها، بازیابی شوند تا تغییر به درستی مدیریت شود.

نکته: برای مدیریت تغییرات پیکربندی مربوط به چند پنجره ، از هر دو "screenLayout" و "smallestScreenSize" استفاده کنید. چند پنجره‌ای در اندروید ۷.۰ (سطح API 24) یا بالاتر پشتیبانی می‌شود.

android:directBootAware

اینکه آیا اکتیویتی از قابلیت بوت مستقیم (Direct-Boot) پشتیبانی می‌کند یا خیر - یعنی اینکه آیا می‌تواند قبل از باز کردن قفل دستگاه توسط کاربر اجرا شود.

نکته: در طول بوت مستقیم ، یک اکتیویتی در برنامه شما فقط می‌تواند به داده‌هایی که در حافظه محافظت‌شده دستگاه ذخیره شده‌اند، دسترسی داشته باشد.

مقدار پیش‌فرض "false" است.

android:documentLaunchMode
مشخص می‌کند که چگونه یک نمونه جدید از یک فعالیت هر بار که اجرا می‌شود به یک وظیفه اضافه شود. این ویژگی به کاربر اجازه می‌دهد چندین سند از یک برنامه مشابه را در صفحه Recents نمایش دهد.

این ویژگی چهار مقدار دارد که وقتی کاربر سندی را با برنامه باز می‌کند، اثرات زیر را ایجاد می‌کنند:

ارزش توضیحات
"intoExisting" سیستم به دنبال وظیفه‌ای می‌گردد که ComponentName و آدرس داده‌ی intent پایه‌اش با نام‌های intent راه‌اندازی‌شده مطابقت داشته باشد. اگر سیستم چنین وظیفه‌ای را پیدا کند، وظیفه را پاک کرده و مجدداً راه‌اندازی می‌کند و activity ریشه فراخوانی onNewIntent(android.content.Intent) را دریافت می‌کند. اگر سیستم چنین وظیفه‌ای را پیدا نکند، سیستم یک وظیفه جدید ایجاد می‌کند.
"always" این فعالیت یک وظیفه جدید برای سند ایجاد می‌کند، حتی اگر سند از قبل باز شده باشد. این همانند تنظیم هر دو پرچم FLAG_ACTIVITY_NEW_DOCUMENT و FLAG_ACTIVITY_MULTIPLE_TASK است.
"none" این فعالیت، وظیفه جدیدی برای فعالیت ایجاد نمی‌کند. این مقدار پیش‌فرض است و فقط زمانی که FLAG_ACTIVITY_NEW_TASK تنظیم شده باشد، وظیفه جدید ایجاد می‌کند. صفحه Recents با فعالیت به طور پیش‌فرض رفتار می‌کند: یک وظیفه واحد را برای برنامه نمایش می‌دهد که از هر فعالیتی که کاربر آخرین بار فراخوانی کرده است، از سر گرفته می‌شود.
"never" حتی اگر اینتنت شامل FLAG_ACTIVITY_NEW_DOCUMENT باشد، اکتیویتی در یک سند جدید اجرا نمی‌شود. تنظیم این مورد، رفتار پرچم‌های FLAG_ACTIVITY_NEW_DOCUMENT و FLAG_ACTIVITY_MULTIPLE_TASK را در صورتی که هر یک از این پرچم‌ها در اکتیویتی تنظیم شده باشند، لغو می‌کند و صفحه Recents یک وظیفه واحد را برای برنامه نمایش می‌دهد که از هر فعالیتی که کاربر آخرین بار فراخوانی کرده است، از سر گرفته می‌شود.

نکته: برای مقادیری غیر از "none" و "never" ، اکتیویتی با launchMode="standard" تعریف می‌شود. اگر این ویژگی مشخص نشده باشد، documentLaunchMode="none" استفاده می‌شود.

android:enabled
اینکه آیا فعالیت می‌تواند توسط سیستم نمونه‌سازی شود یا خیر. اگر بتواند "true" و در غیر این صورت "false" است. مقدار پیش‌فرض "true" است.

عنصر <application> ویژگی enabled به خود را دارد که به تمام اجزای برنامه، از جمله فعالیت‌ها، اعمال می‌شود. ویژگی‌های <application> و <activity> باید هر دو "true" باشند، زیرا هر دو به طور پیش‌فرض هستند تا سیستم بتواند فعالیت را نمونه‌سازی کند. اگر هر کدام "false" باشد، نمی‌توان آن را نمونه‌سازی کرد.

android:enableOnBackInvokedCallback

این پرچم به شما امکان می‌دهد از انیمیشن‌های سیستم پیش‌بینی‌کننده در سطح فعالیت انصراف دهید.

برای غیرفعال کردن انیمیشن‌های پیش‌بینی‌کننده‌ی بازگشت به عقب در سطح فعالیت و دستور دادن به سیستم که فراخوانی‌های API پلتفرم OnBackInvokedCallback نادیده بگیرد، android:enableOnBackInvokedCallback=false را تنظیم کنید.

android:excludeFromRecents

اینکه آیا وظیفه آغاز شده توسط این فعالیت از صفحه Recents حذف شده است یا خیر. یعنی، وقتی این فعالیت، فعالیت ریشه یک وظیفه جدید است، این ویژگی تعیین می‌کند که آیا وظیفه در لیست برنامه‌های اخیر ظاهر می‌شود یا خیر. اگر وظیفه از لیست حذف شده باشد، "true" و اگر شامل شود، "false" است. مقدار پیش‌فرض "false" است.

android:exported

اینکه آیا اکتیویتی می‌تواند توسط کامپوننت‌های برنامه‌های دیگر راه‌اندازی شود یا خیر:

  • اگر "true" ، اکتیویتی برای هر برنامه‌ای قابل دسترسی است و با نام دقیق کلاس خود قابل اجرا است.
  • اگر "false" ، فعالیت فقط می‌تواند توسط اجزای همان برنامه، برنامه‌هایی با شناسه کاربری یکسان یا اجزای سیستم دارای امتیاز بالا راه‌اندازی شود. این مقدار پیش‌فرض زمانی است که هیچ فیلتر intent وجود ندارد.

اگر یک اکتیویتی در برنامه شما شامل فیلترهای intent است، این عنصر را روی "true" تنظیم کنید تا سایر برنامه‌ها بتوانند آن را اجرا کنند. برای مثال، اگر اکتیویتی، اکتیویتی اصلی برنامه است و شامل category android.intent.category.LAUNCHER می‌شود.

اگر این عنصر روی "false" تنظیم شده باشد و یک برنامه سعی کند activity را شروع کند، سیستم یک ActivityNotFoundException صادر می‌کند.

این ویژگی تنها راه برای محدود کردن نمایش یک فعالیت به سایر برنامه‌ها نیست. مجوزها همچنین برای محدود کردن موجودیت‌های خارجی که می‌توانند فعالیت را فراخوانی کنند، استفاده می‌شوند. به ویژگی permission مراجعه کنید.

android:finishOnTaskLaunch
آیا یک نمونه موجود از اکتیویتی، به جز اکتیویتی ریشه، هنگامی که کاربر با انتخاب وظیفه در صفحه اصلی، آن را دوباره اجرا می‌کند، خاموش می‌شود یا خیر. اگر خاموش باشد، "true" و در غیر این صورت "false" است. مقدار پیش‌فرض "false" است.

اگر این ویژگی و allowTaskReparenting هر دو "true" باشند، این ویژگی بر دیگری برتری دارد. وابستگی فعالیت نادیده گرفته می‌شود. فعالیت دوباره والد نمی‌شود، بلکه از بین می‌رود.

اگر FLAG_ACTIVITY_RESET_TASK_IF_NEEDED تنظیم نشده باشد، این ویژگی نادیده گرفته می‌شود.

android:forceQueryable

مشخص می‌کند که آیا این فعالیت برای همه برنامه‌های دیگر روی دستگاه قابل مشاهده است یا خیر، و محدودیت‌های معمول مشاهده بسته را دور می‌زند.

مقدار پیش‌فرض "false" است.

برای اطلاعات بیشتر، به راهنمای فیلترینگ خودکار قابلیت مشاهده بسته‌ها مراجعه کنید.

android:hardwareAccelerated
اینکه آیا رندرینگ با شتاب‌دهنده سخت‌افزاری برای این فعالیت فعال است یا خیر. اگر فعال باشد "true" و اگر فعال نباشد "false" . مقدار پیش‌فرض "false" است.

در اندروید ۳.۰ و بالاتر، یک رندرکننده OpenGL با شتاب‌دهنده سخت‌افزاری برای برنامه‌ها در دسترس است تا عملکرد بسیاری از عملیات رایج گرافیک دوبعدی را بهبود بخشد. هنگامی که رندرکننده با شتاب‌دهنده سخت‌افزاری فعال باشد، اکثر عملیات در Canvas، Paint، Xfermode، ColorFilter، Shader و Camera شتاب می‌گیرند.

این امر منجر به انیمیشن‌های روان‌تر، پیمایش روان‌تر و بهبود کلی پاسخگویی می‌شود، حتی برای برنامه‌هایی که صراحتاً از کتابخانه‌های OpenGL این فریم‌ورک استفاده نمی‌کنند. به دلیل افزایش منابع مورد نیاز برای فعال کردن شتاب‌دهنده سخت‌افزاری، برنامه شما رم بیشتری مصرف می‌کند.

همه عملیات OpenGL 2D شتاب نمی‌گیرند. اگر رندرکننده سخت‌افزاری شتاب‌دهنده را فعال می‌کنید، آزمایش کنید که آیا برنامه شما می‌تواند بدون خطا از رندرکننده استفاده کند یا خیر.

android:icon

آیکونی که نشان‌دهنده‌ی فعالیت است. این آیکون زمانی به کاربران نمایش داده می‌شود که نمایشی از فعالیت روی صفحه مورد نیاز باشد. برای مثال، آیکون‌های مربوط به فعالیت‌هایی که وظایف را آغاز می‌کنند در پنجره‌ی لانچر نمایش داده می‌شوند. این آیکون اغلب با یک برچسب همراه است؛ برای اطلاعات مربوط به برچسب، به ویژگی android:label مراجعه کنید.

این ویژگی به عنوان مرجعی برای یک منبع قابل ترسیم که شامل تعریف تصویر است، تنظیم می‌شود. اگر تنظیم نشود، از آیکون مشخص شده برای کل برنامه به جای آن استفاده می‌شود. برای اطلاعات بیشتر، به ویژگی icon عنصر <application> مراجعه کنید.

آیکون اکتیویتی، چه اینجا تنظیم شود و چه توسط عنصر <application> ، آیکون پیش‌فرض برای تمام فیلترهای اینتنت اکتیویتی نیز هست. برای اطلاعات بیشتر، به ویژگی icon عنصر <intent-filter> مراجعه کنید.

android:immersive
حالت فراگیر (immersive mode) را برای فعالیت فعلی تنظیم می‌کند. اگر مقدار آن "true" باشد، عضو ActivityInfo.flags همیشه بیت FLAG_IMMERSIVE خود را تنظیم می‌کند، حتی اگر حالت فراگیر در زمان اجرا با استفاده از متد setImmersive() تغییر کند.
android:intentMatchingFlags

از این ویژگی برای تنظیم دقیق نحوه تطبیق اهداف ورودی سیستم با اجزای برنامه استفاده کنید. به طور پیش‌فرض، هیچ قانون تطبیق خاصی اعمال نمی‌شود.

مقدار تنظیم‌شده روی برچسب <activity> مقدار تنظیم‌شده روی برچسب <application> را لغو می‌کند.

مقدار باید یک یا چند مورد از پرچم‌های زیر باشد که با ' | ' از هم جدا شده‌اند:

پرچم توضیحات
none تمام قوانین تطبیق ویژه را برای ورودی‌های ورودی غیرفعال می‌کند. هنگام تعیین چندین پرچم، مقادیر متناقض با دادن اولویت به پرچم none حل می‌شوند.
enforceIntentFilter

تطبیق سختگیرانه‌تری را برای اهداف ورودی اعمال می‌کند:

  • اهداف صریح باید با فیلتر هدف کامپوننت هدف مطابقت داشته باشند.
  • اینتنت‌های بدون اکشن با هیچ فیلتر اینتنتی مطابقت ندارند.
allowNullAction

قوانین تطبیق را آسان می‌کند تا به intent های بدون اکشن اجازه تطبیق داده شود. این پرچم همراه با enforceIntentFilter برای دستیابی به رفتار زیر استفاده می‌شود:

  • اهداف صریح باید با فیلتر هدف کامپوننت هدف مطابقت داشته باشند.
  • اینتنت‌های بدون اکشن مجاز به مطابقت با هر فیلتر اینتنتی هستند.

برای اطلاعات بیشتر، به بخش « اهداف امن‌تر» در تغییرات رفتاری اندروید ۱۶ (سطح API ۳۶) مراجعه کنید.

android:label

یک برچسب قابل خواندن توسط کاربر برای فعالیت. این برچسب هنگامی که فعالیت به کاربر نمایش داده می‌شود، روی صفحه نمایش داده می‌شود. اغلب همراه با آیکون فعالیت نمایش داده می‌شود. اگر این ویژگی تنظیم نشده باشد، از برچسب تنظیم شده برای کل برنامه به جای آن استفاده می‌شود. به ویژگی label عنصر <application> مراجعه کنید.

برچسب فعالیت، چه در اینجا و چه توسط عنصر <application> تنظیم شود، برچسب پیش‌فرض برای همه فیلترهای اینتنت فعالیت نیز هست. برای اطلاعات بیشتر، به ویژگی label عنصر <intent-filter> مراجعه کنید.

این برچسب به عنوان مرجعی برای یک منبع رشته‌ای تنظیم شده است تا بتوان آن را مانند سایر رشته‌ها در رابط کاربری بومی‌سازی کرد. با این حال، برای راحتی شما در حین توسعه برنامه، می‌توانید آن را به عنوان یک رشته خام نیز تنظیم کنید.

android:launchMode

دستورالعملی برای نحوه‌ی راه‌اندازی اکتیویتی. پنج حالت وجود دارد که در رابطه با پرچم‌های اکتیویتی (ثابت‌های FLAG_ACTIVITY_* ) در اشیاء Intent کار می‌کنند تا مشخص کنند وقتی اکتیویتی برای مدیریت یک intent فراخوانی می‌شود، چه اتفاقی می‌افتد:

"standard"
"singleTop"
"singleTask"
"singleInstance"
"singleInstancePerTask"

حالت پیش‌فرض "standard" است.

همانطور که در جدول زیر نشان داده شده است، حالت‌ها به دو گروه اصلی تقسیم می‌شوند، که در یک طرف آنها فعالیت‌های "standard" و "singleTop" و در طرف دیگر فعالیت‌های "singleTask" ، "singleInstance" و "singleInstancePerTask" قرار دارند. یک فعالیت با حالت راه‌اندازی "standard" یا "singleTop" می‌تواند چندین بار نمونه‌سازی شود.

این نمونه‌ها می‌توانند به هر وظیفه‌ای تعلق داشته باشند و می‌توانند در هر جایی از وظیفه فعالیت قرار گیرند. معمولاً، آن‌ها در وظیفه‌ای که startActivity() نامیده می‌شود، راه‌اندازی می‌شوند، مگر اینکه شیء Intent حاوی دستورالعمل FLAG_ACTIVITY_NEW_TASK باشد، که در این صورت وظیفه دیگری انتخاب می‌شود. برای اطلاعات بیشتر، به ویژگی taskAffinity مراجعه کنید.

در مقابل، فعالیت‌های "singleTask" ، "singleInstance" و "singleInstancePerTask" رفتارهای متفاوتی دارند. "singleInstancePerTask" همیشه در ریشه وظیفه فعالیت قرار دارد. همچنین، دستگاه می‌تواند فقط یک نمونه از فعالیت "singleInstance" را در یک زمان نگه دارد، در حالی که فعالیت "singleInstancePerTask می‌تواند چندین بار در وظایف مختلف نمونه‌سازی شود، زمانی که FLAG_ACTIVITY_MULTIPLE_TASK یا FLAG_ACTIVITY_NEW_DOCUMENT تنظیم شده باشد.

یک اکتیویتی با حالت اجرای "singleTask" رفتارهای "singleInstance" و "singleInstancePerTask" را با هم ترکیب می‌کند: اکتیویتی می‌تواند چندین بار نمونه‌سازی شود و می‌تواند در هر جایی از یک وظیفه از همان taskAffinity قرار گیرد. اما دستگاه فقط می‌تواند یک وظیفه را برای یافتن اکتیویتی "singleTask" در ریشه وظیفه اکتیویتی نگه دارد.

حالت‌های "standard" و "singleTop" از یک نظر با یکدیگر متفاوت هستند: هر بار که یک هدف جدید برای یک فعالیت "standard" وجود دارد، یک نمونه جدید از کلاس برای پاسخ به آن هدف ایجاد می‌شود. هر نمونه یک هدف واحد را مدیریت می‌کند. به طور مشابه، یک نمونه جدید از یک فعالیت "singleTop" نیز می‌تواند برای مدیریت یک هدف جدید ایجاد شود.

با این حال، اگر وظیفه هدف از قبل یک نمونه موجود از فعالیت در بالای پشته خود داشته باشد، آن نمونه، هدف جدید را با فراخوانی onNewIntent() دریافت می‌کند. نمونه جدیدی ایجاد نمی‌شود. در غیر این صورت - اگر یک نمونه موجود از فعالیت "singleTop" در وظیفه هدف باشد اما در بالای پشته نباشد، یا اگر در بالای پشته باشد اما در وظیفه هدف نباشد - یک نمونه جدید ایجاد و به پشته اضافه می‌شود.

به طور مشابه، اگر کاربر به یک فعالیت در پشته فعلی برود ، رفتار آن توسط حالت راه‌اندازی فعالیت والد تعیین می‌شود. اگر فعالیت والد حالت راه‌اندازی singleTop داشته باشد (یا هدف up شامل FLAG_ACTIVITY_CLEAR_TOP باشد)، والد به بالای پشته آورده می‌شود و وضعیت آن حفظ می‌شود.

هدف ناوبری توسط متد onNewIntent() فعالیت والد دریافت می‌شود. اگر فعالیت والد حالت راه‌اندازی standard داشته باشد و هدف up شامل FLAG_ACTIVITY_CLEAR_TOP نباشد، فعالیت فعلی و والد آن هر دو از پشته خارج می‌شوند و یک نمونه جدید از فعالیت والد برای دریافت هدف ناوبری ایجاد می‌شود.

حالت "singleInstance" همچنین تنها از یک نظر با "singleTask" و "singleInstancePerTask" متفاوت است: یک فعالیت با حالت راه‌اندازی "singleTask" یا "singleInstancePerTask" به سایر فعالیت‌ها، لزوماً فعالیت‌های "standard" و "singleTop" ، اجازه می‌دهد تا بخشی از وظیفه آن باشند.

از سوی دیگر، یک فعالیت "singleInstance" اجازه نمی‌دهد هیچ فعالیت دیگری بخشی از وظیفه‌اش باشد. این فعالیت باید تنها فعالیت در وظیفه باشد. اگر فعالیت دیگری را شروع کند، آن فعالیت به وظیفه دیگری اختصاص داده می‌شود، گویی FLAG_ACTIVITY_NEW_TASK در intent قرار دارد.

موارد استفاده حالت راه اندازی موارد متعدد؟ نظرات
راه‌اندازی‌های عادی برای اکثر فعالیت‌ها "standard" بله پیش‌فرض. سیستم همیشه یک نمونه جدید از اکتیویتی را در وظیفه هدف ایجاد می‌کند و اینتنت را به آن هدایت می‌کند.
"singleTop" مشروط اگر نمونه‌ای از اکتیویتی از قبل در بالای وظیفه هدف وجود داشته باشد، سیستم به جای ایجاد یک نمونه جدید از اکتیویتی، اینتنت را از طریق فراخوانی متد onNewIntent() به آن نمونه هدایت می‌کند.
پرتاب‌های تخصصی
(برای استفاده عمومی توصیه نمی‌شود)
"singleTask" مشروط سیستم، اکتیویتی را در ریشه یک وظیفه جدید ایجاد می‌کند یا آن را در یک وظیفه موجود با همان وابستگی قرار می‌دهد. اگر نمونه‌ای از اکتیویتی از قبل وجود داشته باشد و در ریشه وظیفه باشد، سیستم به جای ایجاد یک نمونه جدید، اینتنت را از طریق فراخوانی متد onNewIntent() به نمونه موجود هدایت می‌کند.
"singleInstance" خیر همانند "singleTask" است، با این تفاوت که سیستم هیچ فعالیت دیگری را در وظیفه‌ای که نمونه را در خود نگه می‌دارد، اجرا نمی‌کند. فعالیت همیشه تنها و تنها عضو وظیفه خود است.
"singleInstancePerTask" مشروط این فعالیت فقط می‌تواند به عنوان فعالیت ریشه وظیفه، اولین فعالیتی که وظیفه را ایجاد کرده است، اجرا شود و بنابراین فقط یک نمونه از این فعالیت در یک وظیفه وجود دارد. با این حال، فعالیت می‌تواند چندین بار در وظایف مختلف نمونه‌سازی شود.

همانطور که در جدول قبل نشان داده شده است، "standard" حالت پیش‌فرض است و برای اکثر انواع فعالیت‌ها مناسب است. "singleTop" نیز یک حالت راه‌اندازی رایج و مفید برای بسیاری از انواع فعالیت‌ها است. حالت‌های دیگر، "singleTask" ، "singleInstance" و "singleInstancePerTask" ، برای اکثر برنامه‌ها مناسب نیستند . آنها منجر به یک مدل تعاملی می‌شوند که احتمالاً برای کاربران ناآشنا است و با اکثر برنامه‌های دیگر بسیار متفاوت است.

صرف نظر از حالت راه‌اندازی که انتخاب می‌کنید، حتماً قابلیت استفاده از فعالیت را در حین راه‌اندازی و هنگام بازگشت به آن از سایر فعالیت‌ها و وظایف با استفاده از دکمه برگشت، آزمایش کنید.

برای اطلاعات بیشتر در مورد حالت‌های راه‌اندازی و تعامل آنها با پرچم‌های Intent ، به Tasks و back Stack مراجعه کنید.

android:lockTaskMode
نحوه نمایش این فعالیت توسط سیستم را هنگامی که دستگاه در حالت قفل کار می‌کند، تعیین می‌کند.

اندروید می‌تواند وظایف را به روشی فراگیر و شبیه کیوسک به نام حالت قفل وظایف اجرا کند. وقتی سیستم در حالت قفل وظایف اجرا می‌شود، کاربران دستگاه معمولاً نمی‌توانند اعلان‌ها را ببینند، به برنامه‌های غیرمجاز دسترسی پیدا کنند یا به صفحه اصلی برگردند، مگر اینکه برنامه Home در لیست مجاز باشد.

فقط برنامه‌هایی که توسط کنترل‌کننده سیاست دستگاه (DPC) در فهرست مجاز قرار گرفته‌اند، می‌توانند در حالت قفل وظیفه اجرا شوند. با این حال، برنامه‌های سیستمی و ممتاز می‌توانند بدون قرار گرفتن در فهرست مجاز، در حالت قفل وظیفه اجرا شوند.

این مقدار می‌تواند هر یک از مقادیر رشته‌ای R.attr.lockTaskMode زیر باشد:

ارزش توضیحات
"normal" مقدار پیش‌فرض. این مقدار پیش‌فرض است. وظایف در حالت قفل اجرا نمی‌شوند، اما می‌توان با فراخوانی startLockTask() آنها را در آنجا قرار داد.
"never"

وظایف در حالت lockTask اجرا نمی‌شوند و کاربر دستگاه نمی‌تواند این وظایف را از صفحه Recents پین کند.

توجه: این حالت فقط برای برنامه‌های سیستمی و دارای امتیاز ویژه در دسترس است. برنامه‌های بدون امتیاز ویژه با این مقدار به عنوان normal در نظر گرفته می‌شوند.

"if_whitelisted" اگر DPC این بسته را با استفاده از DevicePolicyManager.setLockTaskPackages() مجاز کند، این حالت مشابه always است، با این تفاوت که اگر آخرین وظیفه قفل شده باشد، فعالیت قبل از اینکه بتواند به پایان برسد، باید stopLockTask() را فراخوانی کند. اگر DPC این بسته را مجاز نکند، این حالت مشابه normal است.
"always"

وظایفی که در این فعالیت ریشه دارند، همیشه در حالت وظیفه قفل اجرا می‌شوند. اگر سیستم هنگام اجرای این وظیفه از قبل در حالت وظیفه قفل باشد، وظیفه جدید بر روی وظیفه فعلی اجرا می‌شود. وظایفی که در این حالت اجرا می‌شوند می‌توانند با فراخوانی finish() از حالت وظیفه قفل خارج شوند.

توجه: این حالت فقط برای برنامه‌های سیستمی و دارای امتیاز ویژه در دسترس است. برنامه‌های بدون امتیاز ویژه با این مقدار به عنوان normal در نظر گرفته می‌شوند.

این ویژگی در API سطح ۲۳ معرفی شد.

android:maxRecents
حداکثر تعداد وظایفی که در صفحه Recents به این فعالیت ارجاع داده می‌شوند. وقتی به این تعداد ورودی برسیم، سیستم آخرین نمونه‌ای که اخیراً کمتر استفاده شده را از صفحه Recents حذف می‌کند. مقادیر معتبر، اعداد صحیح از ۱ تا ۵۰ یا ۱ تا ۲۵ در دستگاه‌های با حافظه کم هستند. صفر نامعتبر است. مقدار پیش‌فرض ۱۶ است.
android:maxAspectRatio

حداکثر نسبت ابعادی که فعالیت پشتیبانی می‌کند.

اگر برنامه روی دستگاهی با نسبت تصویر عریض‌تر اجرا شود، سیستم به‌طور خودکار برنامه را در کادر قرار می‌دهد و بخش‌هایی از صفحه را بلااستفاده می‌گذارد تا برنامه بتواند با حداکثر نسبت تصویر مشخص‌شده اجرا شود.

حداکثر نسبت ابعاد به صورت شکل اعشاری از تقسیم خارج قسمت طول دستگاه بر طول کوتاه‌تر آن بیان می‌شود. برای مثال، اگر حداکثر نسبت ابعاد 7:3 باشد، مقدار این ویژگی را روی 2.33 تنظیم کنید.

در دستگاه‌های غیرپوشیدنی، مقدار این ویژگی باید ۱.۳۳ یا بیشتر باشد. در دستگاه‌های پوشیدنی، باید ۱.۰ یا بیشتر باشد. در غیر این صورت، سیستم مقدار تعیین‌شده را نادیده می‌گیرد.

برای اطلاعات بیشتر در مورد این ویژگی، به R.attr.maxAspectRatio مراجعه کنید.

android:minAspectRatio

حداقل نسبت ابعادی که فعالیت پشتیبانی می‌کند.

اگر برنامه روی دستگاهی با نسبت تصویر باریک‌تر اجرا شود، سیستم به‌طور خودکار برنامه را در کادر قرار می‌دهد و بخش‌هایی از صفحه را بلااستفاده می‌گذارد تا برنامه بتواند با حداقل نسبت تصویر مشخص‌شده اجرا شود.

حداقل نسبت ابعاد به صورت اعشاری از تقسیم خارج قسمت طول دستگاه بر طول کوتاه‌تر آن بیان می‌شود. برای مثال، اگر نسبت ابعاد نمایشگر ۴:۳ است، حداقل نسبت ابعاد را روی ۱.۳۳ تنظیم کنید.

مقدار باید بزرگتر یا مساوی ۱.۰ باشد، در غیر این صورت سیستم مقدار تعیین شده را نادیده می‌گیرد.

برای اطلاعات بیشتر در مورد این ویژگی، به R.attr.minAspectRatio مراجعه کنید.

android:multiprocess
آیا می‌توان نمونه‌ای از اکتیویتی را در فرآیند کامپوننتی که آن را آغاز کرده است، راه‌اندازی کرد یا خیر. اگر امکان‌پذیر باشد، "true" و در غیر این صورت "false" است. مقدار پیش‌فرض "false" است.

معمولاً، یک نمونه جدید از یک فعالیت در فرآیند برنامه‌ای که آن را تعریف کرده است، راه‌اندازی می‌شود، بنابراین همه نمونه‌های فعالیت در همان فرآیند اجرا می‌شوند. با این حال، اگر این پرچم روی "true" تنظیم شود، نمونه‌های فعالیت می‌توانند در چندین فرآیند اجرا شوند و به سیستم اجازه می‌دهند در هر کجا که از آنها استفاده می‌شود، نمونه‌هایی ایجاد کند، مشروط بر اینکه مجوزها به آن اجازه دهند - چیزی که تقریباً هرگز ضروری یا مطلوب نیست.

android:name
نام کلاسی که فعالیت را پیاده‌سازی می‌کند، یک زیرکلاس از Activity . مقدار ویژگی معمولاً یک نام کلاس کاملاً واجد شرایط است، مانند "com.example.project.ExtracurricularActivity" . با این حال، به عنوان یک اختصار، اگر اولین کاراکتر نام یک نقطه باشد، مانند ".ExtracurricularActivity" ، به فضای نام مشخص شده در فایل build.gradle اضافه می‌شود.

Once you publish your application, don't change this name , unless you set android:exported ="false" . There is no default. The name must be specified.

android:noHistory
Whether the activity is removed from the activity stack and finished, by calling its finish() method, when the user navigates away from it and it's no longer visible on screen. It's "true" if it is finished, and "false" if not. The default value is "false" .

A value of "true" means that the activity doesn't leave a historical trace. It doesn't remain in the activity stack for the task, so the user isn't able to return to it. In this case, onActivityResult() is never called if you start another activity for a result from this activity.

This attribute was introduced in API level 3.

android:parentActivityName
The class name of the logical parent of the activity. The name here must match the class name given to the corresponding <activity> element's android:name attribute.

The system reads this attribute to determine which activity to start when the user taps the Up button in the action bar. The system can also use this information to synthesize a back stack of activities with TaskStackBuilder .

To support API levels 4 - 16, you can also declare the parent activity with a <meta-data> element that specifies a value for "android.support.PARENT_ACTIVITY" :

<activity
    android:name="com.example.app.ChildActivity"
    android:label="@string/title_child_activity"
    android:parentActivityName="com.example.app.MainActivity" >
    <!-- Parent activity meta-data to support API level 4+ -->
    <meta-data
        android:name="android.support.PARENT_ACTIVITY"
        android:value="com.example.app.MainActivity" />
</activity>

For more information about declaring the parent activity to support Up navigation, read Providing Up Navigation .

This attribute was introduced in API level 16.

android:persistableMode

Defines how an instance of an activity is preserved within a containing task across device restarts.

If the root activity of a task sets this attribute's value to persistRootOnly , then only the root activity is preserved. Otherwise, the activities that are higher up the task's back stack are examined; any of these activities that set this attribute's value to persistAcrossReboots are preserved.

If you use this attribute, you must set its value to one of the following:

ارزش توضیحات
persistRootOnly

Default value. When the system restarts, the activity task is preserved, but only the root activity's launching intent is used.

When your app's launching intent loads your app's root activity, the activity doesn't receive a PersistableBundle object. Therefore, don't use onSaveInstanceState() to preserve the state of your app's root activity across a device restart.

Note: This attribute value affects your app's behavior only if it's set on your app's root activity.

persistAcrossReboots

This activity's state is preserved, along with the state of each activity higher up the back stack that has its own persistableMode attribute set to persistAcrossReboots . If an activity doesn't have a persistableMode attribute that is set to persistAcrossReboots , or if it's launched using the Intent.FLAG_ACTIVITY_NEW_DOCUMENT flag, then that activity, along with all activities higher up the back stack, aren't preserved.

When an intent loads an activity whose persistableMode attribute is set to persistAcrossReboots in your app, the activity receives a PersistableBundle object in its onCreate() method. Therefore, you can use onSaveInstanceState() to preserve the state of an activity across a device restart as long as its persistableMode attribute is set to persistAcrossReboots .

Note: This attribute value affects your app's behavior even if it's set on an activity other than your app's root activity.

persistNever

The activity's state isn't preserved.

Note: This attribute value affects your app's behavior only if it's set on your app's root activity.

This attribute was introduced in API level 21.

android:permission
The name of a permission that clients must have to launch the activity or otherwise get it to respond to an intent. If a caller of startActivity() or startActivityForResult() isn't granted the specified permission, its intent isn't delivered to the activity.

If this attribute isn't set, the permission set by the <application> element's permission attribute applies to the activity. If neither attribute is set, the activity isn't protected by a permission.

For more information on permissions, see the Permissions section of the App manifest overview and Security tips .

android:preferMinimalPostProcessing

Specifies whether the activity prefers the connected display to perform minimal post-processing (also known as auto low latency mode or game mode). This setting is useful for applications like games or video conferencing where low latency is more important than image enhancement.

The default value is "false" .

For more information, see the guide on requesting and checking for low latency support .

android:process

The name of the process in which the activity runs. Normally, all components of an application run in a default process name created for the application, and you don't need to use this attribute. But if necessary, you can override the default process name with this attribute, letting you spread your app components across multiple processes.

If the name assigned to this attribute begins with a colon ( : ), a new process, private to the application, is created when it's needed and the activity runs in that process.

If the process name begins with a lowercase character, the activity runs in a global process of that name, provided that it has permission to do so. This lets components in different applications share a process, reducing resource usage.

The <application> element's process attribute can set a different default process name for all components.

android:recreateOnConfigChanges

Specifies the configuration changes that should trigger the system to recreate the activity. If a configuration change is specified here (and not in android:configChanges ), the activity is recreated when that change occurs.

For more information, see the guide on recreating an activity on configuration changes .

android:relinquishTaskIdentity

Whether the activity relinquishes its task identifiers to an activity above it in the task stack. A task whose root activity has this attribute set to "true" replaces the base Intent with that of the next activity in the task.

If the next activity also has this attribute set to "true" then it yields the base Intent to any activity that it launches in the same task. This continues for each activity until an activity is encountered which has this attribute set to "false" . The default value is "false" .

This attribute set to "true" also permits the activity's use of the ActivityManager.TaskDescription to change labels, colors, and icons in the Recents screen .

android:requireContentUriPermissionFromCaller

Specifies permissions necessary to launch this activity when passing content URIs. The default value is none , meaning no specific permissions are required. Setting this attribute restricts activity invocation based on the invoker's permissions. If the invoker doesn't have the required permissions, the activity start will be denied via a SecurityException .

Note that the enforcement works for content URIs inside Intent.getData() , Intent.EXTRA_STREAM , and Intent.getClipData() .

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;

Must be one of the following constant values.

ثابت ارزش توضیحات
هیچ کدام 0 Default, no specific permissions are required.
خواندن ۱ Enforces the invoker to have read access to the passed content URIs.
readAndWrite ۴ Enforces the invoker to have both read and write access to the passed content URIs.
readOrWrite ۳ Enforces the invoker to have either read or write access to the passed content URIs.
بنویس ۲ Enforces the invoker to have write access to the passed content URIs.
android:resizeableActivity

Specifies whether the app supports multi-window mode .

You can set this attribute in either the <activity> or <application> element.

If you set this attribute to "true" , the user can launch the activity in split-screen and free-form modes. If you set the attribute to "false" , the app can't be tested or optimized for a multi-window environment. The system can still put the activity in multi-window mode with compatibility mode applied.

Setting this attribute to "false" doesn't guarantee that there are no other apps in multi-window mode visible on screen, such as in a picture-in-picture, or on other displays. Therefore, setting this flag doesn't mean that your app has exclusive resource access.

If your app targets API level 24 or higher and you do not specify a value for this attribute, the attribute's value defaults to "true" .

If your app targets API level 31 or higher, this attribute works differently on small and large screens:

  • Large screens (sw >= 600dp): all apps support multi-window mode. The attribute indicates whether an app can be resized, not whether the app supports multi-window mode. If resizeableActivity="false" , the app is put into compatibility mode when necessary to conform to display dimensions.
  • Small screens (sw < 600dp): if resizeableActivity="true" and the minimum width and minimum height of the activity are within the multi-window requirements, the app supports multi-window mode. If resizeableActivity="false" , the app doesn't support multi-window mode regardless of the activity minimum width and height.

A task's root activity value is applied to all additional activities launched in the task. That is, if the root activity of a task is resizable, then the system treats all other activities in the task as resizable. If the root activity isn't resizable, the other activities in the task aren't resizable.

Note: A task's root activity value is applied to all additional activities launched in the task. That is, if the root activity of a task is resizable, then the system treats all other activities in the task as resizable. If the root activity isn't resizable, the other activities in the task aren't resizable.

android:screenOrientation

The requested orientation of the activity.

When an activity fills the entire screen, the requested orientation acts as a suggestion to change the orientation on that screen to match the requested value. This can result in an orientation that differs from the screen's physical orientation in space, requiring the user to rotate the device to continue using the app. On Android 12 (API level 31) and higher, device manufacturers can configure individual device screens (such as the tablet-sized screen of a foldable) to ignore this suggestion, and instead force an activity to be letterboxed within the user's preferred orientation of the device. This results in the activity's orientation matching the requested one without needing the user to physically rotate their device.

In multi-window mode, the requested orientation does not act as a suggestion for the overall orientation. If the activity is letterboxed , the requested orientation impacts the letterboxing applied to the activity.

The value can be any one of the following strings:

"unspecified" The default value. The system chooses the orientation. The policy it uses, and therefore the choices made in specific contexts, might differ from device to device.
"behind" The same orientation as the activity that's immediately beneath it in the activity stack.
"landscape" Landscape orientation (the display is wider than it is tall).
"portrait" Portrait orientation (the display is taller than it is wide).
"reverseLandscape" Landscape orientation in the opposite direction from normal landscape. Added in API level 9.
"reversePortrait" Portrait orientation in the opposite direction from normal portrait. Added in API level 9.
"sensorLandscape" Landscape orientation, but can be either normal or reverse landscape based on the device sensor. The sensor is used even if the user has locked sensor-based rotation. Added in API level 9.
"sensorPortrait" Portrait orientation, but can be either normal or reverse portrait based on the device sensor. The sensor is used even if the user has locked sensor-based rotation. However, depending on the device configuration, upside-down rotation might not be allowed. Added in API level 9.
"userLandscape" Landscape orientation, but can be either normal or reverse landscape based on the device sensor and the user's preference. Added in API level 18.
"userPortrait" Portrait orientation, but can be either normal or reverse portrait based on the device sensor and the user's preference. However, depending on the device configuration, upside-down rotation might not be allowed. Added in API level 18.
"sensor" The device orientation sensor determines the orientation. The orientation of the display depends on how the user is holding the device. It changes when the user rotates the device. Some devices, though, don't rotate to all four possible orientations, by default. To use all four orientations, use "fullSensor" . The sensor is used even if the user locked sensor-based rotation.
"fullSensor" The device orientation sensor determines the orientation for any of the four orientations. This is similar to "sensor" , except this allows for any of the four possible screen orientations regardless of what the device normally supports. For example, some devices don't normally use reverse portrait or reverse landscape, but this enables those orientations. Added in API level 9.
"nosensor" The orientation is determined without reference to a physical orientation sensor. The sensor is ignored, so the display doesn't rotate based on how the user moves the device.
"user" The user's current preferred orientation.
"fullUser" If the user has locked sensor-based rotation, this behaves the same as user , otherwise it behaves the same as fullSensor and allows any of the four possible screen orientations. Added in API level 18.
"locked" Locks the orientation to its current rotation, whatever that is. Added in API level 18.

Note: When you declare one of the landscape or portrait values, it is considered a hard requirement for the orientation in which the activity runs. The value you declare enables filtering by services such as Google Play, so your application is available only to devices that support the orientation required by your activities. For example, if you declare either "landscape" , "reverseLandscape" , or "sensorLandscape" , then your application is available only to devices that support landscape orientation.

Also explicitly declare that your application requires either portrait or landscape orientation with the <uses-feature> Element, such as <uses-feature android:name="android.hardware.screen.portrait"/> . This is a filtering behavior provided by Google Play and other services that support it, and the platform itself doesn't control whether your app can install when a device supports only certain orientations.

android:showForAllUsers

Whether the activity is shown when the device's current user is different than the user who launched the activity. You can set this attribute to a literal value, like "true" or "false" , or you can set the attribute to a resource or theme attribute that contains a boolean value.

This attribute was added in API level 23.

android:stateNotNeeded
Whether the activity can be terminated and successfully restarted without having saved its state. It's "true" if it can be restarted without reference to its previous state, and "false" if its previous state is required. The default value is "false" .

Normally, before an activity is temporarily shut down to save resources, its onSaveInstanceState() method is called. This method stores the current state of the activity in a Bundle object, which is then passed to onCreate() when the activity is restarted. If this attribute is set to "true" , onSaveInstanceState() might not be called, and onCreate() is passed null instead of the Bundle , as it is when the activity starts for the first time.

A "true" setting means that the activity can be restarted without retained state. For example, the activity that displays the Home screen uses this setting to make sure that it doesn't get removed if it crashes for some reason.

android:supportsPictureInPicture

Specifies whether the activity supports picture-in-picture display.

android:taskAffinity

The task that the activity has an affinity for. Activities with the same affinity conceptually belong to the same task, to the same "application" from the user's perspective. The affinity of a task is determined by the affinity of its root activity.

The affinity determines two things: the task that the activity is re-parented to (see the allowTaskReparenting attribute) and the task that houses the activity when it launches with the FLAG_ACTIVITY_NEW_TASK flag.

By default, all activities in an application have the same affinity. You can set this attribute to group them differently, and even place activities defined in different applications within the same task. To specify that the activity doesn't have an affinity for any task, set it to an empty string.

If this attribute isn't set, the activity inherits the affinity set for the application. See the <application> element's taskAffinity attribute. The name of the default affinity for an application is the namespace set in the build.gradle file.

android:theme
A reference to a style resource defining an overall theme for the activity. This automatically sets the activity's context to use this theme and might also cause "starting" animations prior to the activity being launched, to better match what the activity actually looks like.

If this attribute isn't set, the activity inherits the theme set for the application as a whole, from the <application> element's theme attribute. If that attribute is also not set, the default system theme is used. For more information, see Styles and themes .

android:uiOptions

Extra options for an activity's UI. Must be one of the following values.

ارزش توضیحات
"none" No extra UI options. This is the default.
"splitActionBarWhenNarrow" Adds a bar at the bottom of the screen to display action items in the app bar , also known as the action bar , when constrained for horizontal space, such as when in portrait mode on a handset. Instead of a small number of action items appearing in the app bar at the top of the screen, the app bar is split into the top navigation section and the bottom bar for action items. This means a reasonable amount of space is made available not only for the action items, but also for navigation and title elements at the top. Menu items are not split across the two bars. They always appear together.

For more information about the app bar, see Add the app bar .

This attribute was added in API level 14.

android:windowSoftInputMode
How the main window of the activity interacts with the window containing the on-screen soft keyboard. The setting for this attribute affects two things:
  • Whether the soft keyboard is hidden or visible when the activity becomes the focus of user attention.
  • Whether the activity's main window is resized smaller to make room for the soft keyboard or its contents pan to make the current focus visible when part of the window is covered by the soft keyboard.

The setting must be one of the values listed in the following table or a combination of one "state..." value plus one "adjust..." value. Setting multiple values in either group, such as multiple "state..." values, has undefined results. Individual values are separated by a vertical bar ( | ), as shown in the following example:

<activity android:windowSoftInputMode="stateVisible|adjustResize" ... >

Values set here (other than "stateUnspecified" and "adjustUnspecified" ) override values set in the theme.

ارزش توضیحات
"stateUnspecified" Whether the soft keyboard is hidden or visible isn't specified. The system chooses an appropriate state or relies on the setting in the theme.

This is the default setting for the behavior of the soft keyboard.

"stateUnchanged" The soft keyboard is kept in whatever state it was last in, visible or hidden, when the activity comes to the fore.
"stateHidden" The soft keyboard is hidden when the user chooses the activity—that is, when the user affirmatively navigates forward to the activity, rather than backing into it when leaving another activity.
"stateAlwaysHidden" The soft keyboard is always hidden when the activity's main window has input focus.
"stateVisible" The soft keyboard is made visible when the user chooses the activity—that is, when the user affirmatively navigates forward to the activity, rather than backing into it when leaving another activity.
"stateAlwaysVisible" The soft keyboard is visible when the window receives input focus.
"adjustUnspecified" Whether the activity's main window resizes to make room for the soft keyboard or the contents of the window pan to make the current focus visible on-screen is unspecified. The system automatically selects one of these modes depending on whether the content of the window has any layout views that can scroll their contents. If there is such a view, the window resizes, on the assumption that scrolling can make all of the window's contents visible within a smaller area.

This is the default setting for the behavior of the main window.

"adjustResize" The activity's main window is always resized to make room for the soft keyboard on screen.
"adjustPan" The activity's main window isn't resized to make room for the soft keyboard. Rather, the contents of the window automatically pan so that the current focus is never obscured by the keyboard, and users can always see what they are typing. This is generally less desirable than resizing, because the user might need to close the soft keyboard to get at and interact with obscured parts of the window.
"adjustNothing" The activity's main window isn't resized or panned to make room for the soft keyboard. The activity is responsible for making room for the soft keyboard using the window insets. For activities that handle window insets correctly this gives the most control over how the window's contents are displayed on the screen.

This attribute was introduced in API level 3.

introduced in:
API level 1 for all attributes except noHistory and windowSoftInputMode , which were added in API level 3.
همچنین ببینید:
<application>
<activity-alias>