فعالیت
آخرین به روز رسانی | انتشار پایدار | کاندید را آزاد کنید | نسخه بتا | انتشار آلفا |
---|---|---|---|---|
9 آوریل 2025 | 1.10.1 | - | 1.11.0-بتا01 | - |
اعلام وابستگی ها
برای افزودن وابستگی به Activity، باید مخزن Google Maven را به پروژه خود اضافه کنید. برای اطلاعات بیشتر، مخزن Maven Google را بخوانید.
وابستگیهای مصنوعات مورد نیاز خود را در فایل build.gradle
برای برنامه یا ماژول خود اضافه کنید:
شیار
dependencies { def activity_version = "1.10.1" // Java language implementation implementation "androidx.activity:activity:$activity_version" // Kotlin implementation "androidx.activity:activity-ktx:$activity_version" }
کاتلین
dependencies { val activity_version = "1.10.1" // Java language implementation implementation("androidx.activity:activity:$activity_version") // Kotlin implementation("androidx.activity:activity-ktx:$activity_version") }
برای اطلاعات بیشتر درباره وابستگیها، به افزودن وابستگیهای ساخت نگاه کنید.
بازخورد
بازخورد شما به بهتر شدن Jetpack کمک می کند. اگر مسائل جدیدی کشف کردید یا ایده هایی برای بهبود این کتابخانه دارید، به ما اطلاع دهید. لطفاً قبل از ایجاد کتابخانه جدید، به مسائل موجود در این کتابخانه نگاهی بیندازید. با کلیک کردن روی دکمه ستاره می توانید رای خود را به یک موضوع موجود اضافه کنید.
برای اطلاعات بیشتر به مستندات ردیاب مشکل مراجعه کنید.
نسخه 1.11
نسخه 1.11.0-beta01
9 آوریل 2025
androidx.activity:activity:1.11.0-beta01
، androidx.activity:activity-compose:1.11.0-beta01
و androidx.activity:activity-ktx:1.11.0-beta01
منتشر شدند. نسخه 1.11.0-beta01 حاوی این تعهدات است.
نسخه 1.11.0-alpha02
26 مارس 2025
androidx.activity:activity:1.11.0-alpha02
، androidx.activity:activity-compose:1.11.0-alpha02
و androidx.activity:activity-ktx:1.11.0-alpha02
منتشر شدند. نسخه 1.11.0-alpha02 حاوی این commit ها است.
تغییرات API
-
EDGE_NONE
وframeTimeMillis
جدید از Android 16 Beta03 را درBackEventCompat
ارائه شده توسط توابعOnBackPressedCallback
'shandleOnBackStarted
وhandleOnBackProgressed
ادغام کرد.
به روز رسانی های وابستگی
- اکنون فعالیت با API 36 کامپایل شده است. ( I510e8 , b/301910674 )
نسخه 1.11.0-alpha01
12 مارس 2025
androidx.activity:activity:1.11.0-alpha01
، androidx.activity:activity-compose:1.11.0-alpha01
و androidx.activity:activity-ktx:1.11.0-alpha01
منتشر شدند. نسخه 1.11.0-alpha01 حاوی این commit ها است.
ویژگی های جدید
-
MediaCapabilities
API را بهPickVisualMediaRequest
اضافه کرد تا به برنامهها اجازه دهد قابلیتهای رسانهای خود مانند انواع پشتیبانیشده HDR را مشخص کنند. ( IC3ee7 )
نسخه 1.10
نسخه 1.10.1
26 فوریه 2025
androidx.activity:activity:1.10.1
، androidx.activity:activity-compose:1.10.1
و androidx.activity:activity-ktx:1.10.1
منتشر شدند. نسخه 1.10.1 شامل این commit ها است.
رفع اشکال
-
ViewTree
OnBackPressedDispatcherOwners
وFullyDrawnReporterOwners
اکنون می توانند از طریق والدین مجزای یک view، مانندViewOverlay
، حل شوند. برای اطلاعات بیشتر در مورد والدین با نمای جدا، به یادداشتهای انتشار هسته یا مستندات درViewTree.setViewTreeDisjointParent
مراجعه کنید. ( Ie7750 )
نسخه 1.10.0
15 ژانویه 2025
androidx.activity:activity:1.10.0
، androidx.activity:activity-compose:1.10.0
و androidx.activity:activity-ktx:1.10.0
منتشر شدند. نسخه 1.10.0 حاوی این commit ها است.
تغییرات مهم از 1.9.0
-
PhotoPicker
اکنون اجازه می دهد تا تصاویر را به ترتیب انتخاب کنید و انتخاب کنید کدام برگه (چه آلبوم ها یا تصاویر) در ابتدا قابل مشاهده باشد. - قراردادهای
PickVisualMedia
وPickMultipleVisualMedia
Activity Result که فعال میشوند، اگر انتخابگر عکس سیستم در دسترس نباشد، Photo Picker دیگر مستقیماً به خدمات Google Play واگذار نمیشود، اما از کنش عمومیACTION_SYSTEM_FALLBACK_PICK_IMAGES
و موارد اضافی مرتبط برای ارائه یک تجربه منسجم Photo Picker بهعنوان برنامههای OEM و سیستم بازگشتی استفاده میکند. - ترکیب محلی
LocalActivity
جدید کهActivity
برای محدوده فعلی فراهم می کند و نیازی به برنامه نویسان برای دریافت یکActivity
ازLocalContext
را از بین می برد.
نسخه 1.10.0-rc01
11 دسامبر 2024
androidx.activity:activity:1.10.0-rc01
، androidx.activity:activity-compose:1.10.0-rc01
و androidx.activity:activity-ktx:1.10.0-rc01
منتشر شدند. نسخه 1.10.0-rc01 حاوی این commit ها است.
رفع اشکال
- رفع مشکلی که در آن تغییر حالت فعال در حالی که
PredictiveBackHandler
در حال حاضر فعال است، فوراً تماس را کوتاه میکند. اکنون بدون در نظر گرفتن تغییرات وضعیت فعال، پاسخ تماس فعلی را تمام می کند. ( IB8719 )
نسخه 1.10.0-beta01
13 نوامبر 2024
androidx.activity:activity:1.10.0-beta01
، androidx.activity:activity-compose:1.10.0-beta01
و androidx.activity:activity-ktx:1.10.0-beta01
بدون هیچ تغییری از آخرین آلفا منتشر شدهاند. نسخه 1.10.0-beta01 حاوی این تعهدات است.
نسخه 1.10.0-alpha03
30 اکتبر 2024
androidx.activity:activity:1.10.0-alpha03
، androidx.activity:activity-compose:1.10.0-alpha03
و androidx.activity:activity-ktx:1.10.0-alpha03
منتشر شدند. نسخه 1.10.0-alpha03 حاوی این commit ها است.
تغییرات API
- یک ترکیب محلی
LocalActivity
جدید اضافه کرد کهActivity
برای محدوده فعلی فراهم می کند و نیازی به برنامه نویسان برای دریافت یکActivity
ازLocalContext
را از بین می برد. همچنین با یک قانون پرز جدید همراه است که بررسی می کندLocalContext
به اشتباه به یکActivity
فرستاده می شود. ( I7746a , b/283009666 )
رفع اشکال
- از فعالیت
1.9.3
:PredictiveBackHandler
دیگر پس از غیرفعال شدن کنترل کننده، پاسخ تماس خود را انجام نمی دهد. این مشکلی را برطرف میکند که در آنNavHost
از Navigation Compose یکIndexOutOfBoundsException
ایجاد میکند. ( I3f75e , b/365027664 , b/340202286 )
به روز رسانی وابستگی
- Activity Compose اکنون به Compose Runtime 1.7.0 بستگی دارد ( I7746a , b/283009666 )
نسخه 1.10.0-alpha02
4 سپتامبر 2024
androidx.activity:activity:1.10.0-alpha02
، androidx.activity:activity-compose:1.10.0-alpha02
و androidx.activity:activity-ktx:1.10.0-alpha02
منتشر شدند. نسخه 1.10.0-alpha02 حاوی این تعهدات است.
تغییرات رفتار
- قراردادهای
PickVisualMedia
وPickMultipleVisualMedia
Activity Result که فعال میشوند، اگر انتخابگر عکس سیستم در دسترس نباشد، Photo Picker دیگر مستقیماً به خدمات Google Play واگذار نمیشود، اما از کنش عمومیACTION_SYSTEM_FALLBACK_PICK_IMAGES
و موارد اضافی مرتبط برای ارائه یک تجربه منسجم Photo Picker بهعنوان برنامههای OEM و سیستم بازگشتی استفاده میکند. این نباید تأثیری بر تجربه کاربری دستگاههایی که نسخه اخیر سرویسهای Google Play دارند، داشته باشد. ( I3513d )
رفع اشکال
- طرح دستی دسترسی به APIهای پلتفرم جدید حذف شد زیرا این به طور خودکار از طریق مدلسازی API هنگام استفاده از R8 با AGP 7.3 یا جدیدتر (مثلا R8 نسخه 3.3) و برای همه ساختها هنگام استفاده از AGP 8.1 یا بالاتر (به عنوان مثال D8 نسخه 8.1) اتفاق میافتد. به مشتریانی که از AGP استفاده نمیکنند، توصیه میشود به نسخه 8.1 یا بالاتر D8 بهروزرسانی کنند. برای جزئیات بیشتر به این مقاله مراجعه کنید. ( I9496c , b/345472586 )
- از Activity
1.9.2
: مشکلی را برطرف کرد که در آن Activity ComposePredictiveBackHandler
API به کنترل ژست برگشت سیستم در فریمی که غیرفعال شده بود ادامه میداد، که میتواند منجر به این شود که کتابخانههایی مانند Navigation Compose حتی با پشته خالی پشتیبان را مدیریت کنند و در نتیجه یکIndexOutOfBoundsException
پرتاب کنند. ( Ie3301 , b/340202286 ) - از فعالیت
1.9.1
: مشکلی درPredictiveBackHandler
برطرف شد که در آن پس از انجام بازگشت سیستم، تلاش برای انجامonBackPressed
ازOnBackPressedDispatcher
با شکست مواجه میشد. ( I5f1f8 )
نسخه 1.10.0-alpha01
26 ژوئن 2024
androidx.activity:activity:1.10.0-alpha01
، androidx.activity:activity-compose:1.10.0-alpha01
و androidx.activity:activity-ktx:1.10.0-alpha01
منتشر شدند. این نسخه در یک شعبه داخلی توسعه یافته است.
ویژگی های جدید
- اضافه شدن پشتیبانی از ویژگی های جدید
PhotoPicker
که در Android V معرفی شده اند، از جمله امکان انتخاب تصاویر به ترتیب و انتخاب تب (اعم از آلبوم ها یا تصاویر) که باید در ابتدا قابل مشاهده باشند.
نسخه 1.9
نسخه 1.9.3
16 اکتبر 2024
androidx.activity:activity:1.9.3
، androidx.activity:activity-compose:1.9.3
و androidx.activity:activity-ktx:1.9.3
منتشر شدند. نسخه 1.9.3 حاوی این commit ها است.
رفع اشکال
-
PredictiveBackHandler
دیگر پس از غیرفعال شدن کنترل کننده، پاسخ تماس خود را فعال نمی کند. این مشکلی را برطرف میکند که در آنNavHost
از Navigation Compose یکIndexOutOfBoundsException
ایجاد میکند. ( I3f75e , b/340202286 )
نسخه 1.9.2
4 سپتامبر 2024
androidx.activity:activity:1.9.2
، androidx.activity:activity-compose:1.9.2
و androidx.activity:activity-ktx:1.9.2
منتشر شدند. نسخه 1.9.2 حاوی این lthcocommit ها است.
رفع اشکال
- مشکلی را برطرف کرد که در آن Activity Compose
PredictiveBackHandler
API به کنترل ژست برگشت سیستم در فریمی که غیرفعال شده بود ادامه میداد، که میتوانست منجر به این شود که کتابخانههایی مانند Navigation Compose حتی با پشته خالی پشتیبان را مدیریت کنند و در نتیجه یکIndexOutOfBoundsException
پرتاب کنند. ( Ie3301 , b/340202286 )
نسخه 1.9.1
24 جولای 2024
androidx.activity:activity:1.9.1
، androidx.activity:activity-compose:1.9.1
و androidx.activity:activity-ktx:1.9.1
منتشر شدند. نسخه 1.9.1 شامل این commit ها است.
رفع اشکال
- مشکلی در
PredictiveBackHandler
برطرف شد که در آن پس از انجام بازگشت سیستم، تلاش برای انجامonBackPressed
ازOnBackPressedDispatcher
ناموفق بود. ( I5f1f8 )
نسخه 1.9.0
17 آوریل 2024
androidx.activity:activity:1.9.0
، androidx.activity:activity-compose:1.9.0
و androidx.activity:activity-ktx:1.9.0
منتشر شدند. نسخه 1.9.0 شامل این commit ها است.
تغییرات مهم از 1.8.0
-
ComponentActivity
اکنونOnUserLeaveHintProvider
پیاده سازی می کند تا به کامپوننت ها اجازه دهد تا برای رویدادهایonUserLeaveHint
تماس بگیرند. - APIهای
OnBackPressedCallback
،BackHandler
وPredictiveBackHandler
اکنون هنگام تماس باonBackPressedDispatcher.onBackPressed()
هنگام بازگردانی هشدار می دهند زیرا همیشه انیمیشن Back Predictive Back را شکسته می کند. برای جزئیات بیشتر به راهنمای بهترین شیوه ها مراجعه کنید. - بقیه APIهای Activity در Kotlin بازنویسی شدهاند و همه برنامههای افزودنی که قبلاً در
activity-ktx
موجود بودند بهactivity
منتقل شدهاند.activity-ktx
اکنون کاملاً خالی است.- به عنوان بخشی از تبدیل
ActivityResultLauncher
به Kotlin، متدgetContract
اکنون یک ویژگی انتزاعی Kotlin است. این یک تغییر سازگار باینری است، اما اگر اجرایActivityResultLauncher
شما در Kotlin نوشته شده باشد، منبع شکسته است.
- به عنوان بخشی از تبدیل
نسخه 1.9.0-rc01
3 آوریل 2024
androidx.activity:activity:1.9.0-rc01
، androidx.activity:activity-compose:1.9.0-rc01
و androidx.activity:activity-ktx:1.9.0-rc01
منتشر شدند. نسخه 1.9.0-rc01 حاوی این commit ها است.
به روز رسانی وابستگی
- اکنون فعالیت به Profile Installer 1.3.1 بستگی دارد.
نسخه 1.9.0-beta01
20 مارس 2024
androidx.activity:activity:1.9.0-beta01
، androidx.activity:activity-compose:1.9.0-beta01
و androidx.activity:activity-ktx:1.9.0-beta01
منتشر شدند. نسخه 1.9.0-beta01 حاوی این تعهدات است.
رفع اشکال
- یک رگرسیون عملکرد راهاندازی Activity معرفی شده در Activity
1.9.0-alpha02
که با فراخوانیOnBackPressedDispatcher
به عنوان بخشی از ایجاد فعالیت ایجاد شده بود، رفع شد. ( Ie75e3 )
نسخه 1.9.0-alpha03
7 فوریه 2024
androidx.activity:activity:1.9.0-alpha03
، androidx.activity:activity-compose:1.9.0-alpha03
و androidx.activity:activity-ktx:1.9.0-alpha03
منتشر شدند. نسخه 1.9.0-alpha03 حاوی این commit ها است.
اخطار لینت
- APIهای
OnBackPressedCallback
،BackHandler
وPredictiveBackHandler
اکنون هنگام تماس باonBackPressedDispatcher.onBackPressed()
هنگام بازگردانی هشدار می دهند زیرا همیشه انیمیشن Back Predictive Back را شکسته می کند. برای جزئیات بیشتر به راهنمای بهترین شیوه ها مراجعه کنید. ( 1e4222 , 2c950d , b/287505200 )
رفع اشکال
- اگر یک رویداد برگشتی از سیستم ارسال شود که در طول یک حرکت پیشگویانه برگشت پیشبینیشده از قبل اجرا شده است، ژست برگشت پیشبینیکننده فعلی لغو میشود و رویداد برگشت جدید برای شروع یک ژست برگشت پیشبینیکننده جدید انجام میشود. ( I3482e )
- رفع خرابی هنگام دسترسی به
onBackPressedDispatcher
از یکComponentActivity
برای اولین بار از یک رشته پس زمینه. اکنون دسترسی بهonBackPressedDispatcher
در هر رشته ای امن است. ( I79955 )
نسخه 1.9.0-alpha02
24 ژانویه 2024
androidx.activity:activity:1.9.0-alpha02
، androidx.activity:activity-compose:1.9.0-alpha02
و androidx.activity:activity-ktx:1.9.0-alpha02
منتشر شدند. نسخه 1.9.0-alpha02 حاوی این commit ها است.
تبدیل کاتلین
-
ActivityResultRegistry
در Kotlin بازنویسی شده است. این تضمین میکند که باطلپذیری ژنریکهای قراردادی که برایregister
ارسال شده است به درستی بهActivityResultLauncher
که به شما بازگردانده شده است منتقل میشود. ( I121f0 ) -
ActivityResult
در Kotlin بازنویسی شده است. افزونههایActivityResult
Kotlin که از ساختارشکنی در فیلدهایresultCode
وdata
پشتیبانی میکنند، ازactivity-ktx
بهactivity
منتقل شدهاند. ( I0565a ) - پسوندهای Kotlin
by viewModels()
برایComponentActivity
وtrackPipAnimationHintView
ازactivity-ktx
بهactivity
منتقل شده اند. آرتیفکتactivity-ktx
اکنون کاملا خالی است. ( I0a444 )
رفع اشکال
-
enableEdgeToEdge
API اکنون اطراف هر بریدگی نمایشگر را می کشد. ( a3644b , b/311173461 ) - از فعالیت
1.8.2
: موارد اضافی ارسال شده بهACTION_SYSTEM_FALLBACK_PICK_IMAGES
قرارداد فعالیت انتخابگر عکس را برطرف کرد تا بهجای استفاده از کلید اضافی با کلید"com.google.android.gms.provider.extra.PICK_IMAGES_MAX"
به درستی کلیدEXTRA_SYSTEM_FALLBACK_PICK_IMAGES_MAX
ارسال شود. اکیداً توصیه میشود اگر یک OEM هستید که یک سیستم Photo Picker را پیادهسازی میکند تا از هر دو ویژگی اضافی برای اطمینان از وسیعترین سازگاری پشتیبانی کند. ( I96a00 )
نسخه 1.9.0-alpha01
29 نوامبر 2023
androidx.activity:activity:1.9.0-alpha01
، androidx.activity:activity-compose:1.9.0-alpha01
و androidx.activity:activity-ktx:1.9.0-alpha01
منتشر شدند. نسخه 1.9.0-alpha01 حاوی این commit ها است.
ویژگی های جدید
-
ComponentActivity
اکنونOnUserLeaveHintProvider
پیاده سازی می کند تا به کامپوننت ها اجازه دهد تا برای رویدادهایonUserLeaveHint
تماس بگیرند. ( I54892 )
تغییرات API
-
ComponentActivity
در Kotlin بازنویسی شده است. ( I14f31 ) -
ActivityResultCaller
در Kotlin بازنویسی شده است. ( Ib02e4 ) -
ActivityResultLauncher
در Kotlin بازنویسی شده است. به عنوان بخشی از این تبدیل، متدgetContract
اکنون یک ویژگی انتزاعی Kotlin است. این یک تغییر سازگار باینری است، اما اگر اجرایActivityResultLauncher
شما در Kotlin نوشته شده باشد، منبع شکسته است. ( شناسه 4615 ) -
PickVisualMediaRequest
اکنون دارای حداقل سطح API 19 با قراردادPickVisualMedia
Activity Result است. ( ID6e21 )
به روز رسانی وابستگی
- اکنون فعالیت به Core
1.13.0-alpha01
بستگی دارد. ( I14f31 )
نسخه 1.8
نسخه 1.8.2
13 دسامبر 2023
androidx.activity:activity:1.8.2
، androidx.activity:activity-compose:1.8.2
و androidx.activity:activity-ktx:1.8.2
منتشر شدند. نسخه 1.8.2 حاوی این commit ها است.
رفع اشکال
- موارد اضافی ارسال شده به
ACTION_SYSTEM_FALLBACK_PICK_IMAGES
قرارداد فعالیت انتخابگر عکس را برطرف کرد تا بهجای استفاده از کلید اضافی با کلید"com.google.android.gms.provider.extra.PICK_IMAGES_MAX"
، آن را به درستی بهEXTRA_SYSTEM_FALLBACK_PICK_IMAGES_MAX
منتقل کنید. اکیداً توصیه میشود اگر یک OEM هستید که یک سیستم Photo Picker را پیادهسازی میکند تا از هر دو ویژگی اضافی برای اطمینان از وسیعترین سازگاری پشتیبانی کند. ( I96a00 )
نسخه 1.8.1
15 نوامبر 2023
androidx.activity:activity:1.8.1
، androidx.activity:activity-compose:1.8.1
و androidx.activity:activity-ktx:1.8.1
منتشر شدند. نسخه 1.8.1 حاوی این commit ها است.
رفع اشکال
-
OnBackPressedDispatcher
اکنون به ارسال بهOnBackPressedCallback
صحیح ادامه می دهد، حتی پس از اینکه یکOnBackPressedCallback
جدید در حالی که ژست برگشتی در حال مدیریت است، اضافه شد. ( ID0ff6 )
نسخه 1.8.0
4 اکتبر 2023
androidx.activity:activity:1.8.0
، androidx.activity:activity-compose:1.8.0
و androidx.activity:activity-ktx:1.8.0
منتشر شدند. نسخه 1.8.0 حاوی این commit ها است.
تغییرات مهم از 1.7.0
- برگشت پیشگو -
OnBackPressedCallback
اکنون تماس های برگشتی پیشگویانه جدیدی را برای مدیریت شروع حرکت، پیشرفت در طول حرکت، و لغو ژست برگشتی علاوه بر فراخوان قبلیhandleOnBackPressed()
برای زمانی که ژست برگشتی انجام می شود، ارائه می دهد. این همچنین باPredictiveBackHandler
Composable ارائه میشود تا رویدادهای پیشگویانه اشارهای را در Activity Compose مدیریت کند. این یک جریان از اشیاء BackEventCompat را ارائه می دهد که باید در لامبای معلقی که ارائه می کنید جمع آوری شوند:
PredictiveBackHandler { progress: Flow<BackEventCompat> ->
// code for gesture back started
try {
progress.collect { backEvent ->
// code for progress
}
// code for completion
} catch (e: CancellationException) {
// code for cancellation
}
}
ComponentActivity.onBackPressed()
اکنون به نفع APIها برای مدیریت برگشت منسوخ شده است. توسعه دهندگان اکنون باید از OnBackPressedDispatcher
استفاده کنند، نه اینکه این روش را نادیده بگیرند.
- EdgeToEdge -
ComponentActivity.enableEdgeToEdge()
اضافه شده است تا به راحتی نمایشگر لبه به لبه را به روشی سازگار با عقب تنظیم کند.
نسخه 1.8.0-rc01
20 سپتامبر 2023
androidx.activity:activity:1.8.0-rc01
، androidx.activity:activity-compose:1.8.0-rc01
و androidx.activity:activity-ktx:1.8.0-rc01
منتشر شدند. نسخه 1.8.0-rc01 حاوی این commit ها است.
نسخه 1.8.0-beta01
6 سپتامبر 2023
androidx.activity:activity:1.8.0-beta01
، androidx.activity:activity-compose:1.8.0-beta01
و androidx.activity:activity-ktx:1.8.0-beta01
منتشر شدند. نسخه 1.8.0-beta01 حاوی این تعهدات است.
بهبود اسناد و مدارک
- اسناد
BackEventCompat
را بهبود بخشید. ( aosp/2722254 )
نسخه 1.8.0-alpha07
23 آگوست 2023
androidx.activity:activity:1.8.0-alpha07
، androidx.activity:activity-compose:1.8.0-alpha07
و androidx.activity:activity-ktx:1.8.0-alpha07
منتشر شدند. نسخه 1.8.0-alpha07 حاوی این commit ها است.
ویژگی های جدید
Activity Compose یک
PredictiveBackHandler
Composable جدید اضافه کرده است تا رویدادهای پیشبینی کننده ژستهای برگشتی را مدیریت کند. این یکFlow
از اشیاءBackEventCompat
را ارائه می دهد که باید در لامبای معلقی که ارائه می کنید جمع آوری شوند:PredictiveBackHandler { progress: Flow<BackEventCompat> -> // code for gesture back started try { progress.collect { backEvent -> // code for progress } // code for completion } catch (e: CancellationException) { // code for cancellation } }
همچنین با یک اخطار زمان کامپایل از طریق قانون lint ارائه می شود تا اطمینان حاصل شود که فراخوانی های
Flow
collect()
. ( Id2773 , b/294884345 )onBackPressedDispatcher
درComponentActivity
اکنون با تنبلی مقداردهی اولیه می شود، به طوری که فقط در صورت نیاز ایجاد می شود. ( I0bf8e )
رفع اشکال
-
ComponentActivity
دیگر NPE را در Android 13 نشان نمیدهد، زمانی که یک تماسonBackPressed()
دریافت میکند و Activity قبلاًDESTROYED
است. ( Idb055 , b/291869278 ) - کاربردهای حذف شده آزمایشی
isAtLeastU()
API ( Ie9117 , b/289269026 )
نسخه 1.8.0-alpha06
21 ژوئن 2023
androidx.activity:activity:1.8.0-alpha06
، androidx.activity:activity-compose:1.8.0-alpha06
و androidx.activity:activity-ktx:1.8.0-alpha06
منتشر شدند. نسخه 1.8.0-alpha06 حاوی این commit ها است.
ویژگی های جدید
-
OnBackPressedDispatcher
اکنون به درستی همه تماسهایی را که در طول یک حرکت پیشگویانه برگشت حذف میشوند، لغو میکند. ( I3f90f )
تغییرات API
- هنگامی که
SystemBarStyle.auto
را بهenableEdgeToEdge
API ارسال می کنید، اکنون می توانید پارامتر lambdadetectDarkMode
لغو کنید تا منطق سفارشی برای تشخیص حالت شب ارائه دهید. ( aosp/2546393 , b/278263793 )
نسخه 1.8.0-alpha05
7 ژوئن 2023
androidx.activity:activity:1.8.0-alpha05
، androidx.activity:activity-compose:1.8.0-alpha05
و androidx.activity:activity-ktx:1.8.0-alpha05
منتشر شدند. این نسخه در یک شعبه داخلی توسعه یافته است.
تغییرات API
- Activity اکنون یک کلاس
BackEventCompat
را ارائه می دهد که به عنوان یک نسخه سازگار با عقب ازBackEvent
که از کلاسBackEvent
چارچوب جدا شده است، عمل می کند. - شکستن تغییر: روش های
handleOnBackStarted
وhandleOnBackProgressed
OnBackPressedCallback
اکنون به جای یک کلاسandroid.window.BackEvent
یک نمونهandroidx.activity.BackEventCompat
دریافت می کنند. APIهای معادل@VisibleForTesting
درOnBackPressedDispatcher
نیز بهروزرسانی شدهاند. - سازنده
OnBackPressedDispatcher
اکنون یک نمونه اختیاریConsumer<Boolean>
می گیرد که به صاحبان توزیع کننده اجازه می دهد هر زمان که تعداد تماس های برگشتی فعال شده از صفر به غیرصفر یا برعکس تغییر تماس دریافت کنند.
رفع اشکال
- از فعالیت
1.7.2
: رفع خرابیReportDrawn
هنگام دور شدن از صفحه قبل از فراخوانیreport
. ( Ic46f1 , b/260506820 )
نسخه 1.8.0-alpha04
10 مه 2023
androidx.activity:activity:1.8.0-alpha04
، androidx.activity:activity-compose:1.8.0-alpha04
و androidx.activity:activity-ktx:1.8.0-alpha04
منتشر شدند. این از یک شعبه داخلی منتشر شد.
رفع اشکال
- از Activity 1.7.1 : -
ReportFullyDrawExecuter
دیگر هنگام استفاده ازComponentActivity
باActivityScenario
لو نمیدهد. ( ID2ff2 , b/277434271 )
نسخه 1.8.0-alpha03
12 آوریل 2023
androidx.activity:activity:1.8.0-alpha03
، androidx.activity:activity-compose:1.8.0-alpha03
و androidx.activity:activity-ktx:1.8.0-alpha03
منتشر شدند. این از یک شعبه داخلی منتشر شد.
ویژگی های جدید
-
ComponentActivity.setUpEdgeToEdge()
اضافه شد تا به راحتی صفحه نمایش لبه به لبه را به روشی سازگار با عقب تنظیم کند.
تغییرات API
-
ComponentActivity.onBackPressed()
اکنون به نفع APIها برای مدیریت برگشت منسوخ شده است. توسعه دهندگان اکنون باید ازOnBackPressedDispatcher
استفاده کنند، نه اینکه این روش را نادیده بگیرند. ( Ibce2f , b/271596918 ) -
ComponentDialog
وComponentActivity
اکنون حاوی API عمومیinitViewTreeOwners()
هستند تا قبل از تنظیم نمای محتوا برای مقداردهی اولیه همه صاحبان درخت view استفاده شود. ( Ibdce0 , b/261314581 )
رفع اشکال
- مشکلی که در آن Fragments به اشتباه MenuHosts را باطل می کرد و باعث می شد منوهای دیگر در Activity رفتار غیرمنتظره ای داشته باشند، برطرف شد. ( I9404e , b/244336571 )
سایر تغییرات
-
ActivityResultRegister
اکنون به جای جاوا از KotlinRandom
استفاده می کند. ( I4d98f , b/272096025 )
نسخه 1.8.0-alpha02
8 مارس 2023
androidx.activity:activity:1.8.0-alpha02
، androidx.activity:activity-compose:1.8.0-alpha02
و androidx.activity:activity-ktx:1.8.0-alpha02
منتشر شدند. توسعه یافته از یک شاخه داخلی.
به روز رسانی وابستگی
- از Activity
1.7.0-rc01
: اکنون فعالیت بهLifecycle 2.6.0
بستگی دارد.
نسخه 1.8.0-alpha01
8 فوریه 2023
androidx.activity:activity:1.8.0-alpha01
، androidx.activity:activity-compose:1.8.0-alpha01
و androidx.activity:activity-ktx:1.8.0-alpha01
منتشر شدند. این از یک شاخه داخلی ساخته شده است.
ویژگی های جدید
- کلاس
OnBackPressedCallback
اکنون شامل فراخوانهای پیشبینیکننده پیشرفت بازگشتی جدید برای مدیریت شروع حرکت برگشتی، پیشرفت در طول ژست، و لغو ژست برگشتی علاوه بر تماس قبلیhandleOnBackPressed()
برای زمانی که ژست برگشتی متعهد است، میشود.
نسخه 1.7
نسخه 1.7.2
24 مه 2023
androidx.activity:activity:1.7.2
، androidx.activity:activity-compose:1.7.2
و androidx.activity:activity-ktx:1.7.2
منتشر شدند. نسخه 1.7.2 حاوی این commit ها است.
رفع اشکال
- رفع خرابی
ReportDrawn
هنگام دور شدن از صفحه قبل از فراخوانیreport
. ( Ic46f1 , b/260506820 )
نسخه 1.7.1
19 آوریل 2023
androidx.activity:activity:1.7.1
، androidx.activity:activity-compose:1.7.1
و androidx.activity:activity-ktx:1.7.1
منتشر شدند. نسخه 1.7.1 حاوی این commit ها است.
رفع اشکال
- هنگام استفاده از
ComponentActivity
باActivityScenario
،ReportFullyDrawExecuter
دیگر درز نمی کند. ( ID2ff2 , b/277434271 )
نسخه 1.7.0
22 مارس 2023
androidx.activity:activity:1.7.0
، androidx.activity:activity-compose:1.7.0
و androidx.activity:activity-ktx:1.7.0
منتشر شدند. نسخه 1.7.0 حاوی این commit ها است.
تغییرات مهم از 1.6.0
- قراردادهای فعالیت Photo Picker در
PickVisualMedia
وPickMultipleVisualMedia
بهروزرسانی شدهاند تا حاوی یک بک گراند اضافی برای زمانی کهMediaStore.ACTION_PICK_IMAGES
در دسترس نیست.ACTION_PICK_IMAGES که به OEMها و برنامههای سیستمی، مانند سرویسهای Google Play، اجازه میدهد تا با پیادهسازی سطوح عملکرد بازگشتی API، تجربه یکدستی از Photo Picker را در گستره وسیعتری از دستگاههای Android و سطوح عملکرد API ارائه دهند. در صورتی که Photo Picker قبل از استفاده ازIntent.ACTION_OPEN_DOCUMENT
در دسترس باشد، از این بازگشتی استفاده میکند، که همچنان از همه دستگاههای API 19 و بالاتر پشتیبانی میکند. -
ComponentDialog
اکنونSavedStateRegistryOwner
پیاده سازی می کند و بهSavedStateRegistry
خود دسترسی دارد وSavedStateRegistryOwner
برایViewTree
خود تنظیم می کند. اکنون میتوان از Jetpack Compose در یکComponentDialog
استفاده کرد، زیرا همLifecycleOwner
و همSavedStateRegistryOwner
که از طریق الزامات APIهایViewTree
به پنجره متصل شدهاند، برآورده میکند. -
IntentSenderRequest.Builder.setFlags()
اکنون به شما اجازه می دهد تا به جای یک پرچم، چندین پرچم را ازIntent
تنظیم کنید.
تبدیل کاتلین
تعدادی از کلاس های Activity به Kotlin تبدیل شده اند. همه کلاس های تبدیل شده هنوز سازگاری باینری خود را با نسخه های قبلی حفظ می کنند. کلاس های زیر دارای تغییرات ناسازگار منبع برای کلاس های نوشته شده در Kotlin هستند: ActivityResultRegistryOwner
، OnBackPressedDispatcherOwner
.
جدول زیر تبدیل منبع برای نسخه جدید Activity را ارائه می دهد:
فعالیت 1.5 | فعالیت 1.6 |
---|---|
override fun getActivityResultRegistry() = activityResultRegistry | override val activityResultRegistry = activityResultRegistry |
override fun getOnBackPressedDispatcher() = onBackPressedDispatcher | override val onBackPressedDispatcher = onBackPressedDispatcher |
این کلاسها نیز به Kotlin تبدیل شدند، اما همچنان با منبع سازگار هستند: ContextAware
، ContextAwareHelper
، OnContextAvailableListener
، IntentSenderRequest
، و OnBackPressedDispatcher
API های FullyDrawnReporter
ComponentActivity
اکنون یک نمونه FullyDrawnReporter
را ارائه می دهد که به چندین مؤلفه اجازه می دهد زمانی که برای تعامل آماده هستند گزارش دهند. ComponentActivity
قبل از فراخوانی reportFullyDrawn()
از طرف شما منتظر می ماند تا تمام کامپوننت ها تکمیل شوند. این APIها از الزامات زمانبندی برای شما مراقبت میکنند و نیازی به فراخوانی به عنوان بخشی از تماس onDraw
ندارند.
این APIها تشویق می شوند تا فعال شوند:
- زمانی که راهاندازی کامل میشود، زمان اجرای Android را علامتگذاری کنید تا مطمئن شوید که تمام کد اجرا شده در طول یک دنباله راهاندازی چند فریمی گنجانده شده است و برای جمعآوری پسزمینه اولویتبندی میشود.
- هنگامی که برنامه شما باید به طور کامل برای معیارهای راه اندازی در نظر گرفته شود، سیگنال Macrobenchmark و Play Vitals را نشان می دهد، بنابراین می توانید عملکرد را ردیابی کنید.
سه API Activity Compose اضافه شدهاند تا استفاده از FullyDrawnReporter
از تک تک اجزای سازنده راحتتر کند:
-
ReportDrawn
نشان می دهد که composable شما بلافاصله برای تعامل آماده است. -
ReportDrawnWhen
یک گزاره می گیرد (یعنیlist.count > 0
) تا نشان دهد که سازنده شما چه زمانی برای تعامل آماده است. -
ReportDrawnAfter
یک روش تعلیق را انتخاب می کند که وقتی کامل شد، نشان می دهد که شما برای تعامل آماده هستید.
به روز رسانی های وابستگی
- اکنون فعالیت به Lifecycle
2.6.1
بستگی دارد. ( 8fc31d ) - اکنون فعالیت به ProfileInstaller
1.3.0
بستگی دارد. ( 83d3b1 )
نسخه 1.7.0-rc01
8 مارس 2023
androidx.activity:activity:1.7.0-rc01
، androidx.activity:activity-compose:1.7.0-rc01
و androidx.activity:activity-ktx:1.7.0-rc01
منتشر شدند. نسخه 1.7.0-rc01 حاوی این commit ها است.
به روز رسانی وابستگی
- اکنون فعالیت به
Lifecycle 2.6.0
بستگی دارد.
نسخه 1.7.0-beta02
22 فوریه 2023
androidx.activity:activity:1.7.0-beta02
، androidx.activity:activity-compose:1.7.0-beta02
و androidx.activity:activity-ktx:1.7.0-beta02
منتشر شدند. نسخه 1.7.0-beta02 حاوی این تعهدات است.
تغییرات API
- کنش و موارد اضافی که توسط قراردادهای
PickVisualMedia
وPickMultipleVisualMedia
بهعنوان بازگشتی برای زمانی کهMediaStore.ACTION_PICK_IMAGES
در دسترس نیست استفاده میشود.ACTION_PICK_IMAGES اکنون ثابتهای عمومی هستند که ثبات API را برای OEMها و برنامههای سیستمی که میخواهند تجربه یکدستی از Photo Picker ارائه دهند، فراهم میکنند. اجرای این بازگشتی هنوز فقط به برنامه های سیستمی محدود می شود. ( ICD320 )
نسخه 1.7.0-beta01
8 فوریه 2023
androidx.activity:activity:1.7.0-beta01
، androidx.activity:activity-compose:1.7.0-beta01
و androidx.activity:activity-ktx:1.7.0-beta01
منتشر شدند. نسخه 1.7.0-beta01 حاوی این تعهدات است.
ویژگی های جدید
-
IntentSenderRequest.Builder.setFlags()
اکنون به شما اجازه می دهد تا به جای یک پرچم، چندین پرچم را ازIntent
تنظیم کنید. ( Iac04c )
رفع اشکال
- بازگشتی برای
PickVisualMedia
برای زمانی که Framework Photo Picker در دسترس نیست، اکنون به درستی مدیریت را به برنامه های نصب شده در تصویر سیستم دستگاه محدود می کند. ( If8ae6 )
تبدیل کاتلین
-
ActivityResultRegistryOwner
اکنون در Kotlin نوشته شده است. این یک تغییر منبع ناسازگار برای کلاسهایی است که در Kotlin نوشته شدهاند - اکنون باید به جای اجرای تابعgetActivityResultRegistry()
ویژگیactivityResultRegistry
را لغو کنید. ( I0b00e ) -
OnBackPressedDispatcherOwner
اکنون در Kotlin نوشته شده است. این یک تغییر منبع ناسازگار برای کلاسهایی است که در Kotlin نوشته شدهاند - اکنون باید ویژگیonBackPressedDispatcher
به جای اجرای تابعgetOnBackPressedDispatcher
قبلی لغو کنید. ( Ia277d ) -
ContextAware
،ContextAwareHelper
،OnContextAvailableListener
،IntentSenderRequest
وOnBackPressedDispatcher
اکنون در Kotlin نوشته شده اند. ( I1a73e ، Iada92 ، aosp/2410754 ، I18ac7 ، b/257291701 )
نسخه 1.7.0-alpha04
25 ژانویه 2023
androidx.activity:activity:1.7.0-alpha04
، androidx.activity:activity-compose:1.7.0-alpha04
و androidx.activity:activity-ktx:1.7.0-alpha04
منتشر شدند. نسخه 1.7.0-alpha04 حاوی این commit ها است.
ویژگی های جدید
- قراردادهای
PickVisualMedia
وPickMultipleVisualMedia
Activity Result اکنون در مواردی که سیستم Android Photo Picker (به عنوان مثالMediaStore.ACTION_PICK_IMAGES
) در دسترس نباشد، از Photo Picker ارائه شده از خدمات Google Play استفاده خواهد کرد. APIisPhotoPickerAvailable()
که فقط سیستم Android را تشخیص میدهد به شرطی که Photo Picker منسوخ شده باشد. توصیه میشود از API جدیدisPhotoPickerAvailable(Context)
استفاده کنید، که اگر یکی از Photo Picker در دسترس باشد، باز خواهد گشت. ( I55be6 )
نسخه 1.7.0-alpha03
11 ژانویه 2023
androidx.activity:activity:1.7.0-alpha03
، androidx.activity:activity-compose:1.7.0-alpha03
و androidx.activity:activity-ktx:1.7.0-alpha03
منتشر شدند. نسخه 1.7.0-alpha03 حاوی این commit ها است.
ویژگی های جدید
-
ComponentDialog
اکنونSavedStateRegistryOwner
پیاده سازی می کند و بهSavedStateRegistry
خود دسترسی دارد وSavedStateRegistryOwner
برای ViewTree خود تنظیم می کند. اکنون میتوان از Jetpack Compose در یکComponentDialog
استفاده کرد، زیرا همLifecycleOwner
و همSavedStateRegistryOwner
که از طریق الزامات APIهای ViewTree به پنجره متصل شدهاند، برآورده میکند. ( Idca17 , I73468 b/261162296 )
تغییرات API
- یک
ReportDrawn
قابل ترکیب اضافه شد که بلافاصله فعالیت را به عنوان آماده برای فراخوانیreportFullyDrawn
علامت گذاری می کند. ( Ic5b14 , b/259687964 )
تبدیل کاتلین
- کلاس های
ActvitiyResultCallback
وOnBackPressedCallback
هر دو به Kotlin تبدیل شده اند و در عین حال سازگاری منبع و باینری را حفظ می کنند. ( Ifc5e5 , Ide1b0 , b/257291701 )
نسخه 1.7.0-alpha02
24 اکتبر 2022
androidx.activity:activity:1.7.0-alpha02
، androidx.activity:activity-compose:1.7.0-alpha02
و androidx.activity:activity-ktx:1.7.0-alpha02
منتشر شدند. نسخه 1.7.0-alpha02 حاوی این commit ها است.
رفع اشکال
- از Activity
1.6.1
: مشکل راهاندازی نشدن قراردادPickMultipleVisualMedia
Activity Result در دستگاههای Android R هنگام استفاده از مقدار پیشفرض برایmaxItems
برطرف شد. ( Ie2776 , b/249182130 )
نسخه 1.7.0-alpha01
5 اکتبر 2022
androidx.activity:activity:1.7.0-alpha01
، androidx.activity:activity-compose:1.7.0-alpha01
و androidx.activity:activity-ktx:1.7.0-alpha01
منتشر شدند. نسخه 1.7.0-alpha01 حاوی این commit ها است.
API های FullyDrawnReporter
ComponentActivity
اکنون یک نمونه FullyDrawnReporter
را ارائه می دهد که به چندین مؤلفه اجازه می دهد زمانی که برای تعامل آماده هستند گزارش دهند. ComponentActivity
قبل از فراخوانی reportFullyDrawn()
از طرف شما منتظر می ماند تا تمام کامپوننت ها تکمیل شوند. این APIها از الزامات زمانبندی برای شما مراقبت میکنند و نیازی به فراخوانی به عنوان بخشی از تماس onDraw
ندارند.
این APIها تشویق می شوند تا فعال شوند:
- زمانی که راهاندازی کامل میشود، زمان اجرای Android را علامتگذاری کنید تا مطمئن شوید که تمام کد اجرا شده در طول یک دنباله راهاندازی چند فریمی گنجانده شده است و برای جمعآوری پسزمینه اولویتبندی میشود.
- هنگامی که برنامه شما باید به طور کامل برای معیارهای راه اندازی در نظر گرفته شود، سیگنال Macrobenchmark و Play Vitals را نشان می دهد، بنابراین می توانید عملکرد را ردیابی کنید.
دو API Activity Compose اضافه شدهاند تا استفاده از FullyDrawnReporter
از اجزای سازنده منفرد راحتتر باشد:
-
ReportDrawnWhen
یک گزاره می گیرد (یعنیlist.count > 0
) تا نشان دهد که سازنده شما چه زمانی برای تعامل آماده است. -
ReportDrawnAfter
یک روش تعلیق را انتخاب می کند که وقتی کامل شد، نشان می دهد که شما برای تعامل آماده هستید.
نسخه 1.6.1
نسخه 1.6.1
24 اکتبر 2022
androidx.activity:activity:1.6.1
، androidx.activity:activity-compose:1.6.1
و androidx.activity:activity-ktx:1.6.1
منتشر شدند. نسخه 1.6.1 حاوی این commit ها است.
رفع اشکال
- مشکل راهاندازی نشدن قرارداد
PickMultipleVisualMedia
Activity Result در دستگاههای Android R هنگام استفاده از مقدار پیشفرض برایmaxItems
برطرف شد. ( Ie2776 , b/249182130 )
نسخه 1.6.0
نسخه 1.6.0
21 سپتامبر 2022
androidx.activity:activity:1.6.0
، androidx.activity:activity-compose:1.6.0
و androidx.activity:activity-ktx:1.6.0
منتشر شدند. نسخه 1.6.0 حاوی این commit ها است.
تغییرات مهم از 1.5.0
-
ActivityResultContracts.PickVisualMedia
وActivityResultContracts.PickMultipleVisualMedia
برای ارائه یک قرارداد سازگار با گذشته کهMediaStore.ACTION_PICK_IMAGES
استفاده می کند.ACTION_PICK_IMAGES زمانی که Photo Picker در دسترس است وIntent.ACTION_OPEN_DOCUMENT
زمانی که در دسترس نیست اضافه شد. -
OnBackInvokedCallback
در Android 13 درOnBackPressedDispatchers
ارائه شده توسطComponentActivity
وComponentDialog
یکپارچه کرد. این تضمین می کند که تمام API ها در هنگام فعال کردن یک ژست پیش بینی کننده پشتی ، روی کارOnBackPressedDispatcher
استفاده می کنند.
نسخه 1.6.0-RC02
7 سپتامبر 2022
androidx.activity:activity:1.6.0-rc02
، androidx.activity:activity-compose:1.6.0-rc02
و androidx.activity:activity-ktx:1.6.0-rc02
منتشر می شود. نسخه 1.6.0-RC02 شامل این تعهدات است.
رفع اشکال
-
OnBackPressedDispatcher
اکنون به جایPRIORITY_OVERLAY
OnBackInvokedCallback
باPRIORITY_DEFAULT
به ثبت می رساند. ( i3901f ) - کلاس هایی که
ComponentActivity
را گسترش می دهند ، اکنون همیشه هر دو تماس تلفنیonMultiWindowModeChanged()
را اعزام می کنند. ( IC4D85 ) - هنگامی که تماس
launch
هرException
به وجود می آورد و پاسخ به تماس بدونLifecycleOwner
ثبت می کندActivityResultCallback
ActivityResultRegistry
. ( ia7ff7 ، b/238350794 ) -
ComponentActivity
اکنون بدون نیاز به تماس با عملکرد فوق العاده در فعالیت شما ، به درستی تماس می گیرد. ( IE33C5 ، B/238057118 )
به روزرسانی وابستگی
- کتابخانه
Activity
اکنون به چرخه عمر2.5.1
بستگی دارد. ( IF6697 )
نسخه 1.6.0-RC01
24 آگوست 2022
androidx.activity:activity:1.6.0-rc01
، androidx.activity:activity-compose:1.6.0-rc01
و androidx.activity:activity-ktx:1.6.0-rc01
منتشر می شود. نسخه 1.6.0-RC01 شامل این تعهدات است.
رفع اشکال
- اولیه سازی یک
OnBackPressedDispatcher
با استفاده از نسخه های SDK قبل از 33 ، دیگر باعث ایجادClassVerificationError
نمی شود. ( IC32E1 ) - کلاس هایی که از
ComponentActivity
'onPictureInPictureModeChanged()
پاسخ می دهند ، اکنون همیشه تماس های خود را ارسال می کنند. ( IB7FDB )
نسخه 1.6.0-beta01
10 آگوست 2022
androidx.activity:activity:1.6.0-beta01
، androidx.activity:activity-compose:1.6.0-beta01
، و androidx.activity:activity-ktx:1.6.0-beta01
منتشر می شود. نسخه 1.6.0-beta01 شامل این تعهدات است.
تغییرات API
- روشهای
startActivityForResult
وstartIntentSenderForResult
را درComponentActivity
با@NonNull
نشان داده است زیرا عبورnull
همیشه منجر به تصادف شده است. ( id2a25 ، b/231476082 )
رفع اشکال
- از فعالیت
1.5.1
:ActivityResultRegistry
دیگر نتیجه ای را بهActivityResultCallback
بازگرداند وقتی تماسlaunch
هرException
انجام می دهد و پاسخ به تماس بدونLifecycleOwner
ثبت می شود. ( ia7ff7 ، b/238350794 ) - از فعالیت
1.5.1
:ComponentActivity
اکنون به درستی تماس های منو را بهonPrepareOptionMenu()
،onCreateOptionsMenu()
وonOptionsItemSelected()
بدون نیاز به تماس با عملکرد فوق العاده ارسال می کند. ( IE33C5 ، B/238057118 )
به روزرسانی وابستگی
- از فعالیت
1.5.1
: کتابخانهActivity
اکنون به نسخهLifecycle
2.5.1
بستگی دارد. ( IF6697 )
نسخه 1.6.0-alpha05
15 ژوئن 2022
androidx.activity:activity:1.6.0-alpha05
، androidx.activity:activity-compose:1.6.0-alpha05
، و androidx.activity:activity-ktx:1.6.0-alpha05
منتشر می شود. نسخه 1.6.0-alpha05 در یک شعبه خصوصی قبل از انتشار ساخته شده و هیچ تعهد عمومی ندارد.
تغییرات API
-
minCompileSdk
اکنون 33 ساله است که با Tiramisu Beta 3 SDK هماهنگ است
رفع اشکال
- تصادف بر روی دستگاه های قدیمی هنگام انجام پسوند SDK برای
ActivityResultContract
PickVisualMedia
resultContract را بررسی کنید تا اکنون باید باACTION_OPEN_DOCUMENT
روی دستگاه های دارای Android 10 و پایین کار کند.
نسخه 1.6.0-alpha04
18 مه 2022
androidx.activity:activity:1.6.0-alpha04
و androidx.activity:activity-ktx:1.6.0-alpha04
منتشر می شود.
رفع اشکال
- خطایی را در
PickVisualMediaRequest
برطرف کرد که در آن تلاش برای ایجاد یک درخواست ، چه از طریق سازنده یا عملکرد سطح بالای کوتلین ، منجر به سرریز پشته می شود. -
OnBackInvokedCallback
در Android 13 Dev Beta 2 درOnBackPressedDispatcher
ارائه شده توسطComponentDialog
یکپارچه کرد. این تضمین می کند که تمام API ها در هنگام فعال کردن یک ژست پیش بینی کننده پشتی ، روی کارOnBackPressedDispatcher
استفاده می کنند.
نسخه 1.6.0-alpha03
27 آوریل 2022
androidx.activity:activity:1.6.0-alpha03
، androidx.activity:activity-compose:1.6.0-alpha03
و androidx.activity:activity-ktx:1.6.0-alpha03
منتشر می شود.
- توجه: این نسخه فقط در برابر توسعه دهنده Android 13 Beta 1 SDK کامپایل خواهد شد.
ویژگی های جدید
- اضافه شده
ActivityResultContracts.PickVisualMedia
وActivityResultContracts.PickMultipleVisualMedia
برای ارائه یک قرارداد سازگار با عقب کهMediaStore.ACTION_PICK_IMAGES
استفاده می کند. ACTION_PICK_IMAGES هنگامی که انتخاب کننده عکس در دسترس است وIntent.ACTION_OPEN_DOCUMENT
ندارد. -
OnBackInvokedCallback
در Android 13 Dev Beta 1 درOnBackPressedDispatcher
ارائه شده توسطComponentActivity
یکپارچه کرد. این تضمین می کند که تمام API ها در هنگام فعال کردن یک ژست پیش بینی کننده پشتی ، روی کارOnBackPressedDispatcher
استفاده می کنند.
نسخه 1.6.0-alpha01
23 مارس 2022
androidx.activity:activity:1.6.0-alpha01
، androidx.activity:activity-compose:1.6.0-alpha01
، و androidx.activity:activity-ktx:1.6.0-alpha01
منتشر می شود.
- توجه: این نسخه فقط در برابر Android 13 Developer Preview 2 SDK کامپایل خواهد شد.
ویژگی های جدید
- تغییرات یکپارچه در Android 13 Dev Preview 2 به
ComponentActivity
.
نسخه 1.5.1
نسخه 1.5.1
27 جولای 2022
androidx.activity:activity:1.5.1
، androidx.activity:activity-compose:1.5.1
، و androidx.activity:activity-ktx:1.5.1
منتشر می شود. نسخه 1.5.1 شامل این تعهدات است.
رفع اشکال
ActivityResultRegistry
دیگر نتیجه ای را بهActivityResultCallback
باز نمی گرداند وقتیlaunch()
تماس هرگونهException
را انجام می دهد و پاسخ به تماس بدونLifecycleOwner
ثبت می شود. ( ia7ff7 ، b/238350794 )ComponentActivity
اکنون به طور صحیح مکالمه منوی را بهonPrepareOptionMenu()
،onCreateOptionsMenu()
وonOptionsItemSelected()
بدون نیاز به تماس با عملکرد فوق العاده ارسال می کند. ( IE33C5 ، B/238057118 )
به روز رسانی وابستگی
- کتابخانه
Activity
اکنون به چرخه عمر2.5.1
بستگی دارد. ( IF6697 )
نسخه 1.5.0
نسخه 1.5.0
29 ژوئن 2022
androidx.activity:activity:1.5.0
، androidx.activity:activity-compose:1.5.0
و androidx.activity:activity-ktx:1.5.0
منتشر می شود. نسخه 1.5.0 شامل این تعهدات است.
تغییرات مهم از 1.4.0
- ComponentDialog -
ComponentDialog
یک زیر کلاس ازDialog
است که شامل یکOnBackPressedDispatcher
است که هنگام فشار دادن دکمه برگشت سیستم و گفتگو قابل مشاهده است. نکته مهم این است که این زیر کلاس همچنینViewTreeOnBackPressedDispatcherOwner
تنظیم می کند ، و به نمایش می دهد یک روش عمومی برای بازیابی توزیع کننده صحیح اعم از موجود در یکComponentActivity
یا یکComponentDialog
. - رابط های پاسخ به تماس -
ComponentActivity
اکنون مجموعه ای از رابط های پاسخ به تماس ماژولار را پیاده سازی می کند که می توانند به جای تماس با فعالیت هایActivity
استفاده شوند. این رابط ها شامل موارد زیر هستند:OnNewIntentProvider
،OnConfigurationChangedProvider
،OnTrimMemoryProvider
،OnPictureInPictureModeChangedProvider
،OnMultiWindowModeChangedProvider
- ادغام CreationExtras -
ComponentActivity
اکنون این توانایی را دارد که یکViewModelProvider.Factory
ارائه دهد. از طریقCreationExtras
از طریق چرخه عمر2.5.0
.
تغییرات دیگر
- سازنده NO Parameter for
ActivityResultContracts.CreateDocument
با یک سازنده جدید که یک نوع میمون بتونی (به عنوانIntent.ACTION_CREATE_DOCUMENT
، "تصویر/png") را می گیرد ، مستهلک شده و جایگزین شده است.
نسخه 1.5.0-RC01
11 مه 2022
androidx.activity:activity:1.5.0-rc01
، androidx.activity:activity-compose:1.5.0-rc01
، و androidx.activity:activity-ktx:1.5.0-rc01
بدون تغییر از 1.5.0-beta01 منتشر نمی شود. نسخه 1.5.0-RC01 شامل این تعهدات است.
نسخه 1.5.0-beta01
20 آوریل 2022
androidx.activity:activity:1.5.0-beta01
، androidx.activity:activity-compose:1.5.0-beta01
، و androidx.activity:activity-ktx:1.5.0-beta01
منتشر می شود. نسخه 1.5.0-beta01 شامل این تعهدات است.
به روزرسانی های وابستگی
- فعالیت اکنون به چرخه عمر
2.4.0-beta01
بستگی دارد.
نسخه 1.5.0-alpha05
6 آوریل 2022
androidx.activity:activity:1.5.0-alpha05
، androidx.activity:activity-compose:1.5.0-alpha05
، و androidx.activity:activity-ktx:1.5.0-alpha05
منتشر می شود. نسخه 1.5.0-alpha05 شامل این تعهدات است.
رفع اشکال
- Onpanelclosed ()
ComponentActivity
onPanelClosed()
اکنون نیز فوق العادهonPanelClosed()
نیز صدا می کند و مشکلی را برطرف می کند که در آن روشonContextMenuClosed
نامیده نمی شود. ( ib6f77 )
نسخه 1.5.0-alpha04
23 مارس 2022
androidx.activity:activity:1.5.0-alpha04
، androidx.activity:activity-compose:1.5.0-alpha04
، و androidx.activity:activity-ktx:1.5.0-alpha04
منتشر می شود. نسخه 1.5.0-alpha04 شامل این تعهدات است.
رفع اشکال
-
SavedStateViewFactory
اکنون از استفاده ازCreationExtras
پشتیبانی می کند حتی وقتی که با یکSavedStateRegistryOwner
اولیه انجام شد. در صورت ارائه اضافی ، استدلال های اولیه نادیده گرفته می شوند. ( i6c43b ، b/224844583 )
نسخه 1.5.0-alpha03
23 فوریه 2022
androidx.activity:activity:1.5.0-alpha03
، androidx.activity:activity-compose:1.5.0-alpha03
، و androidx.activity:activity-ktx:1.5.0-alpha03
منتشر می شود. نسخه 1.5.0-alpha03 شامل این تعهدات است.
تغییرات API
- اکنون می توانید
CreationExtras
by viewModels()
به فعالیت منتقل کنید ( I6A3E6 ، B/217600303 )
نسخه 1.5.0-alpha02
9 فوریه 2022
androidx.activity:activity:1.5.0-alpha02
، androidx.activity:activity-compose:1.5.0-alpha02
، و androidx.activity:activity-ktx:1.5.0-alpha02
منتشر می شود. نسخه 1.5.0-alpha02 شامل این تعهدات است.
ویژگی های جدید
-
ComponentActivity
اکنون رابطOnPictureInPictureModeChangedProvider
را پیاده سازی می کند تا به هر مؤلفه ای اجازه دهد تا حالت تغییر تصویر را تغییر دهد. ( i9f567 ) -
ComponentActivity
اکنون رابطOnMultiWindowModeChangedProvider
را پیاده سازی می کند تا به هر مؤلفه ای امکان دریافت وقایع تغییر حالت چند پنجره را بدهد. ( i62d91 )
نسخه 1.5.0-alpha01
26 ژانویه 2022
androidx.activity:activity:1.5.0-alpha01
، androidx.activity:activity-compose:1.5.0-alpha01
و androidx.activity:activity-ktx:1.5.0-alpha01
منتشر می شود. نسخه 1.5.0-alpha01 شامل این تعهدات است.
ویژگی های جدید
-
ComponentActivity
اکنون با ViewModel CreationExtras ادغام شده است ، به عنوان بخشی از چرخه عمر2.5.0-alpha01
معرفی شده است. ( IE7E00 ، b/207012584 ) - اضافه شده
ComponentDialog
، یک زیر کلاس ازDialog
که شامل یکOnBackPressedDispatcher
است ، که هنگام فشار دادن دکمه پشت سیستم در هنگام گفتگو ، تحت فشار قرار می گیرد ، فراخوانی می شود. نکته مهم این است که این زیر کلاس همچنینViewTreeOnBackPressedDispatcherOwner
تنظیم می کند ، و به نمایش می دهد یک روش عمومی برای بازیابی توزیع کننده صحیح اعم از موجود در یکComponentActivity
یا یکComponentDialog
. ( i8a1bc ) -
ComponentActivity
اکنون رابط جدیدOnNewIntentProvider
را پیاده سازی می کند تا هر مؤلفه ای بتواند این رویدادها را دریافت کند. ( if1f8b ) -
ComponentActivity
اکنون رابط جدیدOnConfigurationChangedProvider
را پیاده سازی می کند تا هر مؤلفه ای بتواند این رویدادها را دریافت کند. ( if623b ) -
ComponentActivity
اکنون رابط جدیدOnTrimMemoryProvider
را پیاده سازی می کند تا هر مؤلفه ای بتواند این رویدادها را دریافت کند. ( IA9295 )
تغییرات API
- سازنده NO Parameter for
ActivityResultContracts.CreateDocument
با یک سازنده جدید که یک نوع میمون بتونی (به عنوانIntent.ACTION_CREATE_DOCUMENT
،"image/png"
) را می گیرد ، مستهلک شده و جایگزین شده است. ( i2bec6 ) -
OnBackPressedDispatcherOwner
مرتبط با یک نمای اکنون می تواند از طریقViewTreeOnBackPressedDispatcherOwner
بازیابی شود ، نه اینکه به بازیگرانContext
اعتماد کنید. ( i74685 )
رفع اشکال
- برای اولین بار از طریق تماس با
registerForActivityResult()
یا تماس برگشتی به یکLifecycleObserver
که به عنوان بخشی ازinit
از یکComponentActivity
اضافه شده است ، تصادف هنگام دسترسی به یکViewModel
را برطرف کرد. ( ife83f )
نسخه 1.4.0
نسخه 1.4.0
27 اکتبر 2021
androidx.activity:activity:1.4.0
، androidx.activity:activity-compose:1.4.0
و androidx.activity:activity-ktx:1.4.0
منتشر می شود. نسخه 1.4.0 شامل این تعهدات است.
تغییرات مهم از 1.3.0
- Androidx
ComponentActivity
اکنون رابطMenuHost
پیاده سازی می کند. این امر به هر مؤلفه ای اجازه می دهد تا با افزودن یک نمونهMenuProvider
به فعالیت ، موارد منو را بهActionBar
اضافه کند. هرMenuProvider
می تواند به صورت اختیاری با یکLifecycle
اضافه شود که به طور خودکار دید آن موارد منو را بر اساس حالتLifecycle
کنترل می کند و هنگام از بین رفتنLifecycle
، حذفMenuProvider
را کنترل می کند. - کلاس
ActivityResultContract
در کوتلین بازنویسی شده است تا اطمینان حاصل شود که توسعه دهندگان در حال نوشتن قراردادهای سفارشی در کوتلین می توانند باطل صحیح را برای کلاسهای ورودی و خروجی خود تعریف کنند. - کلاس
ActivityResultContracts
و قراردادهای آن در کوتلین بازنویسی شده است تا از قابلیت تهی مناسب اطمینان حاصل شود.
نسخه 1.4.0-RC01
13 اکتبر 2021
androidx.activity:activity:1.4.0-rc01
، androidx.activity:activity-compose:1.4.0-rc01
، و androidx.activity:activity-ktx:1.4.0-rc01
منتشر می شود. نسخه 1.4.0-RC01 شامل این تعهدات است.
رفع اشکال
- هنگامی که تماس
launch
هرException
انجام می دهد ، دیگرActivityResultRegistry
دیگر نتیجه ای را بهActivityResultCallback
باز نمی گرداند. ( IF4F91 ، B/200845664 )
نسخه 1.4.0-beta01
29 سپتامبر 2021
androidx.activity:activity:1.4.0-beta01
، androidx.activity:activity-compose:1.4.0-beta01
، و androidx.activity:activity-ktx:1.4.0-beta01
منتشر می شود. نسخه 1.4.0-beta01 شامل این تعهدات است.
تغییرات API
- نوع را برای
ActivityResultContracts.OpenMultipleDocuments
وActivityResultContracts.GetMultipleContents
که باعث استفاده از نوع خروجیList<? extends Uri>
. ( if71de ) - ثابت های عمومی در
ActivityResultContracts.StartActivityForResult
،ActivityResultContracts.StartIntentSenderForResult
، وActivityResultContracts.RequestMultiplePermissions
اکنون هنگام استفاده از Kotlin از طریق اشیاءCompanion
خود در حال حاضر قابل دسترسی هستند. ( AOSP/1832555 )
به روز رسانی اسناد
- پیام استهلاک برای API که اکنون توسط API های نتیجه فعالیت ، یعنی
startActivityForResult
،startIntentSenderForResult
،onActivityResult
،requestPermissions
، وonRequestPermissionsResult
انجام شده است ، همه با جزئیات بیشتر گسترش یافته اند. ( CCE80F )
نسخه 1.4.0-alpha02
15 سپتامبر 2021
androidx.activity:activity:1.4.0-alpha02
، androidx.activity:activity-compose:1.4.0-alpha02
و androidx.activity:activity-ktx:1.4.0-alpha02
منتشر می شود. نسخه 1.4.0-alpha02 شامل این تعهدات است.
ویژگی های جدید
- Artifact
activity-compose
در حال حاضر حاوی یک خطای راه اندازیLaunchDuringComposition
است که مانع از فراخوانی روشlaunch
ActivityResultLauncher
به عنوان بخشی از ترکیب می شود به عنوان ترکیب باید عاری از اثر جانبی باشد. برای رسیدگی به عوارض جانبی از API استفاده کنید. ( 7c2bbe ، b/191347220 )
تغییرات API
- کلاس
ActivityResultContract
در کوتلین بازنویسی شده است تا اطمینان حاصل شود که توسعه دهندگان در حال نوشتن قراردادهای سفارشی در کوتلین می توانند باطل صحیح را برای کلاسهای ورودی و خروجی خود تعریف کنند. ( i8a8f5 ) - کلاس
ActivityResultContracts
و قراردادهای آن در کوتلین بازنویسی شده است تا از قابلیت تهی مناسب اطمینان حاصل شود. ( i69802 )
نسخه 1.4.0-alpha01
1 سپتامبر 2021
androidx.activity:activity:1.4.0-alpha01
، androidx.activity:activity-compose:1.4.0-alpha01
، و androidx.activity:activity-ktx:1.4.0-alpha01
منتشر می شود. نسخه 1.4.0-alpha01 شامل این تعهدات است.
ویژگی های جدید
- Androidx
ComponentActivity
اکنون رابطMenuHost
پیاده سازی می کند. این به هر مؤلفه ای اجازه می دهد تا با افزودن یک نمونهMenuProvider
به فعالیت ، موارد منو را بهActionBar
اضافه کند. هرMenuProvider
می تواند به صورت اختیاری با یکLifecycle
اضافه شود که به طور خودکار دید آن موارد منو را بر اساس حالتLifecycle
کنترل می کند و هنگام از بین رفتنLifecycle
، حذفMenuProvider
را کنترل می کند. ( i3b608 ):
/**
* Using the addMenuProvider() API directly in your Activity
**/
class ExampleActivity : ComponentActivity(R.layout.activity_example) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Add menu items without overriding methods in the Activity
addMenuProvider(object : MenuProvider {
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
// Add menu items here
menuInflater.inflate(R.menu.example_menu, menu)
}
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
// Handle the menu selection
return true
}
})
}
}
/**
* Using the addMenuProvider() API in a Fragment
**/
class ExampleFragment : Fragment(R.layout.fragment_example) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
// The usage of an interface lets you inject your own implementation
val menuHost: MenuHost = requireActivity()
// Add menu items without using the Fragment Menu APIs
// Note how we can tie the MenuProvider to the viewLifecycleOwner
// and an optional Lifecycle.State (here, RESUMED) to indicate when
// the menu should be visible
menuHost.addMenuProvider(object : MenuProvider {
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
// Add menu items here
menuInflater.inflate(R.menu.example_menu, menu)
}
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
// Handle the menu selection
return true
}
}, viewLifecycleOwner, Lifecycle.State.RESUMED)
}
تغییرات رفتار
-
ActivityResultRegistry
اکنون هنگام تلاش برایlaunch()
در یکActivityResultLauncher
که ثبت نشده است یا ثبت نام نکرده است ،IllegalStateException
است. ( ida75d ، b/192567522 )
سهم خارجی
نسخه 1.3.1
نسخه 1.3.1
4 آگوست 2021
androidx.activity:activity:1.3.1
، androidx.activity:activity-compose:1.3.1
، و androidx.activity:activity-ktx:1.3.1
منتشر می شود. نسخه 1.3.1 شامل این تعهدات است.
به روزرسانی های وابستگی
- فعالیت اکنون به Kotlin
1.5.21
بستگی دارد. - آهنگسازی فعالیت اکنون به آهنگسازی
1.0.1
بستگی دارد.
نسخه 1.3.0
نسخه 1.3.0
28 ژوئیه 2021
androidx.activity:activity:1.3.0
، androidx.activity:activity-compose:1.3.0
و androidx.activity:activity-ktx:1.3.0
منتشر می شود. نسخه 1.3.0 شامل این تعهدات است.
تغییرات مهم از 1.2.0
- Active Compose Artifact -
activity-compose
-Composion روش پسوندsetContent
برای میزبانی UI Jetpack شما در یک فعالیت فراهم می کند و بسته بندی های خاصی را برای تعامل با API هایComponentActivity
برای دستیابی به دکمه پشت سیستم و API های نتیجه فعالیت ایجاد می کند. برای جزئیات بیشتر به مستندات مراجعه کنید. - CATTREVIDEO CONTRAPT -
CaptureVideo
ActivityResultContract
جایگزین قراردادTakeVideo
در حال حاضر مستهلک شده است و یک موفقیت بولی را که در بسیاری از برنامه های دوربین کار می کند ، برمی گرداند. - ردیابی تصویر در تصویر در تصویر -کاربران
activity-ktx
هم اکنون می توانند از روش توسعهtrackPipAnimationHintView
درActivity
استفاده کنند تا به طور خودکارPictureInPictureParams
با موقعیت جدید نمای بازسازی کنند زیرا موقعیت نسبت به پنجره را تغییر می دهد.
نسخه 1.3.0-RC02
14 جولای 2021
androidx.activity:activity:1.3.0-rc02
، androidx.activity:activity-compose:1.3.0-rc02
، و androidx.activity:activity-ktx:1.3.0-rc02
منتشر می شود. نسخه 1.3.0-RC02 شامل این تعهدات است.
رفع اشکال
- اکنون تماس های
ActivityResultRegistry
به درستی ذخیره شده و بازیابی می شوند ، بنابراین تماس های تماس تلفنی در SavedState کپی نمی شوند. ( i97816 ، b/191893160 )
نسخه 1.3.0-RC01
1 ژوئیه 2021
androidx.activity:activity:1.3.0-rc01
، androidx.activity:activity-compose:1.3.0-rc01
، و androidx.activity:activity-ktx:1.3.0-rc01
بدون تغییر از 1.3.0-beta02
منتشر نمی شود. نسخه 1.3.0-RC01 شامل این تعهدات است.
نسخه 1.3.0-beta02
16 ژوئن 2021
androidx.activity:activity:1.3.0-beta02
، androidx.activity:activity-compose:1.3.0-beta02
، و androidx.activity:activity-ktx:1.3.0-beta02
منتشر می شود. نسخه 1.3.0-beta02 شامل این تعهدات است.
activity-compose
به آهنگسازی 1.0.0-beta09
بستگی دارد. androidx.compose.ui:ui-test-junit4
اکنون وابستگی زمانی کامپایل به activity-compose
دارد.
نسخه 1.3.0-beta01
2 ژوئن 2021
androidx.activity:activity:1.3.0-beta01
، androidx.activity:activity-compose:1.3.0-beta01
، و androidx.activity:activity-ktx:1.3.0-beta01
منتشر می شود. نسخه 1.3.0-beta01 شامل این تعهدات است.
تغییرات API
- روش قبلاً کاهش یافته
@Composable registerForActivityResult()
حذف شده است. لطفاً ازrememberLauncherForActivityResult()
استفاده کنید. ( IC39D3 )
نسخه 1.3.0-alpha08
18 مه 2021
androidx.activity:activity:1.3.0-alpha08
، androidx.activity:activity-compose:1.3.0-alpha08
، و androidx.activity:activity-ktx:1.3.0-alpha08
منتشر می شود. نسخه 1.3.0-alpha08 شامل این تعهدات است.
ویژگی های جدید
- فعالیت جدید
CaptureVideo
ActivityResultContract
یک بولی را بهActivityResultCallback
شما بازگرداند و نشان می دهد که آیا فیلم شما با موفقیت در URI داده شده ذخیره شده است. این جایگزین قراردادTakeVideo
در حال حاضر مستهلک شده است زیرا برنامه های دوربین به ندرت از بازگشت یک مپ کوچک تصویر کوچک پشتیبانی می کنند و نتیجه را بی فایده می کنند. ( IE21F2 ، B/185938070 ) -
Activity#setPipAnimationHintView
برای به روزرسانی اشاره رکورد منبع پیپرامز هر زمان که این نمایش حرکت می کند. ( i9063d )
تغییرات API
- تابع
rememberLauncherForActivityResult
مانده از عملکردی که عملکردunregister()
را کاهش می دهد - ثبت نام و ثبت نام از پرتاب به طور خودکار توسطrememberLauncherForActivityResult
. ( i2443e )
سازگاری را تشکیل می دهد
-
androidx.activity:activity-compose:1.3.0-alpha08
فقط با نسخه آهنگسازی1.0.0-beta07
و بالاتر سازگار است.
نسخه 1.3.0-alpha07
21 آوریل 2021
androidx.activity:activity:1.3.0-alpha07
، androidx.activity:activity-compose:1.3.0-alpha07
و androidx.activity:activity-ktx:1.3.0-alpha07
منتشر می شود. نسخه 1.3.0-alpha07 شامل این تعهدات است.
رفع اشکال
-
rememberLauncherForActivityResult
اکنون یک مرجع پایدار را به همان نمونهActivityResultLauncher
بازگرداند ، حتی اگر قرارداد به دلیل استفاده مجدد تغییر کند. ( id2d6d ) - استفاده از نسخه های ناپایدار قطعات بالاتر از
1.3.0
دیگر خطای خط مثبت کاذب را به شما می گوید که از1.3.0
استفاده کنید. ( AOSP/1670206 ، b/184847092 )
نسخه 1.3.0-alpha06
7 آوریل 2021
androidx.activity:activity:1.3.0-alpha06
، androidx.activity:activity-compose:1.3.0-alpha06
، و androidx.activity:activity-ktx:1.3.0-alpha06
منتشر می شود. نسخه 1.3.0-alpha06 شامل این تعهدات است.
تغییرات API
- API
registerForActivityResult()
rememberLauncherForActivityResult()
شده است که به یاد داشته باشید کهActivityResultLauncher
برگشتی یک شیء مدیریت شده است که از طرف شما به یاد می آید. تلاش برای فراخوانیunregister
ازActivityResultLauncher
برگشتی ، اکنون خطایی خواهد داشت. ( i2bb6d ) -
LocalOnBackPressedDispatcherOwner.current
andLocalActivityResultRegistryOwner.current
now return a nullable value to better determine whether it is available in the current composition. API هایی که به آن API نیاز دارند ، مانندBackHandler
وrememberLauncherForActivityResult()
به ترتیب ، در صورت عدم یافتن مالک زیرین ، اکنون خطای توصیفی تری دارند.NavHost
اکنون حتی در صورت یافتن یکOnBackPressedDispatcherOwner
، کار می کند ، چنین مواردی در هنگام پیش نمایشNavHost
وجود دارد. ( i7d8b4 )
رفع اشکال
- در صورت
STOPPED
فعالیت ، اینBackHandler
به درستی مطبوعات را به درستی رهگیری می کند ، سپس دوبارهSTARTED
و سایر تماس های تماس با یک چرخه حیات اضافه شد. ( i71de6 ، b/182284739 ) - با استفاده از پسوند روش
launch()
با یکActivityResultContract
سفارشی ResultContract که دارای واحدUnit
است ، دیگر باعث ایجادNullPointerException
نمی شود ( I76282 ، B/183837954 )
نسخه 1.3.0-alpha05
24 مارس 2021
androidx.activity:activity:1.3.0-alpha05
، androidx.activity:activity-compose:1.3.0-alpha05
و androidx.activity:activity-ktx:1.3.0-alpha05
منتشر می شود. نسخه 1.3.0-alpha05 شامل این تعهدات است.
رفع اشکال
- از فعالیت 1.2.2 : یک مسئله را در بررسی
InvalidFragmentVersionForActivityResult
fragmentionforactivityresult بررسی کرد که هنگام استفاده از قطعه 1.3.1 یا بالاتر منجر به مثبت کاذب شد. ( I54DA1 ، B/182388985 ) - از فعالیت 1.2.2 :
ComponentActivity
اکنون هنگام راه اندازی یکIntent
از یکActivityResultContract
، که قبلاً به عنوان اضافی درIntent
دیگری برگزار می شد ، از یکClassNotFoundException
جلوگیری می کند. ( IEFF05 ، B/182906230 )
به روزرسانی های وابستگی
- از فعالیت 1.2.2 : فعالیت اکنون به چرخه عمر
2.3.1
بستگی دارد.
نسخه 1.3.0-alpha04
10 مارس 2021
androidx.activity:activity:1.3.0-alpha04
، androidx.activity:activity-compose:1.3.0-alpha04
و androidx.activity:activity-ktx:1.3.0-alpha04
منتشر می شود. نسخه 1.3.0-alpha04 شامل این تعهدات است.
رفع اشکال
- از فعالیت
1.2.1
:RequestMultiplePermissions
اکنون به جای فقط مجوزهایی که قبلاً اعطا نشده بود ، نتایج همه مجوزهای درخواستی را برمی گرداند. ( I50BC3 ، b/180884668 ) - از فعالیت
1.2.1
:ActivityResultRegistry
اکنون تضمین می کند که در حال انجامlaunch()
درخواست ها حتی اگرunregister()
نتایج خود را برمی گردانند ، سپس دوبارهregister()
. ( i9ef34 ، b/181267562 ) - آهنگسازی دیگر وابستگی های آزمون را به ClassPath زمان اجرا اضافه نمی کند. ( IFD8B3 )
- مسئله ای را با
BackHandler
برطرف کرد که در آن Lambda که قبلاًonBack
شده بود ، پس از بازپرداخت هنوز مورد استفاده قرار می گرفت. ( 8EB5EB )
نسخه 1.3.0-alpha03
24 فوریه 2021
androidx.activity:activity:1.3.0-alpha03
، androidx.activity:activity-compose:1.3.0-alpha03
و androidx.activity:activity-ktx:1.3.0-alpha03
منتشر می شود. نسخه 1.3.0-alpha03 شامل این تعهدات است.
ویژگی های جدید
- در حال حاضر یک تابع
registerForActivityResult
برای بدست آوردن نتیجه از فعالیت های موجود در ترکیبات وجود دارد. ( IA7851 ، B/172690553 )
تغییرات API
-
LocalOnBackPressedDispatcherOwner
اکنون عملکردی راprovides
می دهد که می تواند باCompositionLocalProvider
مورد استفاده قرار گیرد و APIasProvidableCompositionLocal()
را جایگزین کند. ( i45d24 )
نسخه 1.3.0-alpha02
10 فوریه 2021
androidx.activity:activity:1.3.0-alpha02
، androidx.activity:activity-compose:1.3.0-alpha02
، و androidx.activity:activity-ktx:1.3.0-alpha02
منتشر می شود. نسخه 1.3.0-alpha02 شامل این تعهدات است.
رفع اشکال
- رفع یک مسئله در فعالیت آهنگسازی
1.3.0-alpha01
که باعث ایجادNoSuchMethodError: No static method setContent
در هنگام استفاده از آهنگسازی1.0.0-alpha12
وجود ندارد. همه کاربران آهنگسازی باید به1.3.0-alpha02
و بالاتر بستگی داشته باشند. ( b/179911234 )
تغییرات API
- از API
BackHandler
می توان استفاده کرد تا یک ترکیب بتواند از دکمه عقب سیستم رهگیری کند. ( i58ed5 ، b/172154006 )
نسخه 1.3.0-alpha01
10 فوریه 2021
androidx.activity:activity:1.3.0-alpha01
، androidx.activity:activity-compose:1.3.0-alpha01
، و androidx.activity:activity-ktx:1.3.0-alpha01
منتشر می شود. نسخه 1.3.0-alpha01 شامل این تعهدات است.
ویژگی های جدید
- Artifact جدید
activity-compose
Jetpack را برای API های خاصandroidx.activity
آهنگسازی می کند.-
ComponentActivity.setContent
ازandroidx.compose.ui.platform.setContent
بهandroidx.activity.compose.setContent
منتقل شده است. ( ICF416 )
-
مسائل شناخته شده
- با استفاده از فعالیت آهنگسازی
1.3.0-alpha01
و کتابخانه هایی که به آن بستگی دارند ، مانندandroidx.compose.ui:ui-test-junit4:1.0.0-alpha12
، منجر بهNoSuchMethodError: No static method setContent
. ( b/179911234 )
نسخه 1.2.4
نسخه 1.2.4
21 جولای 2021
androidx.activity:activity:1.2.4
و androidx.activity:activity-ktx:1.2.4
منتشر می شود. نسخه 1.2.4 شامل این تعهدات است.
رفع اشکال
- از فعالیت
1.3.0-rc02
: اکنون تماس های CompensionResultregistry به درستی ذخیره شده و بازیابی می شوند ، بنابراین تماس های برگشتی در SaveDstate کپی نمی شوند. ( i97816 ، b/191893160 )
نسخه 1.2.3
نسخه 1.2.3
5 مه 2021
androidx.activity:activity:1.2.3
و androidx.activity:activity-ktx:1.2.3
منتشر می شود. نسخه 1.2.3 شامل این تعهدات است.
رفع اشکال
- با استفاده از پسوند روش
launch()
با یکActivityResultContract
سفارشی ResultContract که دارای واحدUnit
است ، دیگر باعث ایجادNullPointerException
نمی شود ( I76282 ، B/183837954 ) - رفع خطای خط مثبت کاذب به شما گفت که هنگام استفاده از عکس فوری ، آلفا ، بتا یا RC از نسخه جدیدتر از قطعات ، از قطعه
1.3.0
استفاده کنید. ( F4A57E ، B/184847092 )
نسخه 1.2.2
نسخه 1.2.2
24 مارس 2021
androidx.activity:activity:1.2.2
و androidx.activity:activity-ktx:1.2.2
منتشر می شود. نسخه 1.2.2 شامل این تعهدات است.
رفع اشکال
- رفع مسئله در بررسی
InvalidFragmentVersionForActivityResult
بررسی که منجر به مثبت کاذب هنگام استفاده از قطعه 1.3.1 یا بالاتر شد. ( I54DA1 ، B/182388985 ) -
ComponentActivity
اکنون هنگام راه اندازی یکIntent
از یکActivityResultContract
، که قبلاً به عنوان یک اضافی درIntent
دیگری برگزار می شد ، از یکClassNotFoundException
جلوگیری می کند. ( IEFF05 ، B/182906230 )
به روزرسانی های وابستگی
- فعالیت اکنون به چرخه عمر
2.3.1
بستگی دارد.
نسخه 1.2.1
نسخه 1.2.1
10 مارس 2021
androidx.activity:activity:1.2.1
و androidx.activity:activity-ktx:1.2.1
منتشر می شود. نسخه 1.2.1 شامل این تعهدات است.
رفع اشکال
-
RequestMultiplePermissions
اکنون همیشه به جای مجوزهایی که قبلاً اعطا نشده بودند ، نتایج را برای کلیه مجوزهای درخواست شده باز می گرداند. ( I50BC3 ، b/180884668 ) -
ActivityResultRegistry
اکنون تضمین می کند که در حال انجامlaunch()
درخواست ها حتی اگرunregister()
نتایج خود را برمی گردانند ، سپس دوبارهregister()
. ( i9ef34 ، b/181267562 )
نسخه 1.2.0
نسخه 1.2.0
10 فوریه 2021
androidx.activity:activity:1.2.0
و androidx.activity:activity-ktx:1.2.0
منتشر می شود. نسخه 1.2.0 شامل این تعهدات است.
تغییرات اساسی از 1.1.0
- APIS نتیجه فعالیت :
ComponentActivity
اکنون یکActivityResultRegistry
فراهم می کند که به شما امکان می دهدstartActivityForResult()
+onActivityResult()
و همچنینrequestPermissions()
+onRequestPermissionsResult()
جریان را بدون روش های مهم در فعالیت یا قطعه خود ، افزایش ایمنی نوع از طریق فعالیت های فعالیت را افزایش می دهد و از طریق فعالیت های مربوط به فعالیت ایجاد می کند ، و در صورت امکان استفاده از نوعActivityResultContract
فراهم می کند ، و در حال فراهم کردن هوک است. آزمایش این جریان ها. مشاهده به روز شده نتیجه یک فعالیت را مشاهده کنید.
ContextAware
:ComponentActivity
اکنونContextAware
پیاده سازی می کند و به شما امکان می دهد یک یا چند موردOnContextAvailableListener
را اضافه کنید که قبل ازActivity.onCreate()
پایه ، یک پاسخ به تماس دریافت می کنند.- یک پسوند Kotlin به حالت تعلیق
withContextAvailable()
به شما امکان می دهد تا در صورت در دسترس بودن زمینه ، یک بلوک غیر تعلیق را اجرا کنید و نتیجه را برگردانید. - این API توسط
FragmentActivity
در قطعه 1.3.0 برای بازگرداندن وضعیتFragmentManager
استفاده می شود. هر شنونده اضافه شده به زیر کلاسهایFragmentActivity
بعد از آن شنونده اجرا می شود. - این API توسط
AppCompatActivity
در AppCompat 1.3.0-alpha02 یا بالاتر استفاده می شود. هر شنونده اضافه شده به زیر کلاسهایAppCompatActivity
پس از آن شنونده اجرا می شود.
- یک پسوند Kotlin به حالت تعلیق
پشتیبانی
ViewTree
:ComponentActivity
اکنون ازViewTreeLifecycleOwner.get(View)
،ViewTreeViewModelStoreOwner.get(View)
، وViewTreeSavedStateRegistryOwner
API اضافه شده در Lifecycle2.3.0
و SaveEdState1.1.0
پشتیبانی می کند ، به گونه ای که فعالیت به عنوانLifecycleOwner
را بازگرداند.ViewModelStoreOwner
، وSavedStateRegistryOwner
برای هرگونه دیدگاهی که مستقیماً بهComponentActivity
اضافه شده است.
- گزارش دهی DREAPERALL () backport - روش
Activity
reportFullyDrawn()
درComponentActivity
برای کار در تمام سطوح API ، رفع یک تصادف در API 19 و اضافه کردن ردیابی برای این روش برای همه سطح API انجام شده است.
نسخه 1.2.0-RC01
16 دسامبر 2020
androidx.activity:activity:1.2.0-rc01
و androidx.activity:activity-ktx:1.2.0-rc01
منتشر می شود. نسخه 1.2.0-RC01 شامل این تعهدات است.
رفع اشکال
- اکنون
ActivityResultRegistry
همواره وضعیت دقیقی را که نجات یافته است بازیابی می کند. ( IDD56B ) - افزودن ردیابی به
ComponentActivity.reportFullyDrawn
( IC7632 )
سهم خارجی
-
ComponentActivity
اکنونreportFullyDrawn()
نادیده می گیرد ، و این امکان را می دهد تا در تمام سطوح API فراخوانی شود و هنگام فراخوانی این روش بدون اجازه سیستم مناسب در دستگاه های API 19 ، تصادف را برطرف کند. با تشکر از سیمون شیلر! ( b/163239764 ، #103 )
نسخه 1.2.0-beta02
2 دسامبر 2020
androidx.activity:activity:1.2.0-beta02
و androidx.activity:activity-ktx:1.2.0-beta02
منتشر می شود. نسخه 1.2.0-beta02 شامل این تعهدات است.
رفع اشکال
- مسئله ای را برطرف کرد که در آن نتیجه فعالیت API منتظر
STARTED
چرخه عمر قبل از ارائه نتایج در هنگام ثبت نام درLifecycle
باشد. ( i109ea )
سهم خارجی
- اسناد را برای
launch()
به روز کرد تا صریحاً با این مسئله تماس بگیرد که می تواند یکActivityNotFoundException
پرتاب کند. با تشکر از Michał Zieliński! ( AOSP/1493580 )
نسخه 1.2.0-beta01
1 اکتبر 2020
androidx.activity:activity:1.2.0-beta01
و androidx.activity:activity-ktx:1.2.0-beta01
منتشر می شود. نسخه 1.2.0-beta01 شامل این تعهدات است.
رفع اشکال
ActivityResultRegistry
اکنون به طور تصادفی عدد صحیح را تولید می کند تا زمانی که چیزی را پیدا کند که از آن به عنوانregister()
، بنابراین مانع از سرریز عدد صحیح احتمالی ناشی از افزایش کدهای درخواست می شود. ( b/168779518 )ناظران
Lifecycle
هنگام فراخوانیunregister()
در یکActivityResultLauncher
به درستی حذف می شوند. ( b/165608393 )
تغییرات رفتار
-
ActivityResultRegistry
اکنون هنگام تلاش برای تماس باregister()
با یکLifecycleOwner
کهLifecycle
که قبلاً ازSTARTED
رسیده است ، شروع بهIllegalStateException
می کند. ( b/165435866 )
اسناد به روز شد
- پیوندهای مستندات
ContextAware
برای برجسته کردن تماس هایLifecycle
به عنوان مکان مناسب برای ایجاد و تخریب ، پیوندهای مستندات ContextAware بهLifecycleOwner
( AOSP/1414152 )
نسخه 1.2.0-alpha08
19 آگوست 2020
androidx.activity:activity:1.2.0-alpha08
و androidx.activity:activity-ktx:1.2.0-alpha08
منتشر می شود. نسخه 1.2.0-alpha08 شامل این تعهدات است.
ویژگی های جدید
-
ComponentActivity
اکنونContextAware
پیاده سازی می کند و به شما امکان می دهد یک یا چند موردOnContextAvailableListener
اضافه کنید که قبل ازActivity.onCreate()
پایه ، پاسخ به تماس دریافت می کنند. ( b/161390636 )- A suspending Kotlin extension
withContextAvailable()
allows you to run a non-suspending block when the Context becomes available and return a result. ( I8290c ) - This API is used by
FragmentActivity
in Fragment 1.3.0-alpha08 to restore the state of theFragmentManager
. Any listeners added to subclasses ofFragmentActivity
will run after that listener. ( I513da ) - This API is used by
AppCompatActivity
in AppCompat 1.3.0-alpha02 . Any listeners added to subclasses ofAppCompatActivity
will run after that listener. ( I513da )
- A suspending Kotlin extension
رفع اشکال
- Fixed an issue with the
ActivityResultFragmentVersionDetector
Lint check that caused it to break when using Lint 27.1.0 or higher. ( b/162155191 )
Version 1.2.0-alpha07
July 22, 2020
androidx.activity:activity:1.2.0-alpha07
and androidx.activity:activity-ktx:1.2.0-alpha07
are released. Version 1.2.0-alpha07 contains these commits.
ویژگی های جدید
- Added a new
InvalidFragmentVersionForActivityResult
lint check that verifies that you are using Fragment1.3.0-alpha07
when using the Activity Result API , avoiding runtime crashes due to “invalid request code” issues and non-functioning permission requests caused by using older versions of Fragments. ( b/152554847 )
External Contribution
- Fixed an
ArrayIndexOutOfBoundsException
when parsing the results for theRequestPermission
Activity Result contract. ( I8f9e3 , b/161057605 )
Version 1.2.0-alpha06
10 ژوئن 2020
androidx.activity:activity:1.2.0-alpha06
and androidx.activity:activity-ktx:1.2.0-alpha06
are released. Version 1.2.0-alpha06 contains these commits.
ویژگی های جدید
- You can now destructure the
ActivityResult
class in kotlin to directly access therequestCode
andintent
. ( b/157212935 ) -
ActivityResultLauncher
now allows you to get theActivityResultContract
that was used to register the launcher. ( b/156875743 )
تغییرات API
- Breaking change : The
invoke()
method onActivityResultRegistry
has been renamed toonLaunch()
. ( b/157496491 ) - The
OpenMultipleDocuments
contract now returns an empty list instead ofnull
to the registered callback if no result is returned. ( b/157348014 )
Version 1.2.0-alpha05
20 مه 2020
androidx.activity:activity:1.2.0-alpha05
and androidx.activity:activity-ktx:1.2.0-alpha05
are released. Version 1.2.0-alpha05 contains these commits.
ویژگی های جدید
- Added support for
ViewTreeViewModelStoreOwner
from Lifecycle2.3.0-alpha03
, andViewTreeSavedStateRegistryOwner
from SavedState1.1.0-alpha01
when using aView
within aComponentActivity
. ( aosp/1297993 , aosp/1300264 )
تغییرات API
- The
TakePicture
contract now returns aboolean
indicating success rather than a thumbnailBitmap
as this was very rarely supported by camera apps when writing the image to the providedUri
. ( b/154302879 ) - The
invoke()
extensions onActivityResultLauncher
have been removed in favor of explicitly usinglaunch()
to better indicate that these are asynchronous operations. Kotlin extensions forlaunch
have been added to theandroidx.activity.result
package forActivityResultLauncher<Void>
andActivityResultLauncher<Unit>
that remove the need to pass innull
orUnit
, respectively, mirroring that behavior from the previouslyinvoke()
extensions. ( aosp/1304674 , aosp/1304675 ) - The
IntentSenderRequest.Builder
methods forsetFlagsMask()
andsetFlagsValues()
has been combined into a singlesetFlags()
method. ( aosp/1302111 )
رفع اشکال
- When registering an
ActivityResultCallback
with aLifecycleOwner
, fixed an issue where the callback would be triggered before the state reachesSTARTED
. ( aosp/1309744 )
تغییرات رفتار
- The
ActivityResultRegistry
now generates request codes starting at0xFFFF
rather than at0
, preventing overlap when usingstartActivityForResult()
orrequestPermissions()
in an activity. ( aosp/1302324 )
Version 1.2.0-alpha04
29 آوریل 2020
androidx.activity:activity:1.2.0-alpha04
and androidx.activity:activity-ktx:1.2.0-alpha04
are released. Version 1.2.0-alpha04 contains these commits.
ویژگی های جدید
- Added a contract that can call startIntentSenderForResult to the ActivityResult APIs. ( b/153007517 )
تغییرات API
- The
prepareCall()
method has been renamed toregisterForActivityResult()
, both onComponentActivity
here and in Fragment1.3.0-alpha04
. ( aosp/1278717 ) - The
GetContents
,OpenDocuments
, andRequestPermissions
contracts have been renamed toGetMultipleContents
,OpenMultipleDocuments
, andRequestMultiplePermissions
, respectively. ( aosp/1280161 ) -
ComponentActivity
now implements theActivityResultRegisteryOwner
interface. ( aosp/1290888 ) - - The
startActivityForResult()
/onActivityResult()
andonRequestPermissionsResult()
APIs onComponentActivity
have been deprecated. Please use the Activity Result APIs . ( b/154751887 )
رفع اشکال
- When using the
GetMultipleContents
andOpenMultipleDocuments
contracts and selecting a single item, it is now correctly returned to your callback. ( b/152941153 )
Version 1.2.0-alpha03
1 آوریل 2020
androidx.activity:activity:1.2.0-alpha03
and androidx.activity:activity-ktx:1.2.0-alpha03
are released. Version 1.2.0-alpha03 contains these commits.
ویژگی های جدید
- Added the
TakeVideo
,PickContact
,GetContent
,GetContents
,OpenDocument
,OpenDocuments
,OpenDocumentTree
, andCreateDocument
contracts to the set of pre-built contracts provided byActivityResultContracts
. ( aosp/1262482 , aosp/1266916 , aosp/1268960 ) - The Activity Result APIs now support launching an activity for result with an optional
ActivityOptionsCompat
. ( b/151860054 )
تغییرات API
- The
TakePicture
contract now takes aUri
input for where the image should be stored. The previous contract that does not take any input has been renamed toTakePicturePreview
. ( aosp/1262482 ) - The
registerActivityResultCallback()
method onActivityResultRegistry
has been renamed toregister()
. ( aosp/1267621 ) - The
dispose()
method onActivityResultLauncher
has been renamed tounregister()
and theunregisterResultCallback()
onActivityResultRegistry
has been removed. ( aosp/1267621 ) - The
createIntent()
method ofActivityResultContact
now takes aContext
in addition to the input to make it possible to create explicit Intents. ( aosp/1238800 ) - An
ActivityResultContract
can now overridegetSynchronousResult()
to deliver a result without callingstartActivityForResult
. This is used by theRequestPermission
andRequestPermissions
contracts to correctly deliver a 'granted' status if the requested permissions are already granted. ( b/151110799 ) - The previously available
Dial
contract has been removed as thatIntent
is not meant to be used withstartActivityForResult()
. ( aosp/1266916 ) - Many of the Activity Result APIs not meant to be extended are now
final
. This includesgetActivityResultRegistry()
, theprepareCall()
methods, all methods ofActivityResultRegistry
exceptinvoke()
, and a number of the default contracts that do not support optional extras. ( b/152439361 )
رفع اشکال
- Fixed a
NullPointerException
inActivityResultRegistry
when attempting to deliver results to a callback that has not yet been re-registered after a configuration change;ActivityResultRegistry
now holds onto these pending results and delivers them when the callback is re-registered. ( b/152137004 )
Version 1.2.0-alpha02
18 مارس 2020
androidx.activity:activity:1.2.0-alpha02
and androidx.activity:activity-ktx:1.2.0-alpha02
are released. Version 1.2.0-alpha02 contains these commits.
ویژگی های جدید
- ActivityResultRegistry :
ComponentActivity
now provides anActivityResultRegistry
that lets you handle thestartActivityForResult()
+onActivityResult()
as well asrequestPermissions()
+onRequestPermissionsResult()
flows without overriding methods in your Activity or Fragment, brings increased type safety viaActivityResultContract
, and provides hooks for testing these flows. See the updated Getting a Result from an Activity . ( b/125158199 )
Version 1.2.0-alpha01
4 مارس 2020
androidx.activity:activity:1.2.0-alpha01
and androidx.activity:activity-ktx:1.2.0-alpha01
are released. Version 1.2.0-alpha01 contains these commits.
ویژگی های جدید
- Added support for the
ViewTreeLifecycleOwner.get(View)
API added in Lifecycle2.3.0-alpha01
such that it will return the Activity as theLifecycleOwner
for any Views directly added to the Activity. ( aosp/1182955 )
رفع اشکال
- Fixed a regression introduced in Activity
1.1.0
when running on older versions of the platform whereonBackPressed()
would cause anIllegalStateException
due to a bug in theandroid.app.FragmentManager
. ( b/146290338 )
نسخه 1.1.0
نسخه 1.1.0
22 ژانویه 2020
androidx.activity:activity:1.1.0
is released. Version 1.1.0 contains these commits .
Important changes since 1.0.0
- Lifecycle ViewModel SavedState Integration :
SavedStateViewModelFactory
is now the default factory used when usingby viewModels()
, theViewModelProvider
constructor, orViewModelProviders.of()
with aComponentActivity
or its subclasses.
Version 1.1.0-rc03
4 دسامبر 2019
androidx.activity:activity:1.1.0-rc03
and androidx.activity:activity-ktx:1.1.0-rc03
are released. Version 1.1.0-rc03 contains these commits .
Dependency changes
- Activity now depends on Lifecycle
2.2.0-rc03
and Lifecycle ViewModel SavedState1.0.0-rc03
.
Version 1.1.0-rc02
7 نوامبر 2019
androidx.activity:activity:1.1.0-rc02
and androidx.activity:activity-ktx:1.1.0-rc02
are released. Version 1.1.0-rc02 contains these commits .
Dependency changes
- Activity now depends on lifecycle
2.2.0-rc02
.
Version 1.1.0-rc01
23 اکتبر 2019
androidx.activity:activity:1.1.0-rc01
and androidx.activity:activity-ktx:1.1.0-rc01
are released with no changes from 1.1.0-beta01
. Version 1.1.0-rc01 contains these commits .
Version 1.1.0-beta01
9 اکتبر 2019
androidx.activity:activity:1.1.0-beta01
and androidx.activity:activity-ktx:1.1.0-beta01
are released. Version 1.1.0-beta01 contains these commits .
Dependency changes
- Activity now depends on SavedState 1.0.0 stable.
Version 1.1.0-alpha03
5 سپتامبر 2019
androidx.activity:activity:1.1.0-alpha03
and androidx.activity:activity-ktx:1.1.0-alpha03
are released. The commits included in this version can be found here .
ویژگی های جدید
- Activity now depends on Core 1.1.0 stable.
رفع اشکال
- Activity now depends on Lifecycle
2.2.0-alpha04
.
Version 1.1.0-alpha02
7 آگوست 2019
androidx.activity:activity:1.1.0-alpha02
and androidx.activity:activity-ktx:1.1.0-alpha02
are released. The commits included in this version can be found here .
ویژگی های جدید
-
SavedStateViewModelFactory
is now the default factory used when usingby viewModels()
, theViewModelProvider
constructor, orViewModelProviders.of()
with aComponentActivity
( b/135716331 )
Version 1.1.0-alpha01
2 جولای 2019
androidx.activity:activity:1.1.0-alpha01
and androidx.activity:activity-ktx:1.1.0-alpha01
are released. The commits included in this version can be found here .
ویژگی های جدید
-
activity
now depends on Lifecycle2.2.0-alpha02
. ( aosp/1007817 ) -
activity-ktx
added a dependency onlifecycle-runtime-ktx
; you no longer need to explicitly add it to your dependencies when usingactivity-ktx
or libraries that depend onactivity-ktx
(such asfragment-ktx
). ( aosp/987162 )
Version 1.0.0
Version 1.0.0
5 سپتامبر 2019
androidx.activity:activity:1.0.0
and androidx.activity:activity-ktx:1.0.0
are released. The commits included in this version can be found here .
Major Features of 1.0.0
- ComponentActivity :
ComponentActivity
serves as the new base class forFragmentActivity
in Fragment1.1.0
and, by extension,AppCompatActivity
in AppCompat1.1.0
. - activity-ktx : The
activity-ktx
module includes aby viewModels
Kotlin property extension for accessing ViewModels. This module is automatically included when you includefragment-ktx
from Fragment1.1.0
. - OnBackPressedDispatcher : As a composable alternative to overriding
onBackPressed()
, you can now register aOnBackPressedCallback
from anyLifecycleOwner
(such as a fragment) to intercept system back button events. A lambda with receiver versionaddCallback
has been added toactivity-ktx
. See Provide custom back navigation documentation for more details. - onRetainCustomNonConfigurationInstance deprecation : the
onRetainCustomNonConfigurationInstance()
and the relatedgetLastCustomNonConfigurationInstance()
APIs have been deprecated. It is strongly recommended to use ViewModels to store non-configuration state as they offer a composable solution suitable for anyViewModelStoreOwner
that makes the ownership of the retained objects clear and provides anonCleared()
callback for cleaning up resources when the activity is finally destroyed.
Version 1.0.0-rc01
2 جولای 2019
androidx.activity:activity:1.0.0-rc01
and androidx.activity:activity-ktx:1.0.0-rc01
are released with no changes from 1.0.0-beta01
. The commits included in this version can be found here .
Version 1.0.0-beta01
5 ژوئن 2019
androidx.activity::activity:1.0.0-beta01
and androidx.activity:activity-ktx:1.0.0-beta01
are released with no changes from 1.0.0-alpha08
. The commits included in this version can be found here .
Version 1.0.0-alpha08
7 مه 2019
androidx.activity:activity:1.0.0-alpha08
and androidx.activity:activity-ktx:1.0.0-alpha08
are released. The commits included in this version can be found here .
API changes
- Breaking change: The previously deprecated
addOnBackPressedCallback
andremoveOnBackPressedCallback
methods onComponentActivity
have been removed. aosp/953857 - The
setEnabled()
andisEnabled()
methods ofOnBackPressedCallback
are now final. b/131416833 - The
remove()
method ofOnBackPressedCallback
is now final. aosp/952720 -
OnBackPressedDispatcher
now has public constructors, allowing you to construct your own instances for testing, etc. aosp/953431 -
onBackPressed()
forComponentActivity
is now explicitly marked as@MainThread
aosp/952721
رفع اشکال
- Fixed a
ConcurrentModificationException
when callingremove()
from within thehandleOnBackPressed()
method of aOnBackPressedCalback
that was added with aLifecycleOwner
. b/131765095
Version 1.0.0-alpha07
April 25th, 2019
androidx.activity:activity:1.0.0-alpha07
and androidx.activity:activity-ktx:1.0.0-alpha07
are released. The commits included in this version can be found here .
API changes
This release makes significant changes to the handling of the onBackPressed()
. See the updated custom back documentation for more details.
- The methods for
OnBackPressedCallback
andOnBackPressedDispatcher
have been marked as@MainThread
. ( aosp/943813 ) - The
handleOnBackPressed()
method no longer returns aboolean
. Instead,OnBackPressedCallback
is now an abstract class that can be enabled or disabled - only when the newisEnabled()
method returns true willhandleOnBackPressed()
be called, in which you must handle the back button. ( aosp/944518 ) - The
addCallback
methods ofOnBackPressedDispatcher
no longer return aCancellable
instance.OnBackPressedCallback
now contain aremove()
method that fulfill this functionality, allowing you to callremove()
duringhandleOnBackPressed()
. ( aosp/944519 ) ( aosp/946316 ) -
activity-ktx
now contains a receiver scoped callback foraddCallback
that accepts a lamdba that implementshandleOnBackPressed()
and has access toisEnabled
andremove()
( aosp/944520 )
Version 1.0.0-alpha06
3 آوریل 2019
androidx.activity:activity:1.0.0-alpha06
and androidx.activity:activity-ktx:1.0.0-alpha06
are released. The commits included in this version can be found here .
API changes
- ComponentActivity now contain a second constructor that takes a
@LayoutRes int
, which replaces the previous behavior of annotating your AppCompatActivity class with@ContentView
. This approach works in both app and library modules. ( b/128352521 ) - The
OnBackPressedCallback
related APIs on ComponentActivity have been deprecated in favor of the newOnBackPressedDispatcher
, retrievable viagetOnBackPressedDispatcher()
. ( aosp/922523 ) - Methods to add a new
OnBackPressedCallback
to theOnBackPressedDispatcher
now return aCancellable
object, allowing removal of the callback without requiring an explicit reference to theOnBackPressedDispatcher
. ( aosp/922523 ) - Adding a
OnBackPressedCallback
with an associatedLifecycleOwner
now results in adding and removing theOnBackPressedCallback
as the Lifecycle is started and stopped, respectively. ( aosp/922523 )
Version 1.0.0-alpha05
13 مارس 2019
androidx.activity:activity:1.0.0-alpha05
and androidx.activity:activity-ktx:1.0.0-alpha05
are released. The full list of commits included in this release can be found here .
ویژگی های جدید
-
@ContentView
annotation lookups are now cached ( b/123709449 )
Version 1.0.0-alpha04
30 ژانویه 2019
androidx.activity:activity 1.0.0-alpha04
and androidx.activity:activity-ktx 1.0.0-alpha04
are released.
ویژگی های جدید
- Added support for the
@ContentView
class annotation that allows you to indicate which layout XML file should be inflated as an alternative to usingsetContentView()
. ( aosp/837619 )
API changes
- Added a note that
getViewModelStore()
should not be overridden and will be made final in a future release. Please file a feature request if you are currently overriding this method. ( aosp/837619 )
رفع اشکال
- The
activity
module now depends on version 2.1.0-alpha02 of ViewModel to match theactivity-ktx
module's dependency.
Version 1.0.0-alpha03
17 دسامبر 2018
androidx.activity 1.0.0-alpha03
is released.
ویژگی های جدید
- ComponentActivity now implements
BundleSavedStateRegistryOwner
and depends on the newly released SavedState library [ aosp/815133 ] - ComponentActivity now works around an Android framework bug that would cause InputMethodManager to leak the last focused view [ b/37122102 ]
Version 1.0.0-alpha02
3 دسامبر 2018
API changes
- Added a note that
getLifecycle()
should not be overridden and will be madefinal
in a future release. Please file a feature request if you are currently overriding this method. ( aosp/815834 )
Version 1.0.0-alpha01
5 نوامبر 2018
androidx.activity 1.0.0-alpha01
introduces ComponentActivity
, a new base class of the existing FragmentActivity
and AppCompatActivity
.
ویژگی های جدید
- You can now register an
OnBackPressedCallback
viaaddOnBackPressedCallback
to receiveonBackPressed()
callbacks without needing to override the method in your activity. - Added a new
by viewModels()
Kotlin property delegate for retrievingViewModel
s from aComponentActivity
. - Pending input events (such as clicks) are now canceled in
onStop()
.
API changes
- The implementation of
LifecycleOwner
andViewModelStoreOwner
have been moved fromFragmentActivity
toComponentActivity
. -
onRetainCustomNonConfigurationInstance
has been deprecated. Use aViewModel
for storing objects that need to survive configuration changes.
فعالیت
آخرین به روز رسانی | انتشار پایدار | کاندید را آزاد کنید | نسخه بتا | Alpha Release |
---|---|---|---|---|
9 آوریل 2025 | 1.10.1 | - | 1.11.0-beta01 | - |
اعلام وابستگی ها
To add a dependency on Activity, you must add the Google Maven repository to your project. Read Google's Maven repository for more information.
Add the dependencies for the artifacts you need in the build.gradle
file for your app or module:
شیار
dependencies { def activity_version = "1.10.1" // Java language implementation implementation "androidx.activity:activity:$activity_version" // Kotlin implementation "androidx.activity:activity-ktx:$activity_version" }
کاتلین
dependencies { val activity_version = "1.10.1" // Java language implementation implementation("androidx.activity:activity:$activity_version") // Kotlin implementation("androidx.activity:activity-ktx:$activity_version") }
For more information about dependencies, see Add build dependencies .
بازخورد
Your feedback helps make Jetpack better. Let us know if you discover new issues or have ideas for improving this library. Please take a look at the existing issues in this library before you create a new one. You can add your vote to an existing issue by clicking the star button.
See the Issue Tracker documentation for more information.
نسخه 1.11
Version 1.11.0-beta01
9 آوریل 2025
androidx.activity:activity:1.11.0-beta01
, androidx.activity:activity-compose:1.11.0-beta01
, and androidx.activity:activity-ktx:1.11.0-beta01
are released. Version 1.11.0-beta01 contains these commits .
Version 1.11.0-alpha02
26 مارس 2025
androidx.activity:activity:1.11.0-alpha02
, androidx.activity:activity-compose:1.11.0-alpha02
, and androidx.activity:activity-ktx:1.11.0-alpha02
are released. Version 1.11.0-alpha02 contains these commits .
تغییرات API
- Integrated the new
EDGE_NONE
andframeTimeMillis
from Android 16 Beta03 into theBackEventCompat
provided byOnBackPressedCallback
'shandleOnBackStarted
andhandleOnBackProgressed
functions.
Dependency Updates
- Activity is now compiled with API 36. ( I510e8 , b/301910674 )
Version 1.11.0-alpha01
12 مارس 2025
androidx.activity:activity:1.11.0-alpha01
, androidx.activity:activity-compose:1.11.0-alpha01
, and androidx.activity:activity-ktx:1.11.0-alpha01
are released. Version 1.11.0-alpha01 contains these commits .
ویژگی های جدید
- Added
MediaCapabilities
API toPickVisualMediaRequest
to let applications specify its media capabilities, such as supported HDR Types. ( Ic3ee7 )
نسخه 1.10
نسخه 1.10.1
26 فوریه 2025
androidx.activity:activity:1.10.1
, androidx.activity:activity-compose:1.10.1
, and androidx.activity:activity-ktx:1.10.1
are released. Version 1.10.1 contains these commits .
رفع اشکال
-
ViewTree
OnBackPressedDispatcherOwners
andFullyDrawnReporterOwners
can now be resolved through disjoint parents of a view, such as aViewOverlay
. See the release notes of core or the documentation inViewTree.setViewTreeDisjointParent
for more information on disjoint view parents. ( Ie7750 )
نسخه 1.10.0
15 ژانویه 2025
androidx.activity:activity:1.10.0
, androidx.activity:activity-compose:1.10.0
, and androidx.activity:activity-ktx:1.10.0
are released. Version 1.10.0 contains these commits .
Important changes since 1.9.0
-
PhotoPicker
now allows picking images in order and choosing which tab (either albums or images) should be initially visible. - The
PickVisualMedia
andPickMultipleVisualMedia
Activity Result contracts that trigger the Photo Picker no longer directly delegates to Google Play services if the system Photo picker is not available, but uses the publicACTION_SYSTEM_FALLBACK_PICK_IMAGES
action and related extras to provide a consistent Photo Picker experience to OEMs and system apps as a fallback. - New
LocalActivity
composition local that provides theActivity
for the current scope, removing the need for developers to get anActivity
from theLocalContext
.
Version 1.10.0-rc01
11 دسامبر 2024
androidx.activity:activity:1.10.0-rc01
, androidx.activity:activity-compose:1.10.0-rc01
, and androidx.activity:activity-ktx:1.10.0-rc01
are released. Version 1.10.0-rc01 contains these commits .
رفع اشکال
- Fixed an issue where changing the enabled state while the
PredictiveBackHandler
is currently active would short circuit the callback immediately. It will now finish the current callback regardless of the enabled status changes. ( Ib8719 )
Version 1.10.0-beta01
13 نوامبر 2024
androidx.activity:activity:1.10.0-beta01
, androidx.activity:activity-compose:1.10.0-beta01
, and androidx.activity:activity-ktx:1.10.0-beta01
are released with no changes since the last alpha. Version 1.10.0-beta01 contains these commits .
Version 1.10.0-alpha03
30 اکتبر 2024
androidx.activity:activity:1.10.0-alpha03
, androidx.activity:activity-compose:1.10.0-alpha03
, and androidx.activity:activity-ktx:1.10.0-alpha03
are released. Version 1.10.0-alpha03 contains these commits .
تغییرات API
- Added a new
LocalActivity
composition local that provides theActivity
for the current scope, removing the need for developers to get anActivity
from theLocalContext
. It also comes with a new lint rule that checks when theLocalContext
is incorrectly being cast to anActivity
. ( I7746a , b/283009666 )
رفع اشکال
- From Activity
1.9.3
:PredictiveBackHandler
will no longer fire it's callback after the handler has been disabled. This will fix an issue where theNavHost
from Navigation Compose would throw anIndexOutOfBoundsException
. ( I3f75e , b/365027664 , b/340202286 )
Dependency Update
- Activity Compose now depends on Compose Runtime 1.7.0 ( I7746a , b/283009666 )
Version 1.10.0-alpha02
4 سپتامبر 2024
androidx.activity:activity:1.10.0-alpha02
, androidx.activity:activity-compose:1.10.0-alpha02
, and androidx.activity:activity-ktx:1.10.0-alpha02
are released. Version 1.10.0-alpha02 contains these commits .
تغییرات رفتار
- The
PickVisualMedia
andPickMultipleVisualMedia
Activity Result contracts that trigger the Photo Picker no longer directly delegates to Google Play services if the system Photo picker is not available, but uses the publicACTION_SYSTEM_FALLBACK_PICK_IMAGES
action and related extras to provide a consistent Photo Picker experience to OEMs and system apps as a fallback. This should have no effect on the user experience for devices that have a recent version of Google Play services. ( I3513d )
رفع اشکال
- Removed manual outlining of access to new platform APIs since this happens automatically via API modeling when using R8 with AGP 7.3 or later (eg R8 version 3.3) and for all builds when using AGP 8.1 or later (eg D8 version 8.1). Clients who are not using AGP are advised to update to D8 version 8.1 or later. برای جزئیات بیشتر به این مقاله مراجعه کنید. ( I9496c , b/345472586 )
- From Activity
1.9.2
: Fixed an issue where the Activity ComposePredictiveBackHandler
API would continue to handle the system back gesture on the frame it was disabled, which could result in libraries like Navigation Compose to handle back even with an empty back stack, resulting in it throwing anIndexOutOfBoundsException
. ( Ie3301 , b/340202286 ) - From Activity
1.9.1
: Fixed an issue withPredictiveBackHandler
where after doing system back, attempting to doonBackPressed
from theOnBackPressedDispatcher
would fail. ( I5f1f8 )
Version 1.10.0-alpha01
26 ژوئن 2024
androidx.activity:activity:1.10.0-alpha01
, androidx.activity:activity-compose:1.10.0-alpha01
, and androidx.activity:activity-ktx:1.10.0-alpha01
are released. This version is developed in an internal branch.
ویژگی های جدید
- Added support for new
PhotoPicker
features introduced in Android V including being able to pick images in order and choose which tab (either albums or images) should be initially visible.
نسخه 1.9
نسخه 1.9.3
16 اکتبر 2024
androidx.activity:activity:1.9.3
, androidx.activity:activity-compose:1.9.3
, and androidx.activity:activity-ktx:1.9.3
are released. Version 1.9.3 contains these commits .
رفع اشکال
-
PredictiveBackHandler
will no longer fire it's callback after the handler has been disabled. This will fix an issue where theNavHost
from Navigation Compose would throw anIndexOutOfBoundsException
. ( I3f75e , b/340202286 )
Version 1.9.2
4 سپتامبر 2024
androidx.activity:activity:1.9.2
, androidx.activity:activity-compose:1.9.2
, and androidx.activity:activity-ktx:1.9.2
are released. Version 1.9.2 contains these lthcocommits .
رفع اشکال
- Fixed an issue where the Activity Compose
PredictiveBackHandler
API would continue to handle the system back gesture on the frame it was disabled, which could result in libraries like Navigation Compose to handle back even with an empty back stack, resulting in it throwing anIndexOutOfBoundsException
. ( Ie3301 , b/340202286 )
Version 1.9.1
24 جولای 2024
androidx.activity:activity:1.9.1
, androidx.activity:activity-compose:1.9.1
, and androidx.activity:activity-ktx:1.9.1
are released. Version 1.9.1 contains these commits .
رفع اشکال
- Fixed an issue with
PredictiveBackHandler
where after doing system back, attempting to doonBackPressed
from theOnBackPressedDispatcher
would fail. ( I5f1f8 )
نسخه 1.9.0
17 آوریل 2024
androidx.activity:activity:1.9.0
, androidx.activity:activity-compose:1.9.0
, and androidx.activity:activity-ktx:1.9.0
are released. Version 1.9.0 contains these commits .
Important changes since 1.8.0
-
ComponentActivity
now implementsOnUserLeaveHintProvider
to allow components to callbacks foronUserLeaveHint
events. - The
OnBackPressedCallback
,BackHandler
, andPredictiveBackHandler
APIs now warn when callingonBackPressedDispatcher.onBackPressed()
when handling back as that will always break the Predictive Back Animation . See the best practices guide for more details. - The remainder of the Activity APIs have been rewritten in Kotlin and all extensions previously available in
activity-ktx
have been moved toactivity
.activity-ktx
is now completely empty.- As part of the conversion of
ActivityResultLauncher
to Kotlin, thegetContract
method is now an abstract Kotlin property. This is a binary compatible change, but source breaking if your implementation ofActivityResultLauncher
is written in Kotlin.
- As part of the conversion of
Version 1.9.0-rc01
3 آوریل 2024
androidx.activity:activity:1.9.0-rc01
, androidx.activity:activity-compose:1.9.0-rc01
, and androidx.activity:activity-ktx:1.9.0-rc01
are released. Version 1.9.0-rc01 contains these commits .
به روز رسانی وابستگی
- Activity now depends on Profile Installer 1.3.1 .
Version 1.9.0-beta01
20 مارس 2024
androidx.activity:activity:1.9.0-beta01
, androidx.activity:activity-compose:1.9.0-beta01
, and androidx.activity:activity-ktx:1.9.0-beta01
are released. Version 1.9.0-beta01 contains these commits .
رفع اشکال
- Fixed an Activity startup performance regression introduced in Activity
1.9.0-alpha02
caused by calling theOnBackPressedDispatcher
as part of the creation of the Activity. ( Ie75e3 )
Version 1.9.0-alpha03
7 فوریه 2024
androidx.activity:activity:1.9.0-alpha03
, androidx.activity:activity-compose:1.9.0-alpha03
, and androidx.activity:activity-ktx:1.9.0-alpha03
are released. Version 1.9.0-alpha03 contains these commits.
Lint Warning
- The
OnBackPressedCallback
,BackHandler
, andPredictiveBackHandler
APIs now warn when callingonBackPressedDispatcher.onBackPressed()
when handling back as that will always break the Predictive Back Animation . See the best practices guide for more details. ( 1e4222 , 2c950d , b/287505200 )
رفع اشکال
- If a back event is sent from the system started during an already running Predictive Back Gesture, the currently running Predictive Back Gesture is canceled and the new back event takes over to begin a new Predictive Back Gesture. ( I3482e )
- Fixed a crash when accessing the
onBackPressedDispatcher
from aComponentActivity
for the first time from a background thread. It is now safe to access theonBackPressedDispatcher
on any thread. ( I79955 )
Version 1.9.0-alpha02
24 ژانویه 2024
androidx.activity:activity:1.9.0-alpha02
, androidx.activity:activity-compose:1.9.0-alpha02
, and androidx.activity:activity-ktx:1.9.0-alpha02
are released. Version 1.9.0-alpha02 contains these commits.
Kotlin Conversions
-
ActivityResultRegistry
has been rewritten in Kotlin. This ensures that the nullability of the generics on the contract passed toregister
will correctly be passed through to theActivityResultLauncher
returned to you. ( I121f0 ) -
ActivityResult
has been rewritten in Kotlin. TheActivityResult
Kotlin extensions that support destructuring into theresultCode
anddata
fields have been moved fromactivity-ktx
toactivity
. ( I0565a ) - The Kotlin extensions of
by viewModels()
forComponentActivity
andtrackPipAnimationHintView
have been moved fromactivity-ktx
toactivity
. Theactivity-ktx
artifact is now completely empty. ( I0a444 )
رفع اشکال
- The
enableEdgeToEdge
API now draws around any display cutouts. ( a3644b , b/311173461 ) - From Activity
1.8.2
: Fixed the extra passed to the Photo Picker Activity Contract'sACTION_SYSTEM_FALLBACK_PICK_IMAGES
to correctly pass it theEXTRA_SYSTEM_FALLBACK_PICK_IMAGES_MAX
key, rather than using the extra with the key"com.google.android.gms.provider.extra.PICK_IMAGES_MAX"
. It is strongly recommended if you are an OEM who implements a system fallback Photo Picker to support both extras to ensure the widest compatibility. ( I96a00 )
Version 1.9.0-alpha01
29 نوامبر 2023
androidx.activity:activity:1.9.0-alpha01
, androidx.activity:activity-compose:1.9.0-alpha01
, and androidx.activity:activity-ktx:1.9.0-alpha01
are released. Version 1.9.0-alpha01 contains these commits.
ویژگی های جدید
-
ComponentActivity
now implementsOnUserLeaveHintProvider
to allow components to callbacks foronUserLeaveHint
events. ( I54892 )
تغییرات API
-
ComponentActivity
has been rewritten in Kotlin. ( I14f31 ) -
ActivityResultCaller
has been rewritten in Kotlin. ( Ib02e4 ) -
ActivityResultLauncher
has been rewritten in Kotlin. As part of that conversion, thegetContract
method is now an abstract Kotlin property. This is a binary compatible change, but source breaking if your implementation ofActivityResultLauncher
is written in Kotlin. ( Id4615 ) -
PickVisualMediaRequest
now has the same minimum API level of 19 as thePickVisualMedia
Activity Result contract. ( Id6e21 )
Dependency Update
- Activity now depends on Core
1.13.0-alpha01
. ( I14f31 )
نسخه 1.8
نسخه 1.8.2
13 دسامبر 2023
androidx.activity:activity:1.8.2
, androidx.activity:activity-compose:1.8.2
, and androidx.activity:activity-ktx:1.8.2
are released. Version 1.8.2 contains these commits.
رفع اشکال
- Fixed the extra passed to the Photo Picker Activity Contract's
ACTION_SYSTEM_FALLBACK_PICK_IMAGES
to correctly pass it theEXTRA_SYSTEM_FALLBACK_PICK_IMAGES_MAX
key, rather than using the extra with the key"com.google.android.gms.provider.extra.PICK_IMAGES_MAX"
. It is strongly recommended if you are an OEM who implements a system fallback Photo Picker to support both extras to ensure the widest compatibility. ( I96a00 )
نسخه 1.8.1
15 نوامبر 2023
androidx.activity:activity:1.8.1
, androidx.activity:activity-compose:1.8.1
, and androidx.activity:activity-ktx:1.8.1
are released. Version 1.8.1 contains these commits.
رفع اشکال
-
OnBackPressedDispatcher
now continues to dispatch to the correctOnBackPressedCallback
even after a newOnBackPressedCallback
is added while the back gesture is being handled. ( Id0ff6 )
نسخه 1.8.0
4 اکتبر 2023
androidx.activity:activity:1.8.0
, androidx.activity:activity-compose:1.8.0
, and androidx.activity:activity-ktx:1.8.0
are released. Version 1.8.0 contains these commits.
Important changes since 1.7.0
- Predictive Back - The
OnBackPressedCallback
now offers new Predictive Back callbacks for handling the back gesture starting, progress throughout the gesture, and the back gesture being canceled in addition to the previoushandleOnBackPressed()
callback for when the back gesture is committed. This also comes with thePredictiveBackHandler
Composable to handle predictive back gesture events in Activity Compose. It provides a Flow of BackEventCompat objects that must be collected in the suspending lamba you provide:
PredictiveBackHandler { progress: Flow<BackEventCompat> ->
// code for gesture back started
try {
progress.collect { backEvent ->
// code for progress
}
// code for completion
} catch (e: CancellationException) {
// code for cancellation
}
}
ComponentActivity.onBackPressed()
has now been deprecated in favor of the APIs for handling back. Developers should now utilize the OnBackPressedDispatcher
, rather than overriding this method.
- EdgeToEdge -
ComponentActivity.enableEdgeToEdge()
has been added to easily set up the edge-to-edge display in a backward-compatible manner.
Version 1.8.0-rc01
20 سپتامبر 2023
androidx.activity:activity:1.8.0-rc01
, androidx.activity:activity-compose:1.8.0-rc01
, and androidx.activity:activity-ktx:1.8.0-rc01
are released. Version 1.8.0-rc01 contains these commits.
Version 1.8.0-beta01
6 سپتامبر 2023
androidx.activity:activity:1.8.0-beta01
, androidx.activity:activity-compose:1.8.0-beta01
, and androidx.activity:activity-ktx:1.8.0-beta01
are released. Version 1.8.0-beta01 contains these commits.
Documentation Improvement
- Improved the documentation of
BackEventCompat
. ( aosp/2722254 )
Version 1.8.0-alpha07
23 آگوست 2023
androidx.activity:activity:1.8.0-alpha07
, androidx.activity:activity-compose:1.8.0-alpha07
, and androidx.activity:activity-ktx:1.8.0-alpha07
are released. Version 1.8.0-alpha07 contains these commits.
ویژگی های جدید
Activity Compose has added a new
PredictiveBackHandler
Composable to handle predictive back gesture events. It provides aFlow
ofBackEventCompat
objects that must be collected in the suspending lamba you provide:PredictiveBackHandler { progress: Flow<BackEventCompat> -> // code for gesture back started try { progress.collect { backEvent -> // code for progress } // code for completion } catch (e: CancellationException) { // code for cancellation } }
It also comes with a compile time warning via lint rule to ensure the
Flow
callscollect()
. ( Id2773 , b/294884345 )The
onBackPressedDispatcher
inComponentActivity
is now initialized lazily so that it is only created when required. ( I0bf8e )
رفع اشکال
-
ComponentActivity
will no longer show a NPE on Android 13 when it gets anonBackPressed()
callback and the Activity has already beenDESTROYED
. ( Idb055 , b/291869278 ) - Removed usages of experimental
isAtLeastU()
API ( Ie9117 , b/289269026 )
Version 1.8.0-alpha06
21 ژوئن 2023
androidx.activity:activity:1.8.0-alpha06
, androidx.activity:activity-compose:1.8.0-alpha06
, and androidx.activity:activity-ktx:1.8.0-alpha06
are released. Version 1.8.0-alpha06 contains these commits.
ویژگی های جدید
- The
OnBackPressedDispatcher
now correctly cancels any callbacks that are removed during a Predictive Back Gesture. ( I3f90f )
تغییرات API
- When passing
SystemBarStyle.auto
to theenableEdgeToEdge
API, you can now override thedetectDarkMode
lambda parameter to provide custom logic for detecting night mode. ( aosp/2546393 , b/278263793 )
Version 1.8.0-alpha05
7 ژوئن 2023
androidx.activity:activity:1.8.0-alpha05
, androidx.activity:activity-compose:1.8.0-alpha05
, and androidx.activity:activity-ktx:1.8.0-alpha05
are released. This version is developed in an internal branch.
تغییرات API
- Activity now provides a
BackEventCompat
class that serves as a backward compatible version ofBackEvent
that is decoupled from the frameworkBackEvent
class. - Breaking change: The
handleOnBackStarted
andhandleOnBackProgressed
methods ofOnBackPressedCallback
now receive anandroidx.activity.BackEventCompat
instance rather than a frameworkandroid.window.BackEvent
class. The equivalent@VisibleForTesting
APIs onOnBackPressedDispatcher
have also been updated. - The constructor for
OnBackPressedDispatcher
now takes an optionalConsumer<Boolean>
instance that allows the owners of the dispatcher to receive a callback whenever the number of enabled callbacks changes from zero to non-zero or vice versa.
رفع اشکال
- From Activity
1.7.2
: FixReportDrawn
crashing when navigating away from a screen beforereport
is called. ( Ic46f1 , b/260506820 )
Version 1.8.0-alpha04
10 مه 2023
androidx.activity:activity:1.8.0-alpha04
, androidx.activity:activity-compose:1.8.0-alpha04
, and androidx.activity:activity-ktx:1.8.0-alpha04
are released. This was released from an internal branch.
رفع اشکال
- From Activity 1.7.1 : - The
ReportFullyDrawExecuter
no longer leaks when usingComponentActivity
withActivityScenario
. ( Id2ff2 , b/277434271 )
Version 1.8.0-alpha03
12 آوریل 2023
androidx.activity:activity:1.8.0-alpha03
, androidx.activity:activity-compose:1.8.0-alpha03
, and androidx.activity:activity-ktx:1.8.0-alpha03
are released. This was released from an internal branch.
ویژگی های جدید
- Added
ComponentActivity.setUpEdgeToEdge()
to easily set up the edge-to-edge display in a backward-compatible manner.
تغییرات API
-
ComponentActivity.onBackPressed()
has now been deprecated in favor of the APIs for handling back. Developers should now utilize theOnBackPressedDispatcher
, rather than overriding this method. ( Ibce2f , b/271596918 ) -
ComponentDialog
andComponentActivity
now contain public APIinitViewTreeOwners()
to be used to initialize all view tree owners before setting the content view. ( Ibdce0 , b/261314581 )
رفع اشکال
- Fixed an issue where Fragments were incorrectly invalidating MenuHosts and causing other menus in the Activity to have unexpected behavior. ( I9404e , b/244336571 )
سایر تغییرات
- The
ActivityResultRegister
now uses KotlinRandom
instead of Java. ( I4d98f , b/272096025 )
Version 1.8.0-alpha02
8 مارس 2023
androidx.activity:activity:1.8.0-alpha02
, androidx.activity:activity-compose:1.8.0-alpha02
, and androidx.activity:activity-ktx:1.8.0-alpha02
are released. Developed from an internal branch.
به روز رسانی وابستگی
- From Activity
1.7.0-rc01
: Activity now depends onLifecycle 2.6.0
.
Version 1.8.0-alpha01
8 فوریه 2023
androidx.activity:activity:1.8.0-alpha01
, androidx.activity:activity-compose:1.8.0-alpha01
, and androidx.activity:activity-ktx:1.8.0-alpha01
are released. This was built from an internal branch.
ویژگی های جدید
- The
OnBackPressedCallback
class now contains new Predictive Back progress callbacks for handling the back gesture starting, progress throughout the gesture, and the back gesture being canceled in addition to the previoushandleOnBackPressed()
callback for when the back gesture is committed.
نسخه 1.7
نسخه 1.7.2
24 مه 2023
androidx.activity:activity:1.7.2
, androidx.activity:activity-compose:1.7.2
, and androidx.activity:activity-ktx:1.7.2
are released. Version 1.7.2 contains these commits.
رفع اشکال
- Fix
ReportDrawn
crashing when navigating away from a screen beforereport
is called. ( Ic46f1 , b/260506820 )
نسخه 1.7.1
19 آوریل 2023
androidx.activity:activity:1.7.1
, androidx.activity:activity-compose:1.7.1
, and androidx.activity:activity-ktx:1.7.1
are released. Version 1.7.1 contains these commits.
رفع اشکال
- The
ReportFullyDrawExecuter
no longer leaks when usingComponentActivity
withActivityScenario
. ( Id2ff2 , b/277434271 )
نسخه 1.7.0
22 مارس 2023
androidx.activity:activity:1.7.0
, androidx.activity:activity-compose:1.7.0
, and androidx.activity:activity-ktx:1.7.0
are released. Version 1.7.0 contains these commits.
Important changes since 1.6.0
- The Photo Picker activity contracts in
PickVisualMedia
andPickMultipleVisualMedia
have been updated to contain an additional fallback for whenMediaStore.ACTION_PICK_IMAGES
is unavailable that allows OEMs and system apps, such as Google Play services, to provide a consistent Photo Picker experience on a wider range of Android devices and API levels by implementing the fallback action . The Photo Picker will use this fallback if it is available before falling back to usingIntent.ACTION_OPEN_DOCUMENT
, which remains to support all API 19 and higher devices. -
ComponentDialog
now implementsSavedStateRegistryOwner
and has access to its ownSavedStateRegistry
and sets theSavedStateRegistryOwner
for itsViewTree
. It is now possible to use Jetpack Compose within aComponentDialog
as it meets both theLifecycleOwner
andSavedStateRegistryOwner
attached to the Window via theViewTree
APIs requirements. -
IntentSenderRequest.Builder.setFlags()
now allows you to set multiple flags fromIntent
, rather than only a single flag.
Kotlin Conversion
A number of Activity classes have been converted to Kotlin. All converted classes still retain their binary compatibility with previous versions. The following classes have source incompatible changes for classes written in Kotlin: ActivityResultRegistryOwner
, OnBackPressedDispatcherOwner
.
The table below provides the source conversions for the new version of Activity:
Activity 1.5 | Activity 1.6 |
---|---|
override fun getActivityResultRegistry() = activityResultRegistry | override val activityResultRegistry = activityResultRegistry |
override fun getOnBackPressedDispatcher() = onBackPressedDispatcher | override val onBackPressedDispatcher = onBackPressedDispatcher |
These classes were also converted to Kotlin, but remain source compatible: ContextAware
, ContextAwareHelper
, OnContextAvailableListener
, IntentSenderRequest
, and OnBackPressedDispatcher
FullyDrawnReporter APIs
ComponentActivity
now provides a FullyDrawnReporter
instance that allows multiple components to report when they are ready for interaction. ComponentActivity
will wait for all components to complete before calling reportFullyDrawn()
on your behalf. These APIs take care of the timing requirements for you and do not need to be called as part of an onDraw
call.
These APIs are encouraged to enable:
- Signaling the Android Runtime when startup completes, to ensure all of the code run during a multi-frame startup sequence is included and prioritized for background compilation.
- Signaling Macrobenchmark and Play Vitals when your application should be considered fully drawn for startup metrics, so you can track performance.
Three Activity Compose APIs have been added to make it more convenient to use the FullyDrawnReporter
from individual composables:
-
ReportDrawn
indicates that your composable is immediately ready for interaction. -
ReportDrawnWhen
takes a predicate (ie,list.count > 0
) to indicate when your composable is ready for interaction. -
ReportDrawnAfter
takes a suspending method that, when it completes, indicates that you are ready for interaction.
Dependency Updates
- Activity now depends on Lifecycle
2.6.1
. ( 8fc31d ) - Activity now depends on ProfileInstaller
1.3.0
. ( 83d3b1 )
Version 1.7.0-rc01
8 مارس 2023
androidx.activity:activity:1.7.0-rc01
, androidx.activity:activity-compose:1.7.0-rc01
, and androidx.activity:activity-ktx:1.7.0-rc01
are released. Version 1.7.0-rc01 contains these commits.
به روز رسانی وابستگی
- Activity now depends on
Lifecycle 2.6.0
.
Version 1.7.0-beta02
22 فوریه 2023
androidx.activity:activity:1.7.0-beta02
, androidx.activity:activity-compose:1.7.0-beta02
, and androidx.activity:activity-ktx:1.7.0-beta02
are released. Version 1.7.0-beta02 contains these commits.
تغییرات API
- The action and extra used by the
PickVisualMedia
andPickMultipleVisualMedia
contracts as a fallback for whenMediaStore.ACTION_PICK_IMAGES
is unavailable are now public constants that provide API stability to OEMs and system apps that want to provide a consistent Photo Picker experience. The implementation of this fallback is still limited to only system apps. ( Icd320 )
Version 1.7.0-beta01
8 فوریه 2023
androidx.activity:activity:1.7.0-beta01
, androidx.activity:activity-compose:1.7.0-beta01
, and androidx.activity:activity-ktx:1.7.0-beta01
are released. Version 1.7.0-beta01 contains these commits.
ویژگی های جدید
-
IntentSenderRequest.Builder.setFlags()
now allows you to set multiple flags fromIntent
, rather than only a single flag. ( Iac04c )
رفع اشکال
- The fallback for
PickVisualMedia
for when the framework Photo Picker is unavailable now correctly limits the handling to apps installed in the device's system image. ( If8ae6 )
Kotlin Conversions
-
ActivityResultRegistryOwner
is now written in Kotlin. This is a source incompatible change for those classes written in Kotlin - you must now override theactivityResultRegistry
property rather than implementing the previousgetActivityResultRegistry()
function. ( I0b00e ) -
OnBackPressedDispatcherOwner
is now written in Kotlin. This is a source incompatible change for those classes written in Kotlin - you must now override theonBackPressedDispatcher
property rather than implementing the previousgetOnBackPressedDispatcher
function. ( Ia277d ) -
ContextAware
,ContextAwareHelper
,OnContextAvailableListener
,IntentSenderRequest
andOnBackPressedDispatcher
are now written in Kotlin. ( I1a73e , Iada92 , aosp/2410754 , I18ac7 , b/257291701 )
Version 1.7.0-alpha04
25 ژانویه 2023
androidx.activity:activity:1.7.0-alpha04
, androidx.activity:activity-compose:1.7.0-alpha04
, and androidx.activity:activity-ktx:1.7.0-alpha04
are released. Version 1.7.0-alpha04 contains these commits.
ویژگی های جدید
- The
PickVisualMedia
andPickMultipleVisualMedia
Activity Result contracts will now use a Google Play services provided Photo Picker where available in cases where the Android system provided Photo Picker (eg,MediaStore.ACTION_PICK_IMAGES
) is not available. TheisPhotoPickerAvailable()
API that only detects the Android system provided Photo Picker has been deprecated. It is recommended to use the newisPhotoPickerAvailable(Context)
API, which will return if either Photo Picker is available. ( I55be6 )
Version 1.7.0-alpha03
11 ژانویه 2023
androidx.activity:activity:1.7.0-alpha03
, androidx.activity:activity-compose:1.7.0-alpha03
, and androidx.activity:activity-ktx:1.7.0-alpha03
are released. Version 1.7.0-alpha03 contains these commits.
ویژگی های جدید
-
ComponentDialog
now implementsSavedStateRegistryOwner
and has access to its ownSavedStateRegistry
and sets theSavedStateRegistryOwner
for its ViewTree. It is now possible to use Jetpack Compose within aComponentDialog
as it meets both theLifecycleOwner
andSavedStateRegistryOwner
attached to the Window via the ViewTree APIs requirements. ( Idca17 , I73468 b/261162296 )
تغییرات API
- Added a
ReportDrawn
composable that immediately marks the activity as ready to callreportFullyDrawn
. ( Ic5b14 , b/259687964 )
Kotlin Conversions
- The
ActvitiyResultCallback
andOnBackPressedCallback
classes have both been converted to Kotlin while maintaining source and binary compatibility. ( Ifc5e5 , Ide1b0 , b/257291701 )
Version 1.7.0-alpha02
24 اکتبر 2022
androidx.activity:activity:1.7.0-alpha02
, androidx.activity:activity-compose:1.7.0-alpha02
, and androidx.activity:activity-ktx:1.7.0-alpha02
are released. Version 1.7.0-alpha02 contains these commits.
رفع اشکال
- From Activity
1.6.1
: Fixed an issue with thePickMultipleVisualMedia
Activity Result contract not launching on Android R devices when using the default value formaxItems
. ( Ie2776 , b/249182130 )
Version 1.7.0-alpha01
5 اکتبر 2022
androidx.activity:activity:1.7.0-alpha01
, androidx.activity:activity-compose:1.7.0-alpha01
, and androidx.activity:activity-ktx:1.7.0-alpha01
are released. Version 1.7.0-alpha01 contains these commits.
FullyDrawnReporter APIs
ComponentActivity
now provides a FullyDrawnReporter
instance that allows multiple components to report when they are ready for interaction. ComponentActivity
will wait for all components to complete before calling reportFullyDrawn()
on your behalf. These APIs take care of the timing requirements for you and do not need to be called as part of an onDraw
call.
These APIs are encouraged to enable:
- Signaling the Android Runtime when startup completes, to ensure all of the code run during a multi-frame startup sequence is included and prioritized for background compilation.
- Signaling Macrobenchmark and Play Vitals when your application should be considered fully drawn for startup metrics, so you can track performance.
Two Activity Compose APIs have been added to make it more convenient to use the FullyDrawnReporter
from individual composables:
-
ReportDrawnWhen
takes a predicate (ie,list.count > 0
) to indicate when your composable is ready for interaction. -
ReportDrawnAfter
takes a suspending method that, when it completes, indicates that you are ready for interaction.
نسخه 1.6.1
نسخه 1.6.1
24 اکتبر 2022
androidx.activity:activity:1.6.1
, androidx.activity:activity-compose:1.6.1
, and androidx.activity:activity-ktx:1.6.1
are released. Version 1.6.1 contains these commits.
رفع اشکال
- Fixed an issue with the
PickMultipleVisualMedia
Activity Result contract not launching on Android R devices when using the default value formaxItems
. ( Ie2776 , b/249182130 )
نسخه 1.6.0
نسخه 1.6.0
21 سپتامبر 2022
androidx.activity:activity:1.6.0
, androidx.activity:activity-compose:1.6.0
, and androidx.activity:activity-ktx:1.6.0
are released. Version 1.6.0 contains these commits.
Important changes since 1.5.0
- Added
ActivityResultContracts.PickVisualMedia
andActivityResultContracts.PickMultipleVisualMedia
for providing a backward compatible contract that usesMediaStore.ACTION_PICK_IMAGES
when the Photo Picker is available andIntent.ACTION_OPEN_DOCUMENT
when it is not available. - Integrated the
OnBackInvokedCallback
in Android 13 into theOnBackPressedDispatchers
provided byComponentActivity
andComponentDialog
. This ensures that all APIs built onOnBackPressedDispatcher
work when enabling a predictive back gesture .
Version 1.6.0-rc02
7 سپتامبر 2022
androidx.activity:activity:1.6.0-rc02
, androidx.activity:activity-compose:1.6.0-rc02
, and androidx.activity:activity-ktx:1.6.0-rc02
are released. Version 1.6.0-rc02 contains these commits.
رفع اشکال
-
OnBackPressedDispatcher
now registers theOnBackInvokedCallback
with thePRIORITY_DEFAULT
instead ofPRIORITY_OVERLAY
. ( I3901f ) - Classes that extend
ComponentActivity
will now always have both of theironMultiWindowModeChanged()
callbacks dispatched. ( Ic4d85 ) - The
ActivityResultRegistry
will no longer return a result to theActivityResultCallback
when thelaunch
call throws anyException
and the callback was registered without aLifecycleOwner
. ( Ia7ff7 , b/238350794 ) -
ComponentActivity
will now properly dispatch menu calls without the need to call the super function in your activity. ( Ie33c5 , b/238057118 )
Dependency Update
- The
Activity
library now depends on Lifecycle2.5.1
. ( If6697 )
Version 1.6.0-rc01
24 آگوست 2022
androidx.activity:activity:1.6.0-rc01
, androidx.activity:activity-compose:1.6.0-rc01
, and androidx.activity:activity-ktx:1.6.0-rc01
are released. Version 1.6.0-rc01 contains these commits.
رفع اشکال
- Initializing an
OnBackPressedDispatcher
will no longer causeClassVerificationError
s when using SDK versions prior to 33. ( Ic32e1 ) - Classes that override
ComponentActivity
'sonPictureInPictureModeChanged()
callback will now always have their callbacks dispatched. ( Ib7fdb )
Version 1.6.0-beta01
August 10, 2022
androidx.activity:activity:1.6.0-beta01
, androidx.activity:activity-compose:1.6.0-beta01
, and androidx.activity:activity-ktx:1.6.0-beta01
are released. Version 1.6.0-beta01 contains these commits.
تغییرات API
- Marked the deprecated
startActivityForResult
andstartIntentSenderForResult
methods onComponentActivity
with@NonNull
because passingnull
has always resulted in a crash. ( Id2a25 , b/231476082 )
رفع اشکال
- From Activity
1.5.1
: TheActivityResultRegistry
will no longer return a result to theActivityResultCallback
when thelaunch
call throws anyException
and the callback was registered without aLifecycleOwner
. ( Ia7ff7 , b/238350794 ) - From Activity
1.5.1
:ComponentActivity
will now properly dispatch menu calls toonPrepareOptionMenu()
,onCreateOptionsMenu()
andonOptionsItemSelected()
overrides without the need to call the super function. ( Ie33c5 , b/238057118 )
Dependency Update
- From Activity
1.5.1
: TheActivity
library now depends on theLifecycle
version2.5.1
. ( If6697 )
Version 1.6.0-alpha05
15 ژوئن 2022
androidx.activity:activity:1.6.0-alpha05
, androidx.activity:activity-compose:1.6.0-alpha05
, and androidx.activity:activity-ktx:1.6.0-alpha05
are released. Version 1.6.0-alpha05 was developed in a private pre-release branch and has no public commits.
تغییرات API
-
minCompileSdk
is now 33 to align with Tiramisu Beta 3 SDK
رفع اشکال
- Fixed crash on older devices when doing SDK extension check for the
PickVisualMedia
ActivityResultContract
so that it should now work withACTION_OPEN_DOCUMENT
on devices running Android 10 and lower.
Version 1.6.0-alpha04
18 مه 2022
androidx.activity:activity:1.6.0-alpha04
and androidx.activity:activity-ktx:1.6.0-alpha04
are released.
رفع اشکال
- Fixed an error in
PickVisualMediaRequest
where attempting to create a request, either via the Builder or the top level Kotlin function, would result in a stack overflow. - Integrated the
OnBackInvokedCallback
in Android 13 Dev Beta 2 into theOnBackPressedDispatcher
provided byComponentDialog
. This ensures that all APIs built onOnBackPressedDispatcher
work when enabling a predictive back gesture .
Version 1.6.0-alpha03
27 آوریل 2022
androidx.activity:activity:1.6.0-alpha03
, androidx.activity:activity-compose:1.6.0-alpha03
, and androidx.activity:activity-ktx:1.6.0-alpha03
are released.
- Note: This version will only compile against the Android 13 Developer Beta 1 SDK.
ویژگی های جدید
- Added
ActivityResultContracts.PickVisualMedia
andActivityResultContracts.PickMultipleVisualMedia
for providing a backward compatible contract that usesMediaStore.ACTION_PICK_IMAGES
when the Photo Picker is available andIntent.ACTION_OPEN_DOCUMENT
when it is not available. - Integrated the
OnBackInvokedCallback
in Android 13 Dev Beta 1 into theOnBackPressedDispatcher
provided byComponentActivity
. This ensures that all APIs built onOnBackPressedDispatcher
work when enabling a predictive back gesture .
Version 1.6.0-alpha01
23 مارس 2022
androidx.activity:activity:1.6.0-alpha01
, androidx.activity:activity-compose:1.6.0-alpha01
, and androidx.activity:activity-ktx:1.6.0-alpha01
are released.
- Note: This version will only compile against the Android 13 Developer Preview 2 SDK.
ویژگی های جدید
- Integrated changes in Android 13 Dev Preview 2 into
ComponentActivity
.
نسخه 1.5.1
نسخه 1.5.1
27 جولای 2022
androidx.activity:activity:1.5.1
, androidx.activity:activity-compose:1.5.1
, and androidx.activity:activity-ktx:1.5.1
are released. Version 1.5.1 contains these commits.
رفع اشکال
The
ActivityResultRegistry
will no longer return a result to theActivityResultCallback
when thelaunch()
call throws anyException
and the callback was registered without aLifecycleOwner
. ( Ia7ff7 , b/238350794 )ComponentActivity
will now properly dispatch menu calls toonPrepareOptionMenu()
,onCreateOptionsMenu()
andonOptionsItemSelected()
overrides without the need to call the super function. ( Ie33c5 , b/238057118 )
به روز رسانی وابستگی
- The
Activity
library now depends on the Lifecycle2.5.1
. ( If6697 )
نسخه 1.5.0
نسخه 1.5.0
29 ژوئن 2022
androidx.activity:activity:1.5.0
, androidx.activity:activity-compose:1.5.0
, and androidx.activity:activity-ktx:1.5.0
are released. Version 1.5.0 contains these commits.
Important changes since 1.4.0
- ComponentDialog -
ComponentDialog
is a subclass ofDialog
that includes anOnBackPressedDispatcher
that will be called when the system back button is pressed and the dialog is visible. Importantly, this subclass also sets theViewTreeOnBackPressedDispatcherOwner
, allowing views a generic way to retrieve the correct dispatcher whether it exists in aComponentActivity
or aComponentDialog
. - Callback Interfaces -
ComponentActivity
now implements a set of modular callback interfaces that can be used instead of theActivity
callbacks. These interfaces include the following:OnNewIntentProvider
,OnConfigurationChangedProvider
,OnTrimMemoryProvider
,OnPictureInPictureModeChangedProvider
,OnMultiWindowModeChangedProvider
- CreationExtras Integration -
ComponentActivity
now has the ability to provide a statelessViewModelProvider.Factory
via Lifecycle2.5.0
'sCreationExtras
.
تغییرات دیگر
- The no parameter constructor for
ActivityResultContracts.CreateDocument
has been deprecated and replaced with a new constructor that takes a concrete mime type (eg, "image/png") as is required byIntent.ACTION_CREATE_DOCUMENT
.
Version 1.5.0-rc01
11 مه 2022
androidx.activity:activity:1.5.0-rc01
, androidx.activity:activity-compose:1.5.0-rc01
, and androidx.activity:activity-ktx:1.5.0-rc01
are released with no changes from 1.5.0-beta01. Version 1.5.0-rc01 contains these commits.
Version 1.5.0-beta01
20 آوریل 2022
androidx.activity:activity:1.5.0-beta01
, androidx.activity:activity-compose:1.5.0-beta01
, and androidx.activity:activity-ktx:1.5.0-beta01
are released. Version 1.5.0-beta01 contains these commits.
Dependency updates
- Activity now depends on Lifecycle
2.4.0-beta01
.
Version 1.5.0-alpha05
6 آوریل 2022
androidx.activity:activity:1.5.0-alpha05
, androidx.activity:activity-compose:1.5.0-alpha05
, and androidx.activity:activity-ktx:1.5.0-alpha05
are released. Version 1.5.0-alpha05 contains these commits.
رفع اشکال
-
ComponentActivity
'sonPanelClosed()
now calls the superonPanelClosed()
as well, fixing an issue where theonContextMenuClosed
method would not be called. ( Ib6f77 )
Version 1.5.0-alpha04
23 مارس 2022
androidx.activity:activity:1.5.0-alpha04
, androidx.activity:activity-compose:1.5.0-alpha04
, and androidx.activity:activity-ktx:1.5.0-alpha04
are released. Version 1.5.0-alpha04 contains these commits.
رفع اشکال
-
SavedStateViewFactory
now supports usingCreationExtras
even when it was initialized with aSavedStateRegistryOwner
. If extras are provided, the initialized arguments are ignored. ( I6c43b , b/224844583 )
Version 1.5.0-alpha03
23 فوریه 2022
androidx.activity:activity:1.5.0-alpha03
, androidx.activity:activity-compose:1.5.0-alpha03
, and androidx.activity:activity-ktx:1.5.0-alpha03
are released. Version 1.5.0-alpha03 contains these commits.
تغییرات API
- You can now pass
CreationExtras
to the activityby viewModels()
function ( I6a3e6 , b/217600303 )
Version 1.5.0-alpha02
9 فوریه 2022
androidx.activity:activity:1.5.0-alpha02
, androidx.activity:activity-compose:1.5.0-alpha02
, and androidx.activity:activity-ktx:1.5.0-alpha02
are released. Version 1.5.0-alpha02 contains these commits.
ویژگی های جدید
-
ComponentActivity
now implements theOnPictureInPictureModeChangedProvider
interface to allow any component to receive picture-in-picture mode change events. ( I9f567 ) -
ComponentActivity
now implements theOnMultiWindowModeChangedProvider
interface to allow any component to receive multi-window mode change events. ( I62d91 )
Version 1.5.0-alpha01
26 ژانویه 2022
androidx.activity:activity:1.5.0-alpha01
, androidx.activity:activity-compose:1.5.0-alpha01
, and androidx.activity:activity-ktx:1.5.0-alpha01
are released. Version 1.5.0-alpha01 contains these commits.
ویژگی های جدید
-
ComponentActivity
now integrates with ViewModel CreationExtras, introduced as part of Lifecycle2.5.0-alpha01
. ( Ie7e00 , b/207012584 ) - Added
ComponentDialog
, a subclass ofDialog
that includes anOnBackPressedDispatcher
that will be called when the system back button is pressed when the dialog is visible. Importantly, this subclass also sets theViewTreeOnBackPressedDispatcherOwner
, allowing views a generic way to retrieve the correct dispatcher whether it exists in aComponentActivity
or aComponentDialog
. ( I8a1bc ) -
ComponentActivity
now implements the newOnNewIntentProvider
interface to allow any component to receive these events. ( If1f8b ) -
ComponentActivity
now implements the newOnConfigurationChangedProvider
interface to allow any component to receive these events. ( If623b ) -
ComponentActivity
now implements the newOnTrimMemoryProvider
interface to allow any component to receive these events. ( Ia9295 )
تغییرات API
- The no parameter constructor for
ActivityResultContracts.CreateDocument
has been deprecated and replaced with a new constructor that takes a concrete mime type (eg,"image/png"
) as is required byIntent.ACTION_CREATE_DOCUMENT
. ( I2bec6 ) - The
OnBackPressedDispatcherOwner
associated with a View can now be retrieved via theViewTreeOnBackPressedDispatcherOwner
, rather than relying on casting theContext
. ( I74685 )
رفع اشکال
- Fixed a crash when accessing a
ViewModel
for the very first time from aregisterForActivityResult()
callback or the callbacks to aLifecycleObserver
added as part ofinit
of aComponentActivity
. ( Ife83f )
نسخه 1.4.0
نسخه 1.4.0
27 اکتبر 2021
androidx.activity:activity:1.4.0
, androidx.activity:activity-compose:1.4.0
, and androidx.activity:activity-ktx:1.4.0
are released. Version 1.4.0 contains these commits.
Important changes since 1.3.0
- AndroidX
ComponentActivity
now implements theMenuHost
interface. This allows any component to add menu items to theActionBar
by adding aMenuProvider
instance to the activity. EachMenuProvider
can optionally be added with aLifecycle
that will automatically control the visibility of those menu items based on theLifecycle
state and handle the removal of theMenuProvider
when theLifecycle
is destroyed. - The
ActivityResultContract
class has been rewritten in Kotlin to ensure that developers writing custom contracts in Kotlin can define the correct nullability for their input and output classes. - The
ActivityResultContracts
class and its contracts have been rewritten in Kotlin to ensure the proper nullability.
Version 1.4.0-rc01
13 اکتبر 2021
androidx.activity:activity:1.4.0-rc01
, androidx.activity:activity-compose:1.4.0-rc01
, and androidx.activity:activity-ktx:1.4.0-rc01
are released. Version 1.4.0-rc01 contains these commits.
رفع اشکال
- The
ActivityResultRegistry
will no longer return a result to theActivityResultCallback
when thelaunch
call throws anyException
. ( If4f91 , b/200845664 )
Version 1.4.0-beta01
29 سپتامبر 2021
androidx.activity:activity:1.4.0-beta01
, androidx.activity:activity-compose:1.4.0-beta01
, and androidx.activity:activity-ktx:1.4.0-beta01
are released. Version 1.4.0-beta01 contains these commits.
تغییرات API
- Fixed the type for the
ActivityResultContracts.OpenMultipleDocuments
andActivityResultContracts.GetMultipleContents
that caused then to use an output type ofList<? extends Uri>
when using the code from the Java programming language. ( If71de ) - Public constants within the
ActivityResultContracts.StartActivityForResult
,ActivityResultContracts.StartIntentSenderForResult
, andActivityResultContracts.RequestMultiplePermissions
classes are now accessible when using Kotlin via their now publicCompanion
objects. ( aosp/1832555 )
به روز رسانی اسناد
- The deprecation message for APIs now handled by the Activity Result APIs , namely
startActivityForResult
,startIntentSenderForResult
,onActivityResult
,requestPermissions
, andonRequestPermissionsResult
, have all been expanded with more details. ( cce80f )
Version 1.4.0-alpha02
15 سپتامبر 2021
androidx.activity:activity:1.4.0-alpha02
, androidx.activity:activity-compose:1.4.0-alpha02
, and androidx.activity:activity-ktx:1.4.0-alpha02
are released. Version 1.4.0-alpha02 contains these commits.
ویژگی های جدید
- The
activity-compose
artifact now contains aLaunchDuringComposition
lint error that prevents you from calling thelaunch
method ofActivityResultLauncher
as part of composition as composition should be side-effect free. Use the APIs for handling side-effects . ( 7c2bbe , b/191347220 )
تغییرات API
- The
ActivityResultContract
class has been rewritten in Kotlin to ensure that developers writing custom contracts in Kotlin can define the correct nullability for their input and output classes. ( I8a8f5 ) - The
ActivityResultContracts
class and its contracts have been rewritten in Kotlin to ensure the proper nullability. ( I69802 )
Version 1.4.0-alpha01
1 سپتامبر 2021
androidx.activity:activity:1.4.0-alpha01
, androidx.activity:activity-compose:1.4.0-alpha01
, and androidx.activity:activity-ktx:1.4.0-alpha01
are released. Version 1.4.0-alpha01 contains these commits.
ویژگی های جدید
- AndroidX
ComponentActivity
now implements theMenuHost
interface.. This allows any component to add menu items to theActionBar
by adding aMenuProvider
instance to the activity. EachMenuProvider
can optionally be added with aLifecycle
that will automatically control the visibility of those menu items based on theLifecycle
state and handle the removal of theMenuProvider
when theLifecycle
is destroyed. ( I3b608 ):
/**
* Using the addMenuProvider() API directly in your Activity
**/
class ExampleActivity : ComponentActivity(R.layout.activity_example) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Add menu items without overriding methods in the Activity
addMenuProvider(object : MenuProvider {
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
// Add menu items here
menuInflater.inflate(R.menu.example_menu, menu)
}
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
// Handle the menu selection
return true
}
})
}
}
/**
* Using the addMenuProvider() API in a Fragment
**/
class ExampleFragment : Fragment(R.layout.fragment_example) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
// The usage of an interface lets you inject your own implementation
val menuHost: MenuHost = requireActivity()
// Add menu items without using the Fragment Menu APIs
// Note how we can tie the MenuProvider to the viewLifecycleOwner
// and an optional Lifecycle.State (here, RESUMED) to indicate when
// the menu should be visible
menuHost.addMenuProvider(object : MenuProvider {
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
// Add menu items here
menuInflater.inflate(R.menu.example_menu, menu)
}
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
// Handle the menu selection
return true
}
}, viewLifecycleOwner, Lifecycle.State.RESUMED)
}
تغییرات رفتار
- The
ActivityResultRegistry
will now throw anIllegalStateException
when attempting to calllaunch()
on anActivityResultLauncher
that has not be registered or that has been unregistered. ( Ida75d , b/192567522 )
External Contribution
نسخه 1.3.1
نسخه 1.3.1
4 آگوست 2021
androidx.activity:activity:1.3.1
, androidx.activity:activity-compose:1.3.1
, and androidx.activity:activity-ktx:1.3.1
are released. Version 1.3.1 contains these commits.
Dependency updates
- Activity now depends on Kotlin
1.5.21
. - Activity Compose now depends on Compose
1.0.1
.
Version 1.3.0
Version 1.3.0
28 ژوئیه 2021
androidx.activity:activity:1.3.0
, androidx.activity:activity-compose:1.3.0
, and androidx.activity:activity-ktx:1.3.0
are released. Version 1.3.0 contains these commits.
Important changes since 1.2.0
- Activity Compose artifact - The
activity-compose
artifact provides thesetContent
extension method for hosting your Jetpack Compose UI in an activity and Compose specific wrappers for interacting with theComponentActivity
APIs for handling the system back button and the Activity Result APIs. برای جزئیات بیشتر به مستندات مراجعه کنید. - CaptureVideo contract - The
CaptureVideo
ActivityResultContract
replaces the now deprecatedTakeVideo
contract and returns a boolean denoting success that works across many camera apps. - Picture-In-Picture Hint View Tracking - Users of
activity-ktx
can now use thetrackPipAnimationHintView
extension method onActivity
to automatically rebuild thePictureInPictureParams
with the new position of the view as it changes position relative to the window.
Version 1.3.0-rc02
14 جولای 2021
androidx.activity:activity:1.3.0-rc02
, androidx.activity:activity-compose:1.3.0-rc02
, and androidx.activity:activity-ktx:1.3.0-rc02
are released. Version 1.3.0-rc02 contains these commits.
رفع اشکال
- The
ActivityResultRegistry
callbacks are now properly saved and restored so callbacks are not duplicated in the savedState. ( I97816 , b/191893160 )
Version 1.3.0-rc01
1 ژوئیه 2021
androidx.activity:activity:1.3.0-rc01
, androidx.activity:activity-compose:1.3.0-rc01
, and androidx.activity:activity-ktx:1.3.0-rc01
are released with no changes from 1.3.0-beta02
. Version 1.3.0-rc01 contains these commits.
Version 1.3.0-beta02
16 ژوئن 2021
androidx.activity:activity:1.3.0-beta02
, androidx.activity:activity-compose:1.3.0-beta02
, and androidx.activity:activity-ktx:1.3.0-beta02
are released. Version 1.3.0-beta02 contains these commits.
Updated activity-compose
to depend on Compose 1.0.0-beta09
. androidx.compose.ui:ui-test-junit4
now has a compile time dependency on activity-compose
.
Version 1.3.0-beta01
2 ژوئن 2021
androidx.activity:activity:1.3.0-beta01
, androidx.activity:activity-compose:1.3.0-beta01
, and androidx.activity:activity-ktx:1.3.0-beta01
are released. Version 1.3.0-beta01 contains these commits.
تغییرات API
- The previously deprecated
@Composable registerForActivityResult()
method has been removed. Please userememberLauncherForActivityResult()
. ( Ic39d3 )
Version 1.3.0-alpha08
18 مه 2021
androidx.activity:activity:1.3.0-alpha08
, androidx.activity:activity-compose:1.3.0-alpha08
, and androidx.activity:activity-ktx:1.3.0-alpha08
are released. Version 1.3.0-alpha08 contains these commits.
ویژگی های جدید
- The new
CaptureVideo
ActivityResultContract
returns a boolean to yourActivityResultCallback
indicating if your video was successfully saved to the given URI. This replaces the now deprecatedTakeVideo
contract as camera apps very rarely supported returning a thumbnail bitmap, making the result unhelpful. ( Ie21f2 , b/185938070 ) - Added new API
Activity#setPipAnimationHintView
to update the PipParams' source rect hint whenever the view moves. ( I9063d )
تغییرات API
- The
rememberLauncherForActivityResult
function now returns a launcher that deprecates theunregister()
function - registration and unregistering the launcher is handled automatically byrememberLauncherForActivityResult
. ( I2443e )
Compose Compatibility
-
androidx.activity:activity-compose:1.3.0-alpha08
is only compatible with Compose version1.0.0-beta07
and above.
Version 1.3.0-alpha07
21 آوریل 2021
androidx.activity:activity:1.3.0-alpha07
, androidx.activity:activity-compose:1.3.0-alpha07
, and androidx.activity:activity-ktx:1.3.0-alpha07
are released. Version 1.3.0-alpha07 contains these commits.
رفع اشکال
-
rememberLauncherForActivityResult
now returns a stable reference to the sameActivityResultLauncher
instance even if the contract changes due to recompositions. ( Id2d6d ) - Using unstable versions of Fragments above
1.3.0
will no longer throw a false positive lint error telling you to use1.3.0
. ( aosp/1670206 , b/184847092 )
Version 1.3.0-alpha06
7 آوریل 2021
androidx.activity:activity:1.3.0-alpha06
, androidx.activity:activity-compose:1.3.0-alpha06
, and androidx.activity:activity-ktx:1.3.0-alpha06
are released. Version 1.3.0-alpha06 contains these commits.
تغییرات API
- The
registerForActivityResult()
API has been renamed torememberLauncherForActivityResult()
to better indicate that the returnedActivityResultLauncher
is a managed object that is remembered on your behalf. Attempting to callunregister
the returnedActivityResultLauncher
will now throw an error. ( I2bb6d ) -
LocalOnBackPressedDispatcherOwner.current
andLocalActivityResultRegistryOwner.current
now return a nullable value to better determine whether it is available in the current composition. APIs that requires those APIs, such asBackHandler
andrememberLauncherForActivityResult()
, respectively, will now throw a more descriptive error if the underlying owner is not found.NavHost
now works even when anOnBackPressedDispatcherOwner
is not found, such is the case when previewing theNavHost
. ( I7d8b4 )
رفع اشکال
- The
BackHandler
will now properly intercept back presses in the event that the Activity isSTOPPED
, thenSTARTED
again, and other callbacks were added with a LifecycleOwner. ( I71de6 , b/182284739 ) - Using the
launch()
method extension with a customActivityResultContract
that has aUnit
input will no longer cause aNullPointerException
( I76282 , b/183837954 )
Version 1.3.0-alpha05
24 مارس 2021
androidx.activity:activity:1.3.0-alpha05
, androidx.activity:activity-compose:1.3.0-alpha05
, and androidx.activity:activity-ktx:1.3.0-alpha05
are released. Version 1.3.0-alpha05 contains these commits.
رفع اشکال
- From Activity 1.2.2 : Fixed an issue in the
InvalidFragmentVersionForActivityResult
lint check that led to a false positive when using Fragment 1.3.1 or higher. ( I54da1 , b/182388985 ) - From Activity 1.2.2 :
ComponentActivity
now avoids aClassNotFoundException
when launching anIntent
from anActivityResultContract
that was previously held as an extra in anotherIntent
. ( Ieff05 , b/182906230 )
Dependency Updates
- From Activity 1.2.2 : Activity now depends on Lifecycle
2.3.1
.
Version 1.3.0-alpha04
10 مارس 2021
androidx.activity:activity:1.3.0-alpha04
, androidx.activity:activity-compose:1.3.0-alpha04
, and androidx.activity:activity-ktx:1.3.0-alpha04
are released. Version 1.3.0-alpha04 contains these commits.
رفع اشکال
- From Activity
1.2.1
:RequestMultiplePermissions
now always returns results for all requested permissions instead of only permissions that weren't previously granted. ( I50bc3 , b/180884668 ) - From Activity
1.2.1
:ActivityResultRegistry
now ensures that in progresslaunch()
requests will return their results even if youunregister()
, thenregister()
again with the same key. ( I9ef34 , b/181267562 ) - Activity Compose no longer adds test dependencies to the runtime classpath. ( Ifd8b3 )
- Fixed an issue with
BackHandler
where the previously setonBack
lambda was still being used after recomposition. ( 8eb5eb )
Version 1.3.0-alpha03
24 فوریه 2021
androidx.activity:activity:1.3.0-alpha03
, androidx.activity:activity-compose:1.3.0-alpha03
, and androidx.activity:activity-ktx:1.3.0-alpha03
are released. Version 1.3.0-alpha03 contains these commits.
ویژگی های جدید
- There is a now a Composable
registerForActivityResult
function for getting results from activities within composables. ( Ia7851 , b/172690553 )
تغییرات API
-
LocalOnBackPressedDispatcherOwner
now has aprovides
functions that can be used withCompositionLocalProvider
, replacing theasProvidableCompositionLocal()
API. ( I45d24 )
Version 1.3.0-alpha02
10 فوریه 2021
androidx.activity:activity:1.3.0-alpha02
, androidx.activity:activity-compose:1.3.0-alpha02
, and androidx.activity:activity-ktx:1.3.0-alpha02
are released. Version 1.3.0-alpha02 contains these commits.
رفع اشکال
- Fixed an issue in Activity Compose
1.3.0-alpha01
that causes aNoSuchMethodError: No static method setContent
exception when using Compose1.0.0-alpha12
. All Compose users should depend on1.3.0-alpha02
and above. ( b/179911234 )
تغییرات API
- The
BackHandler
API can be used to allow a Composable to intercept the system back button. ( I58ed5 , b/172154006 )
Version 1.3.0-alpha01
10 فوریه 2021
androidx.activity:activity:1.3.0-alpha01
, androidx.activity:activity-compose:1.3.0-alpha01
, and androidx.activity:activity-ktx:1.3.0-alpha01
are released. Version 1.3.0-alpha01 contains these commits.
ویژگی های جدید
- The new
activity-compose
artifact provides Jetpack Compose specific helpers forandroidx.activity
specific APIs.-
ComponentActivity.setContent
has moved fromandroidx.compose.ui.platform.setContent
toandroidx.activity.compose.setContent
. ( Icf416 )
-
مسائل شناخته شده
- Using Activity Compose
1.3.0-alpha01
and libraries that depend on it, such asandroidx.compose.ui:ui-test-junit4:1.0.0-alpha12
, will result in aNoSuchMethodError: No static method setContent
exception. ( b/179911234 )
نسخه 1.2.4
نسخه 1.2.4
21 جولای 2021
androidx.activity:activity:1.2.4
and androidx.activity:activity-ktx:1.2.4
are released. Version 1.2.4 contains these commits.
رفع اشکال
- From Activity
1.3.0-rc02
: The ActivityResultRegistry callbacks are now properly saved and restored so callbacks are not duplicated in the savedState. ( I97816 , b/191893160 )
Version 1.2.3
Version 1.2.3
5 مه 2021
androidx.activity:activity:1.2.3
and androidx.activity:activity-ktx:1.2.3
are released. Version 1.2.3 contains these commits.
رفع اشکال
- Using the
launch()
method extension with a customActivityResultContract
that has aUnit
input will no longer cause aNullPointerException
( I76282 , b/183837954 ) - Fixed a false positive lint error telling you to use Fragment
1.3.0
when using an snapshot, alpha, beta, or RC build of a newer version of Fragments. ( f4a57e , b/184847092 )
نسخه 1.2.2
نسخه 1.2.2
24 مارس 2021
androidx.activity:activity:1.2.2
and androidx.activity:activity-ktx:1.2.2
are released. Version 1.2.2 contains these commits.
رفع اشکال
- Fixed an issue in the
InvalidFragmentVersionForActivityResult
lint check that led to a false positive when using Fragment 1.3.1 or higher. ( I54da1 , b/182388985 ) -
ComponentActivity
now avoids aClassNotFoundException
when launching anIntent
from anActivityResultContract
that was previously held as an extra in anotherIntent
. ( Ieff05 , b/182906230 )
Dependency Updates
- Activity now depends on Lifecycle
2.3.1
.
نسخه 1.2.1
نسخه 1.2.1
10 مارس 2021
androidx.activity:activity:1.2.1
and androidx.activity:activity-ktx:1.2.1
are released. Version 1.2.1 contains these commits.
رفع اشکال
-
RequestMultiplePermissions
now always returns results for all requested permissions instead of only permissions that weren't previously granted. ( I50bc3 , b/180884668 ) -
ActivityResultRegistry
now ensures that in progresslaunch()
requests will return their results even if youunregister()
, thenregister()
again with the same key. ( I9ef34 , b/181267562 )
نسخه 1.2.0
نسخه 1.2.0
10 فوریه 2021
androidx.activity:activity:1.2.0
and androidx.activity:activity-ktx:1.2.0
are released. Version 1.2.0 contains these commits.
Major changes since 1.1.0
- Activity Result APIs :
ComponentActivity
now provides anActivityResultRegistry
that lets you handlestartActivityForResult()
+onActivityResult()
as well asrequestPermissions()
+onRequestPermissionsResult()
flows without overriding methods in your Activity or Fragment, brings increased type safety viaActivityResultContract
, and provides hooks for testing these flows. See the updated Getting a Result from an Activity .
ContextAware
:ComponentActivity
now implementsContextAware
, allowing you to add one or moreOnContextAvailableListener
instances which will receive a callback before the baseActivity.onCreate()
.- A suspending Kotlin extension
withContextAvailable()
allows you to run a non-suspending block when the Context becomes available and return a result. - This API is used by
FragmentActivity
in Fragment 1.3.0 to restore the state of theFragmentManager
. Any listeners added to subclasses ofFragmentActivity
will run after that listener. - This API is used by
AppCompatActivity
in AppCompat 1.3.0-alpha02 or higher. Any listeners added to subclasses ofAppCompatActivity
will run after that listener.
- A suspending Kotlin extension
ViewTree
Support :ComponentActivity
now supports theViewTreeLifecycleOwner.get(View)
,ViewTreeViewModelStoreOwner.get(View)
, andViewTreeSavedStateRegistryOwner
APIs added in Lifecycle2.3.0
and SavedState1.1.0
such that it will return the Activity as theLifecycleOwner
,ViewModelStoreOwner
, andSavedStateRegistryOwner
for any Views directly added to theComponentActivity
.
- reportFullyDrawn() backport - The
Activity
method ofreportFullyDrawn()
has been backported inComponentActivity
to work on all API levels, fixing a crash on API 19 and adding tracing for this method for all API levels.
Version 1.2.0-rc01
16 دسامبر 2020
androidx.activity:activity:1.2.0-rc01
and androidx.activity:activity-ktx:1.2.0-rc01
are released. Version 1.2.0-rc01 contains these commits.
رفع اشکال
- The
ActivityResultRegistry
now always restores the exact state that was saved. ( Idd56b ) - Add tracing to
ComponentActivity.reportFullyDrawn
( Ic7632 )
External Contribution
-
ComponentActivity
now overridesreportFullyDrawn()
, allowing it to be called on all API levels and fixing a crash when calling this method without the appropriate system permission on API 19 devices. Thanks Simon Schiller! ( b/163239764 , #103 )
Version 1.2.0-beta02
2 دسامبر 2020
androidx.activity:activity:1.2.0-beta02
and androidx.activity:activity-ktx:1.2.0-beta02
are released. Version 1.2.0-beta02 contains these commits.
رفع اشکال
- Fixed an issue where the Activity Result API would not wait for the Lifecycle to be
STARTED
before delivering results when registered with aLifecycle
. ( I109ea )
External Contribution
- Updated the documentation for
launch()
to explicitly call out that it can throw anActivityNotFoundException
. Thanks Michał Zieliński! ( aosp/1493580 )
Version 1.2.0-beta01
1 اکتبر 2020
androidx.activity:activity:1.2.0-beta01
and androidx.activity:activity-ktx:1.2.0-beta01
are released. Version 1.2.0-beta01 contains these commits.
رفع اشکال
The
ActivityResultRegistry
now randomly generates integers until it finds one that is unallocated to use as a request coderegister()
, thus preventing the possible integer overflow caused by incrementing request codes. ( b/168779518 )Lifecycle
observers are properly removed when callingunregister()
on anActivityResultLauncher
. ( b/165608393 )
تغییرات رفتار
- The
ActivityResultRegistry
now throws anIllegalStateException
when attempting to callregister()
with aLifecycleOwner
whoseLifecycle
has already reachedSTARTED
. ( b/165435866 )
اسناد به روز شد
-
ContextAware
documentation links toLifecycleOwner
to highlightLifecycle
callbacks as the appropriate place for creation and destruction events. ( aosp/1414152 )
Version 1.2.0-alpha08
19 آگوست 2020
androidx.activity:activity:1.2.0-alpha08
and androidx.activity:activity-ktx:1.2.0-alpha08
are released. Version 1.2.0-alpha08 contains these commits.
ویژگی های جدید
-
ComponentActivity
now implementsContextAware
, allowing you to add one or moreOnContextAvailableListener
instances which will receive a callback before the baseActivity.onCreate()
. ( b/161390636 )- A suspending Kotlin extension
withContextAvailable()
allows you to run a non-suspending block when the Context becomes available and return a result. ( I8290c ) - This API is used by
FragmentActivity
in Fragment 1.3.0-alpha08 to restore the state of theFragmentManager
. Any listeners added to subclasses ofFragmentActivity
will run after that listener. ( I513da ) - This API is used by
AppCompatActivity
in AppCompat 1.3.0-alpha02 . Any listeners added to subclasses ofAppCompatActivity
will run after that listener. ( I513da )
- A suspending Kotlin extension
رفع اشکال
- Fixed an issue with the
ActivityResultFragmentVersionDetector
Lint check that caused it to break when using Lint 27.1.0 or higher. ( b/162155191 )
Version 1.2.0-alpha07
July 22, 2020
androidx.activity:activity:1.2.0-alpha07
and androidx.activity:activity-ktx:1.2.0-alpha07
are released. Version 1.2.0-alpha07 contains these commits.
ویژگی های جدید
- Added a new
InvalidFragmentVersionForActivityResult
lint check that verifies that you are using Fragment1.3.0-alpha07
when using the Activity Result API , avoiding runtime crashes due to “invalid request code” issues and non-functioning permission requests caused by using older versions of Fragments. ( b/152554847 )
External Contribution
- Fixed an
ArrayIndexOutOfBoundsException
when parsing the results for theRequestPermission
Activity Result contract. ( I8f9e3 , b/161057605 )
Version 1.2.0-alpha06
10 ژوئن 2020
androidx.activity:activity:1.2.0-alpha06
and androidx.activity:activity-ktx:1.2.0-alpha06
are released. Version 1.2.0-alpha06 contains these commits.
ویژگی های جدید
- You can now destructure the
ActivityResult
class in kotlin to directly access therequestCode
andintent
. ( b/157212935 ) -
ActivityResultLauncher
now allows you to get theActivityResultContract
that was used to register the launcher. ( b/156875743 )
تغییرات API
- Breaking change : The
invoke()
method onActivityResultRegistry
has been renamed toonLaunch()
. ( b/157496491 ) - The
OpenMultipleDocuments
contract now returns an empty list instead ofnull
to the registered callback if no result is returned. ( b/157348014 )
Version 1.2.0-alpha05
20 مه 2020
androidx.activity:activity:1.2.0-alpha05
and androidx.activity:activity-ktx:1.2.0-alpha05
are released. Version 1.2.0-alpha05 contains these commits.
ویژگی های جدید
- Added support for
ViewTreeViewModelStoreOwner
from Lifecycle2.3.0-alpha03
, andViewTreeSavedStateRegistryOwner
from SavedState1.1.0-alpha01
when using aView
within aComponentActivity
. ( aosp/1297993 , aosp/1300264 )
تغییرات API
- The
TakePicture
contract now returns aboolean
indicating success rather than a thumbnailBitmap
as this was very rarely supported by camera apps when writing the image to the providedUri
. ( b/154302879 ) - The
invoke()
extensions onActivityResultLauncher
have been removed in favor of explicitly usinglaunch()
to better indicate that these are asynchronous operations. Kotlin extensions forlaunch
have been added to theandroidx.activity.result
package forActivityResultLauncher<Void>
andActivityResultLauncher<Unit>
that remove the need to pass innull
orUnit
, respectively, mirroring that behavior from the previouslyinvoke()
extensions. ( aosp/1304674 , aosp/1304675 ) - The
IntentSenderRequest.Builder
methods forsetFlagsMask()
andsetFlagsValues()
has been combined into a singlesetFlags()
method. ( aosp/1302111 )
رفع اشکال
- When registering an
ActivityResultCallback
with aLifecycleOwner
, fixed an issue where the callback would be triggered before the state reachesSTARTED
. ( aosp/1309744 )
تغییرات رفتار
- The
ActivityResultRegistry
now generates request codes starting at0xFFFF
rather than at0
, preventing overlap when usingstartActivityForResult()
orrequestPermissions()
in an activity. ( aosp/1302324 )
Version 1.2.0-alpha04
29 آوریل 2020
androidx.activity:activity:1.2.0-alpha04
and androidx.activity:activity-ktx:1.2.0-alpha04
are released. Version 1.2.0-alpha04 contains these commits.
ویژگی های جدید
- Added a contract that can call startIntentSenderForResult to the ActivityResult APIs. ( b/153007517 )
تغییرات API
- The
prepareCall()
method has been renamed toregisterForActivityResult()
, both onComponentActivity
here and in Fragment1.3.0-alpha04
. ( aosp/1278717 ) - The
GetContents
,OpenDocuments
, andRequestPermissions
contracts have been renamed toGetMultipleContents
,OpenMultipleDocuments
, andRequestMultiplePermissions
, respectively. ( aosp/1280161 ) -
ComponentActivity
now implements theActivityResultRegisteryOwner
interface. ( aosp/1290888 ) - - The
startActivityForResult()
/onActivityResult()
andonRequestPermissionsResult()
APIs onComponentActivity
have been deprecated. Please use the Activity Result APIs . ( b/154751887 )
رفع اشکال
- When using the
GetMultipleContents
andOpenMultipleDocuments
contracts and selecting a single item, it is now correctly returned to your callback. ( b/152941153 )
Version 1.2.0-alpha03
1 آوریل 2020
androidx.activity:activity:1.2.0-alpha03
and androidx.activity:activity-ktx:1.2.0-alpha03
are released. Version 1.2.0-alpha03 contains these commits.
ویژگی های جدید
- Added the
TakeVideo
,PickContact
,GetContent
,GetContents
,OpenDocument
,OpenDocuments
,OpenDocumentTree
, andCreateDocument
contracts to the set of pre-built contracts provided byActivityResultContracts
. ( aosp/1262482 , aosp/1266916 , aosp/1268960 ) - The Activity Result APIs now support launching an activity for result with an optional
ActivityOptionsCompat
. ( b/151860054 )
تغییرات API
- The
TakePicture
contract now takes aUri
input for where the image should be stored. The previous contract that does not take any input has been renamed toTakePicturePreview
. ( aosp/1262482 ) - The
registerActivityResultCallback()
method onActivityResultRegistry
has been renamed toregister()
. ( aosp/1267621 ) - The
dispose()
method onActivityResultLauncher
has been renamed tounregister()
and theunregisterResultCallback()
onActivityResultRegistry
has been removed. ( aosp/1267621 ) - The
createIntent()
method ofActivityResultContact
now takes aContext
in addition to the input to make it possible to create explicit Intents. ( aosp/1238800 ) - An
ActivityResultContract
can now overridegetSynchronousResult()
to deliver a result without callingstartActivityForResult
. This is used by theRequestPermission
andRequestPermissions
contracts to correctly deliver a 'granted' status if the requested permissions are already granted. ( b/151110799 ) - The previously available
Dial
contract has been removed as thatIntent
is not meant to be used withstartActivityForResult()
. ( aosp/1266916 ) - Many of the Activity Result APIs not meant to be extended are now
final
. This includesgetActivityResultRegistry()
, theprepareCall()
methods, all methods ofActivityResultRegistry
exceptinvoke()
, and a number of the default contracts that do not support optional extras. ( b/152439361 )
رفع اشکال
- Fixed a
NullPointerException
inActivityResultRegistry
when attempting to deliver results to a callback that has not yet been re-registered after a configuration change;ActivityResultRegistry
now holds onto these pending results and delivers them when the callback is re-registered. ( b/152137004 )
Version 1.2.0-alpha02
18 مارس 2020
androidx.activity:activity:1.2.0-alpha02
and androidx.activity:activity-ktx:1.2.0-alpha02
are released. Version 1.2.0-alpha02 contains these commits.
ویژگی های جدید
- ActivityResultRegistry :
ComponentActivity
now provides anActivityResultRegistry
that lets you handle thestartActivityForResult()
+onActivityResult()
as well asrequestPermissions()
+onRequestPermissionsResult()
flows without overriding methods in your Activity or Fragment, brings increased type safety viaActivityResultContract
, and provides hooks for testing these flows. See the updated Getting a Result from an Activity . ( b/125158199 )
Version 1.2.0-alpha01
4 مارس 2020
androidx.activity:activity:1.2.0-alpha01
and androidx.activity:activity-ktx:1.2.0-alpha01
are released. Version 1.2.0-alpha01 contains these commits.
ویژگی های جدید
- Added support for the
ViewTreeLifecycleOwner.get(View)
API added in Lifecycle2.3.0-alpha01
such that it will return the Activity as theLifecycleOwner
for any Views directly added to the Activity. ( aosp/1182955 )
رفع اشکال
- Fixed a regression introduced in Activity
1.1.0
when running on older versions of the platform whereonBackPressed()
would cause anIllegalStateException
due to a bug in theandroid.app.FragmentManager
. ( b/146290338 )
نسخه 1.1.0
نسخه 1.1.0
22 ژانویه 2020
androidx.activity:activity:1.1.0
is released. Version 1.1.0 contains these commits .
Important changes since 1.0.0
- Lifecycle ViewModel SavedState Integration :
SavedStateViewModelFactory
is now the default factory used when usingby viewModels()
, theViewModelProvider
constructor, orViewModelProviders.of()
with aComponentActivity
or its subclasses.
Version 1.1.0-rc03
4 دسامبر 2019
androidx.activity:activity:1.1.0-rc03
and androidx.activity:activity-ktx:1.1.0-rc03
are released. Version 1.1.0-rc03 contains these commits .
Dependency changes
- Activity now depends on Lifecycle
2.2.0-rc03
and Lifecycle ViewModel SavedState1.0.0-rc03
.
Version 1.1.0-rc02
7 نوامبر 2019
androidx.activity:activity:1.1.0-rc02
and androidx.activity:activity-ktx:1.1.0-rc02
are released. Version 1.1.0-rc02 contains these commits .
Dependency changes
- Activity now depends on lifecycle
2.2.0-rc02
.
Version 1.1.0-rc01
23 اکتبر 2019
androidx.activity:activity:1.1.0-rc01
and androidx.activity:activity-ktx:1.1.0-rc01
are released with no changes from 1.1.0-beta01
. Version 1.1.0-rc01 contains these commits .
Version 1.1.0-beta01
9 اکتبر 2019
androidx.activity:activity:1.1.0-beta01
and androidx.activity:activity-ktx:1.1.0-beta01
are released. Version 1.1.0-beta01 contains these commits .
Dependency changes
- Activity now depends on SavedState 1.0.0 stable.
Version 1.1.0-alpha03
5 سپتامبر 2019
androidx.activity:activity:1.1.0-alpha03
and androidx.activity:activity-ktx:1.1.0-alpha03
are released. The commits included in this version can be found here .
ویژگی های جدید
- Activity now depends on Core 1.1.0 stable.
رفع اشکال
- Activity now depends on Lifecycle
2.2.0-alpha04
.
Version 1.1.0-alpha02
7 آگوست 2019
androidx.activity:activity:1.1.0-alpha02
and androidx.activity:activity-ktx:1.1.0-alpha02
are released. The commits included in this version can be found here .
ویژگی های جدید
-
SavedStateViewModelFactory
is now the default factory used when usingby viewModels()
, theViewModelProvider
constructor, orViewModelProviders.of()
with aComponentActivity
( b/135716331 )
Version 1.1.0-alpha01
2 جولای 2019
androidx.activity:activity:1.1.0-alpha01
and androidx.activity:activity-ktx:1.1.0-alpha01
are released. The commits included in this version can be found here .
ویژگی های جدید
-
activity
now depends on Lifecycle2.2.0-alpha02
. ( aosp/1007817 ) -
activity-ktx
added a dependency onlifecycle-runtime-ktx
; you no longer need to explicitly add it to your dependencies when usingactivity-ktx
or libraries that depend onactivity-ktx
(such asfragment-ktx
). ( aosp/987162 )
Version 1.0.0
Version 1.0.0
5 سپتامبر 2019
androidx.activity:activity:1.0.0
and androidx.activity:activity-ktx:1.0.0
are released. The commits included in this version can be found here .
Major Features of 1.0.0
- ComponentActivity :
ComponentActivity
serves as the new base class forFragmentActivity
in Fragment1.1.0
and, by extension,AppCompatActivity
in AppCompat1.1.0
. - activity-ktx : The
activity-ktx
module includes aby viewModels
Kotlin property extension for accessing ViewModels. This module is automatically included when you includefragment-ktx
from Fragment1.1.0
. - OnBackPressedDispatcher : As a composable alternative to overriding
onBackPressed()
, you can now register aOnBackPressedCallback
from anyLifecycleOwner
(such as a fragment) to intercept system back button events. A lambda with receiver versionaddCallback
has been added toactivity-ktx
. See Provide custom back navigation documentation for more details. - onRetainCustomNonConfigurationInstance deprecation : the
onRetainCustomNonConfigurationInstance()
and the relatedgetLastCustomNonConfigurationInstance()
APIs have been deprecated. It is strongly recommended to use ViewModels to store non-configuration state as they offer a composable solution suitable for anyViewModelStoreOwner
that makes the ownership of the retained objects clear and provides anonCleared()
callback for cleaning up resources when the activity is finally destroyed.
Version 1.0.0-rc01
2 جولای 2019
androidx.activity:activity:1.0.0-rc01
and androidx.activity:activity-ktx:1.0.0-rc01
are released with no changes from 1.0.0-beta01
. The commits included in this version can be found here .
Version 1.0.0-beta01
5 ژوئن 2019
androidx.activity::activity:1.0.0-beta01
and androidx.activity:activity-ktx:1.0.0-beta01
are released with no changes from 1.0.0-alpha08
. The commits included in this version can be found here .
Version 1.0.0-alpha08
7 مه 2019
androidx.activity:activity:1.0.0-alpha08
and androidx.activity:activity-ktx:1.0.0-alpha08
are released. The commits included in this version can be found here .
API changes
- Breaking change: The previously deprecated
addOnBackPressedCallback
andremoveOnBackPressedCallback
methods onComponentActivity
have been removed. aosp/953857 - The
setEnabled()
andisEnabled()
methods ofOnBackPressedCallback
are now final. b/131416833 - The
remove()
method ofOnBackPressedCallback
is now final. aosp/952720 -
OnBackPressedDispatcher
now has public constructors, allowing you to construct your own instances for testing, etc. aosp/953431 -
onBackPressed()
forComponentActivity
is now explicitly marked as@MainThread
aosp/952721
رفع اشکال
- Fixed a
ConcurrentModificationException
when callingremove()
from within thehandleOnBackPressed()
method of aOnBackPressedCalback
that was added with aLifecycleOwner
. b/131765095
Version 1.0.0-alpha07
April 25th, 2019
androidx.activity:activity:1.0.0-alpha07
and androidx.activity:activity-ktx:1.0.0-alpha07
are released. The commits included in this version can be found here .
API changes
This release makes significant changes to the handling of the onBackPressed()
. See the updated custom back documentation for more details.
- The methods for
OnBackPressedCallback
andOnBackPressedDispatcher
have been marked as@MainThread
. ( aosp/943813 ) - The
handleOnBackPressed()
method no longer returns aboolean
. Instead,OnBackPressedCallback
is now an abstract class that can be enabled or disabled - only when the newisEnabled()
method returns true willhandleOnBackPressed()
be called, in which you must handle the back button. ( aosp/944518 ) - The
addCallback
methods ofOnBackPressedDispatcher
no longer return aCancellable
instance.OnBackPressedCallback
now contain aremove()
method that fulfill this functionality, allowing you to callremove()
duringhandleOnBackPressed()
. ( aosp/944519 ) ( aosp/946316 ) -
activity-ktx
now contains a receiver scoped callback foraddCallback
that accepts a lamdba that implementshandleOnBackPressed()
and has access toisEnabled
andremove()
( aosp/944520 )
Version 1.0.0-alpha06
3 آوریل 2019
androidx.activity:activity:1.0.0-alpha06
and androidx.activity:activity-ktx:1.0.0-alpha06
are released. The commits included in this version can be found here .
API changes
- ComponentActivity now contain a second constructor that takes a
@LayoutRes int
, which replaces the previous behavior of annotating your AppCompatActivity class with@ContentView
. This approach works in both app and library modules. ( b/128352521 ) - The
OnBackPressedCallback
related APIs on ComponentActivity have been deprecated in favor of the newOnBackPressedDispatcher
, retrievable viagetOnBackPressedDispatcher()
. ( aosp/922523 ) - Methods to add a new
OnBackPressedCallback
to theOnBackPressedDispatcher
now return aCancellable
object, allowing removal of the callback without requiring an explicit reference to theOnBackPressedDispatcher
. ( aosp/922523 ) - Adding a
OnBackPressedCallback
with an associatedLifecycleOwner
now results in adding and removing theOnBackPressedCallback
as the Lifecycle is started and stopped, respectively. ( aosp/922523 )
Version 1.0.0-alpha05
13 مارس 2019
androidx.activity:activity:1.0.0-alpha05
and androidx.activity:activity-ktx:1.0.0-alpha05
are released. The full list of commits included in this release can be found here .
ویژگی های جدید
-
@ContentView
annotation lookups are now cached ( b/123709449 )
Version 1.0.0-alpha04
30 ژانویه 2019
androidx.activity:activity 1.0.0-alpha04
and androidx.activity:activity-ktx 1.0.0-alpha04
are released.
ویژگی های جدید
- Added support for the
@ContentView
class annotation that allows you to indicate which layout XML file should be inflated as an alternative to usingsetContentView()
. ( aosp/837619 )
API changes
- Added a note that
getViewModelStore()
should not be overridden and will be made final in a future release. Please file a feature request if you are currently overriding this method. ( aosp/837619 )
رفع اشکال
- The
activity
module now depends on version 2.1.0-alpha02 of ViewModel to match theactivity-ktx
module's dependency.
Version 1.0.0-alpha03
17 دسامبر 2018
androidx.activity 1.0.0-alpha03
is released.
ویژگی های جدید
- ComponentActivity now implements
BundleSavedStateRegistryOwner
and depends on the newly released SavedState library [ aosp/815133 ] - ComponentActivity now works around an Android framework bug that would cause InputMethodManager to leak the last focused view [ b/37122102 ]
Version 1.0.0-alpha02
3 دسامبر 2018
API changes
- Added a note that
getLifecycle()
should not be overridden and will be madefinal
in a future release. Please file a feature request if you are currently overriding this method. ( aosp/815834 )
Version 1.0.0-alpha01
5 نوامبر 2018
androidx.activity 1.0.0-alpha01
introduces ComponentActivity
, a new base class of the existing FragmentActivity
and AppCompatActivity
.
ویژگی های جدید
- You can now register an
OnBackPressedCallback
viaaddOnBackPressedCallback
to receiveonBackPressed()
callbacks without needing to override the method in your activity. - Added a new
by viewModels()
Kotlin property delegate for retrievingViewModel
s from aComponentActivity
. - Pending input events (such as clicks) are now canceled in
onStop()
.
API changes
- The implementation of
LifecycleOwner
andViewModelStoreOwner
have been moved fromFragmentActivity
toComponentActivity
. -
onRetainCustomNonConfigurationInstance
has been deprecated. Use aViewModel
for storing objects that need to survive configuration changes.
فعالیت
آخرین به روز رسانی | انتشار پایدار | کاندید را آزاد کنید | نسخه بتا | Alpha Release |
---|---|---|---|---|
9 آوریل 2025 | 1.10.1 | - | 1.11.0-beta01 | - |
اعلام وابستگی ها
To add a dependency on Activity, you must add the Google Maven repository to your project. Read Google's Maven repository for more information.
Add the dependencies for the artifacts you need in the build.gradle
file for your app or module:
شیار
dependencies { def activity_version = "1.10.1" // Java language implementation implementation "androidx.activity:activity:$activity_version" // Kotlin implementation "androidx.activity:activity-ktx:$activity_version" }
کاتلین
dependencies { val activity_version = "1.10.1" // Java language implementation implementation("androidx.activity:activity:$activity_version") // Kotlin implementation("androidx.activity:activity-ktx:$activity_version") }
For more information about dependencies, see Add build dependencies .
بازخورد
Your feedback helps make Jetpack better. Let us know if you discover new issues or have ideas for improving this library. Please take a look at the existing issues in this library before you create a new one. You can add your vote to an existing issue by clicking the star button.
See the Issue Tracker documentation for more information.
نسخه 1.11
Version 1.11.0-beta01
9 آوریل 2025
androidx.activity:activity:1.11.0-beta01
, androidx.activity:activity-compose:1.11.0-beta01
, and androidx.activity:activity-ktx:1.11.0-beta01
are released. Version 1.11.0-beta01 contains these commits .
Version 1.11.0-alpha02
26 مارس 2025
androidx.activity:activity:1.11.0-alpha02
, androidx.activity:activity-compose:1.11.0-alpha02
, and androidx.activity:activity-ktx:1.11.0-alpha02
are released. Version 1.11.0-alpha02 contains these commits .
تغییرات API
- Integrated the new
EDGE_NONE
andframeTimeMillis
from Android 16 Beta03 into theBackEventCompat
provided byOnBackPressedCallback
'shandleOnBackStarted
andhandleOnBackProgressed
functions.
Dependency Updates
- Activity is now compiled with API 36. ( I510e8 , b/301910674 )
Version 1.11.0-alpha01
12 مارس 2025
androidx.activity:activity:1.11.0-alpha01
, androidx.activity:activity-compose:1.11.0-alpha01
, and androidx.activity:activity-ktx:1.11.0-alpha01
are released. Version 1.11.0-alpha01 contains these commits .
ویژگی های جدید
- Added
MediaCapabilities
API toPickVisualMediaRequest
to let applications specify its media capabilities, such as supported HDR Types. ( Ic3ee7 )
نسخه 1.10
نسخه 1.10.1
26 فوریه 2025
androidx.activity:activity:1.10.1
, androidx.activity:activity-compose:1.10.1
, and androidx.activity:activity-ktx:1.10.1
are released. Version 1.10.1 contains these commits .
رفع اشکال
-
ViewTree
OnBackPressedDispatcherOwners
andFullyDrawnReporterOwners
can now be resolved through disjoint parents of a view, such as aViewOverlay
. See the release notes of core or the documentation inViewTree.setViewTreeDisjointParent
for more information on disjoint view parents. ( Ie7750 )
نسخه 1.10.0
15 ژانویه 2025
androidx.activity:activity:1.10.0
, androidx.activity:activity-compose:1.10.0
, and androidx.activity:activity-ktx:1.10.0
are released. Version 1.10.0 contains these commits .
Important changes since 1.9.0
-
PhotoPicker
now allows picking images in order and choosing which tab (either albums or images) should be initially visible. - The
PickVisualMedia
andPickMultipleVisualMedia
Activity Result contracts that trigger the Photo Picker no longer directly delegates to Google Play services if the system Photo picker is not available, but uses the publicACTION_SYSTEM_FALLBACK_PICK_IMAGES
action and related extras to provide a consistent Photo Picker experience to OEMs and system apps as a fallback. - New
LocalActivity
composition local that provides theActivity
for the current scope, removing the need for developers to get anActivity
from theLocalContext
.
Version 1.10.0-rc01
11 دسامبر 2024
androidx.activity:activity:1.10.0-rc01
, androidx.activity:activity-compose:1.10.0-rc01
, and androidx.activity:activity-ktx:1.10.0-rc01
are released. Version 1.10.0-rc01 contains these commits .
رفع اشکال
- Fixed an issue where changing the enabled state while the
PredictiveBackHandler
is currently active would short circuit the callback immediately. It will now finish the current callback regardless of the enabled status changes. ( Ib8719 )
Version 1.10.0-beta01
13 نوامبر 2024
androidx.activity:activity:1.10.0-beta01
, androidx.activity:activity-compose:1.10.0-beta01
, and androidx.activity:activity-ktx:1.10.0-beta01
are released with no changes since the last alpha. Version 1.10.0-beta01 contains these commits .
Version 1.10.0-alpha03
30 اکتبر 2024
androidx.activity:activity:1.10.0-alpha03
, androidx.activity:activity-compose:1.10.0-alpha03
, and androidx.activity:activity-ktx:1.10.0-alpha03
are released. Version 1.10.0-alpha03 contains these commits .
تغییرات API
- Added a new
LocalActivity
composition local that provides theActivity
for the current scope, removing the need for developers to get anActivity
from theLocalContext
. It also comes with a new lint rule that checks when theLocalContext
is incorrectly being cast to anActivity
. ( I7746a , b/283009666 )
رفع اشکال
- From Activity
1.9.3
:PredictiveBackHandler
will no longer fire it's callback after the handler has been disabled. This will fix an issue where theNavHost
from Navigation Compose would throw anIndexOutOfBoundsException
. ( I3f75e , b/365027664 , b/340202286 )
Dependency Update
- Activity Compose now depends on Compose Runtime 1.7.0 ( I7746a , b/283009666 )
Version 1.10.0-alpha02
4 سپتامبر 2024
androidx.activity:activity:1.10.0-alpha02
, androidx.activity:activity-compose:1.10.0-alpha02
, and androidx.activity:activity-ktx:1.10.0-alpha02
are released. Version 1.10.0-alpha02 contains these commits .
تغییرات رفتار
- The
PickVisualMedia
andPickMultipleVisualMedia
Activity Result contracts that trigger the Photo Picker no longer directly delegates to Google Play services if the system Photo picker is not available, but uses the publicACTION_SYSTEM_FALLBACK_PICK_IMAGES
action and related extras to provide a consistent Photo Picker experience to OEMs and system apps as a fallback. This should have no effect on the user experience for devices that have a recent version of Google Play services. ( I3513d )
رفع اشکال
- Removed manual outlining of access to new platform APIs since this happens automatically via API modeling when using R8 with AGP 7.3 or later (eg R8 version 3.3) and for all builds when using AGP 8.1 or later (eg D8 version 8.1). Clients who are not using AGP are advised to update to D8 version 8.1 or later. برای جزئیات بیشتر به این مقاله مراجعه کنید. ( I9496c , b/345472586 )
- From Activity
1.9.2
: Fixed an issue where the Activity ComposePredictiveBackHandler
API would continue to handle the system back gesture on the frame it was disabled, which could result in libraries like Navigation Compose to handle back even with an empty back stack, resulting in it throwing anIndexOutOfBoundsException
. ( Ie3301 , b/340202286 ) - From Activity
1.9.1
: Fixed an issue withPredictiveBackHandler
where after doing system back, attempting to doonBackPressed
from theOnBackPressedDispatcher
would fail. ( I5f1f8 )
Version 1.10.0-alpha01
26 ژوئن 2024
androidx.activity:activity:1.10.0-alpha01
, androidx.activity:activity-compose:1.10.0-alpha01
, and androidx.activity:activity-ktx:1.10.0-alpha01
are released. This version is developed in an internal branch.
ویژگی های جدید
- Added support for new
PhotoPicker
features introduced in Android V including being able to pick images in order and choose which tab (either albums or images) should be initially visible.
نسخه 1.9
نسخه 1.9.3
16 اکتبر 2024
androidx.activity:activity:1.9.3
, androidx.activity:activity-compose:1.9.3
, and androidx.activity:activity-ktx:1.9.3
are released. Version 1.9.3 contains these commits .
رفع اشکال
-
PredictiveBackHandler
will no longer fire it's callback after the handler has been disabled. This will fix an issue where theNavHost
from Navigation Compose would throw anIndexOutOfBoundsException
. ( I3f75e , b/340202286 )
Version 1.9.2
4 سپتامبر 2024
androidx.activity:activity:1.9.2
, androidx.activity:activity-compose:1.9.2
, and androidx.activity:activity-ktx:1.9.2
are released. Version 1.9.2 contains these lthcocommits .
رفع اشکال
- Fixed an issue where the Activity Compose
PredictiveBackHandler
API would continue to handle the system back gesture on the frame it was disabled, which could result in libraries like Navigation Compose to handle back even with an empty back stack, resulting in it throwing anIndexOutOfBoundsException
. ( Ie3301 , b/340202286 )
Version 1.9.1
24 جولای 2024
androidx.activity:activity:1.9.1
, androidx.activity:activity-compose:1.9.1
, and androidx.activity:activity-ktx:1.9.1
are released. Version 1.9.1 contains these commits .
رفع اشکال
- Fixed an issue with
PredictiveBackHandler
where after doing system back, attempting to doonBackPressed
from theOnBackPressedDispatcher
would fail. ( I5f1f8 )
نسخه 1.9.0
17 آوریل 2024
androidx.activity:activity:1.9.0
, androidx.activity:activity-compose:1.9.0
, and androidx.activity:activity-ktx:1.9.0
are released. Version 1.9.0 contains these commits .
Important changes since 1.8.0
-
ComponentActivity
now implementsOnUserLeaveHintProvider
to allow components to callbacks foronUserLeaveHint
events. - The
OnBackPressedCallback
,BackHandler
, andPredictiveBackHandler
APIs now warn when callingonBackPressedDispatcher.onBackPressed()
when handling back as that will always break the Predictive Back Animation . See the best practices guide for more details. - The remainder of the Activity APIs have been rewritten in Kotlin and all extensions previously available in
activity-ktx
have been moved toactivity
.activity-ktx
is now completely empty.- As part of the conversion of
ActivityResultLauncher
to Kotlin, thegetContract
method is now an abstract Kotlin property. This is a binary compatible change, but source breaking if your implementation ofActivityResultLauncher
is written in Kotlin.
- As part of the conversion of
Version 1.9.0-rc01
3 آوریل 2024
androidx.activity:activity:1.9.0-rc01
, androidx.activity:activity-compose:1.9.0-rc01
, and androidx.activity:activity-ktx:1.9.0-rc01
are released. Version 1.9.0-rc01 contains these commits .
به روز رسانی وابستگی
- Activity now depends on Profile Installer 1.3.1 .
Version 1.9.0-beta01
20 مارس 2024
androidx.activity:activity:1.9.0-beta01
, androidx.activity:activity-compose:1.9.0-beta01
, and androidx.activity:activity-ktx:1.9.0-beta01
are released. Version 1.9.0-beta01 contains these commits .
رفع اشکال
- Fixed an Activity startup performance regression introduced in Activity
1.9.0-alpha02
caused by calling theOnBackPressedDispatcher
as part of the creation of the Activity. ( Ie75e3 )
Version 1.9.0-alpha03
7 فوریه 2024
androidx.activity:activity:1.9.0-alpha03
, androidx.activity:activity-compose:1.9.0-alpha03
, and androidx.activity:activity-ktx:1.9.0-alpha03
are released. Version 1.9.0-alpha03 contains these commits.
Lint Warning
- The
OnBackPressedCallback
,BackHandler
, andPredictiveBackHandler
APIs now warn when callingonBackPressedDispatcher.onBackPressed()
when handling back as that will always break the Predictive Back Animation . See the best practices guide for more details. ( 1e4222 , 2c950d , b/287505200 )
رفع اشکال
- If a back event is sent from the system started during an already running Predictive Back Gesture, the currently running Predictive Back Gesture is canceled and the new back event takes over to begin a new Predictive Back Gesture. ( I3482e )
- Fixed a crash when accessing the
onBackPressedDispatcher
from aComponentActivity
for the first time from a background thread. It is now safe to access theonBackPressedDispatcher
on any thread. ( I79955 )
Version 1.9.0-alpha02
24 ژانویه 2024
androidx.activity:activity:1.9.0-alpha02
, androidx.activity:activity-compose:1.9.0-alpha02
, and androidx.activity:activity-ktx:1.9.0-alpha02
are released. Version 1.9.0-alpha02 contains these commits.
Kotlin Conversions
-
ActivityResultRegistry
has been rewritten in Kotlin. This ensures that the nullability of the generics on the contract passed toregister
will correctly be passed through to theActivityResultLauncher
returned to you. ( I121f0 ) -
ActivityResult
has been rewritten in Kotlin. TheActivityResult
Kotlin extensions that support destructuring into theresultCode
anddata
fields have been moved fromactivity-ktx
toactivity
. ( I0565a ) - The Kotlin extensions of
by viewModels()
forComponentActivity
andtrackPipAnimationHintView
have been moved fromactivity-ktx
toactivity
. Theactivity-ktx
artifact is now completely empty. ( I0a444 )
رفع اشکال
- The
enableEdgeToEdge
API now draws around any display cutouts. ( a3644b , b/311173461 ) - From Activity
1.8.2
: Fixed the extra passed to the Photo Picker Activity Contract'sACTION_SYSTEM_FALLBACK_PICK_IMAGES
to correctly pass it theEXTRA_SYSTEM_FALLBACK_PICK_IMAGES_MAX
key, rather than using the extra with the key"com.google.android.gms.provider.extra.PICK_IMAGES_MAX"
. It is strongly recommended if you are an OEM who implements a system fallback Photo Picker to support both extras to ensure the widest compatibility. ( I96a00 )
Version 1.9.0-alpha01
29 نوامبر 2023
androidx.activity:activity:1.9.0-alpha01
, androidx.activity:activity-compose:1.9.0-alpha01
, and androidx.activity:activity-ktx:1.9.0-alpha01
are released. Version 1.9.0-alpha01 contains these commits.
ویژگی های جدید
-
ComponentActivity
now implementsOnUserLeaveHintProvider
to allow components to callbacks foronUserLeaveHint
events. ( I54892 )
تغییرات API
-
ComponentActivity
has been rewritten in Kotlin. ( I14f31 ) -
ActivityResultCaller
has been rewritten in Kotlin. ( Ib02e4 ) -
ActivityResultLauncher
has been rewritten in Kotlin. As part of that conversion, thegetContract
method is now an abstract Kotlin property. This is a binary compatible change, but source breaking if your implementation ofActivityResultLauncher
is written in Kotlin. ( Id4615 ) -
PickVisualMediaRequest
now has the same minimum API level of 19 as thePickVisualMedia
Activity Result contract. ( Id6e21 )
Dependency Update
- Activity now depends on Core
1.13.0-alpha01
. ( I14f31 )
نسخه 1.8
نسخه 1.8.2
13 دسامبر 2023
androidx.activity:activity:1.8.2
, androidx.activity:activity-compose:1.8.2
, and androidx.activity:activity-ktx:1.8.2
are released. Version 1.8.2 contains these commits.
رفع اشکال
- Fixed the extra passed to the Photo Picker Activity Contract's
ACTION_SYSTEM_FALLBACK_PICK_IMAGES
to correctly pass it theEXTRA_SYSTEM_FALLBACK_PICK_IMAGES_MAX
key, rather than using the extra with the key"com.google.android.gms.provider.extra.PICK_IMAGES_MAX"
. It is strongly recommended if you are an OEM who implements a system fallback Photo Picker to support both extras to ensure the widest compatibility. ( I96a00 )
نسخه 1.8.1
15 نوامبر 2023
androidx.activity:activity:1.8.1
, androidx.activity:activity-compose:1.8.1
, and androidx.activity:activity-ktx:1.8.1
are released. Version 1.8.1 contains these commits.
رفع اشکال
-
OnBackPressedDispatcher
now continues to dispatch to the correctOnBackPressedCallback
even after a newOnBackPressedCallback
is added while the back gesture is being handled. ( Id0ff6 )
نسخه 1.8.0
4 اکتبر 2023
androidx.activity:activity:1.8.0
, androidx.activity:activity-compose:1.8.0
, and androidx.activity:activity-ktx:1.8.0
are released. Version 1.8.0 contains these commits.
Important changes since 1.7.0
- Predictive Back - The
OnBackPressedCallback
now offers new Predictive Back callbacks for handling the back gesture starting, progress throughout the gesture, and the back gesture being canceled in addition to the previoushandleOnBackPressed()
callback for when the back gesture is committed. This also comes with thePredictiveBackHandler
Composable to handle predictive back gesture events in Activity Compose. It provides a Flow of BackEventCompat objects that must be collected in the suspending lamba you provide:
PredictiveBackHandler { progress: Flow<BackEventCompat> ->
// code for gesture back started
try {
progress.collect { backEvent ->
// code for progress
}
// code for completion
} catch (e: CancellationException) {
// code for cancellation
}
}
ComponentActivity.onBackPressed()
has now been deprecated in favor of the APIs for handling back. Developers should now utilize the OnBackPressedDispatcher
, rather than overriding this method.
- EdgeToEdge -
ComponentActivity.enableEdgeToEdge()
has been added to easily set up the edge-to-edge display in a backward-compatible manner.
Version 1.8.0-rc01
20 سپتامبر 2023
androidx.activity:activity:1.8.0-rc01
, androidx.activity:activity-compose:1.8.0-rc01
, and androidx.activity:activity-ktx:1.8.0-rc01
are released. Version 1.8.0-rc01 contains these commits.
Version 1.8.0-beta01
6 سپتامبر 2023
androidx.activity:activity:1.8.0-beta01
, androidx.activity:activity-compose:1.8.0-beta01
, and androidx.activity:activity-ktx:1.8.0-beta01
are released. Version 1.8.0-beta01 contains these commits.
Documentation Improvement
- Improved the documentation of
BackEventCompat
. ( aosp/2722254 )
Version 1.8.0-alpha07
23 آگوست 2023
androidx.activity:activity:1.8.0-alpha07
, androidx.activity:activity-compose:1.8.0-alpha07
, and androidx.activity:activity-ktx:1.8.0-alpha07
are released. Version 1.8.0-alpha07 contains these commits.
ویژگی های جدید
Activity Compose has added a new
PredictiveBackHandler
Composable to handle predictive back gesture events. It provides aFlow
ofBackEventCompat
objects that must be collected in the suspending lamba you provide:PredictiveBackHandler { progress: Flow<BackEventCompat> -> // code for gesture back started try { progress.collect { backEvent -> // code for progress } // code for completion } catch (e: CancellationException) { // code for cancellation } }
It also comes with a compile time warning via lint rule to ensure the
Flow
callscollect()
. ( Id2773 , b/294884345 )The
onBackPressedDispatcher
inComponentActivity
is now initialized lazily so that it is only created when required. ( I0bf8e )
رفع اشکال
-
ComponentActivity
will no longer show a NPE on Android 13 when it gets anonBackPressed()
callback and the Activity has already beenDESTROYED
. ( Idb055 , b/291869278 ) - Removed usages of experimental
isAtLeastU()
API ( Ie9117 , b/289269026 )
Version 1.8.0-alpha06
21 ژوئن 2023
androidx.activity:activity:1.8.0-alpha06
, androidx.activity:activity-compose:1.8.0-alpha06
, and androidx.activity:activity-ktx:1.8.0-alpha06
are released. Version 1.8.0-alpha06 contains these commits.
ویژگی های جدید
- The
OnBackPressedDispatcher
now correctly cancels any callbacks that are removed during a Predictive Back Gesture. ( I3f90f )
تغییرات API
- When passing
SystemBarStyle.auto
to theenableEdgeToEdge
API, you can now override thedetectDarkMode
lambda parameter to provide custom logic for detecting night mode. ( aosp/2546393 , b/278263793 )
Version 1.8.0-alpha05
7 ژوئن 2023
androidx.activity:activity:1.8.0-alpha05
, androidx.activity:activity-compose:1.8.0-alpha05
, and androidx.activity:activity-ktx:1.8.0-alpha05
are released. This version is developed in an internal branch.
تغییرات API
- Activity now provides a
BackEventCompat
class that serves as a backward compatible version ofBackEvent
that is decoupled from the frameworkBackEvent
class. - Breaking change: The
handleOnBackStarted
andhandleOnBackProgressed
methods ofOnBackPressedCallback
now receive anandroidx.activity.BackEventCompat
instance rather than a frameworkandroid.window.BackEvent
class. The equivalent@VisibleForTesting
APIs onOnBackPressedDispatcher
have also been updated. - The constructor for
OnBackPressedDispatcher
now takes an optionalConsumer<Boolean>
instance that allows the owners of the dispatcher to receive a callback whenever the number of enabled callbacks changes from zero to non-zero or vice versa.
رفع اشکال
- From Activity
1.7.2
: FixReportDrawn
crashing when navigating away from a screen beforereport
is called. ( Ic46f1 , b/260506820 )
Version 1.8.0-alpha04
10 مه 2023
androidx.activity:activity:1.8.0-alpha04
, androidx.activity:activity-compose:1.8.0-alpha04
, and androidx.activity:activity-ktx:1.8.0-alpha04
are released. This was released from an internal branch.
رفع اشکال
- From Activity 1.7.1 : - The
ReportFullyDrawExecuter
no longer leaks when usingComponentActivity
withActivityScenario
. ( Id2ff2 , b/277434271 )
Version 1.8.0-alpha03
12 آوریل 2023
androidx.activity:activity:1.8.0-alpha03
, androidx.activity:activity-compose:1.8.0-alpha03
, and androidx.activity:activity-ktx:1.8.0-alpha03
are released. This was released from an internal branch.
ویژگی های جدید
- Added
ComponentActivity.setUpEdgeToEdge()
to easily set up the edge-to-edge display in a backward-compatible manner.
تغییرات API
-
ComponentActivity.onBackPressed()
has now been deprecated in favor of the APIs for handling back. Developers should now utilize theOnBackPressedDispatcher
, rather than overriding this method. ( Ibce2f , b/271596918 ) -
ComponentDialog
andComponentActivity
now contain public APIinitViewTreeOwners()
to be used to initialize all view tree owners before setting the content view. ( Ibdce0 , b/261314581 )
رفع اشکال
- Fixed an issue where Fragments were incorrectly invalidating MenuHosts and causing other menus in the Activity to have unexpected behavior. ( I9404e , b/244336571 )
سایر تغییرات
- The
ActivityResultRegister
now uses KotlinRandom
instead of Java. ( I4d98f , b/272096025 )
Version 1.8.0-alpha02
8 مارس 2023
androidx.activity:activity:1.8.0-alpha02
, androidx.activity:activity-compose:1.8.0-alpha02
, and androidx.activity:activity-ktx:1.8.0-alpha02
are released. Developed from an internal branch.
به روز رسانی وابستگی
- From Activity
1.7.0-rc01
: Activity now depends onLifecycle 2.6.0
.
Version 1.8.0-alpha01
8 فوریه 2023
androidx.activity:activity:1.8.0-alpha01
, androidx.activity:activity-compose:1.8.0-alpha01
, and androidx.activity:activity-ktx:1.8.0-alpha01
are released. This was built from an internal branch.
ویژگی های جدید
- The
OnBackPressedCallback
class now contains new Predictive Back progress callbacks for handling the back gesture starting, progress throughout the gesture, and the back gesture being canceled in addition to the previoushandleOnBackPressed()
callback for when the back gesture is committed.
نسخه 1.7
نسخه 1.7.2
24 مه 2023
androidx.activity:activity:1.7.2
, androidx.activity:activity-compose:1.7.2
, and androidx.activity:activity-ktx:1.7.2
are released. Version 1.7.2 contains these commits.
رفع اشکال
- Fix
ReportDrawn
crashing when navigating away from a screen beforereport
is called. ( Ic46f1 , b/260506820 )
نسخه 1.7.1
19 آوریل 2023
androidx.activity:activity:1.7.1
, androidx.activity:activity-compose:1.7.1
, and androidx.activity:activity-ktx:1.7.1
are released. Version 1.7.1 contains these commits.
رفع اشکال
- The
ReportFullyDrawExecuter
no longer leaks when usingComponentActivity
withActivityScenario
. ( Id2ff2 , b/277434271 )
نسخه 1.7.0
22 مارس 2023
androidx.activity:activity:1.7.0
, androidx.activity:activity-compose:1.7.0
, and androidx.activity:activity-ktx:1.7.0
are released. Version 1.7.0 contains these commits.
Important changes since 1.6.0
- The Photo Picker activity contracts in
PickVisualMedia
andPickMultipleVisualMedia
have been updated to contain an additional fallback for whenMediaStore.ACTION_PICK_IMAGES
is unavailable that allows OEMs and system apps, such as Google Play services, to provide a consistent Photo Picker experience on a wider range of Android devices and API levels by implementing the fallback action . The Photo Picker will use this fallback if it is available before falling back to usingIntent.ACTION_OPEN_DOCUMENT
, which remains to support all API 19 and higher devices. -
ComponentDialog
now implementsSavedStateRegistryOwner
and has access to its ownSavedStateRegistry
and sets theSavedStateRegistryOwner
for itsViewTree
. It is now possible to use Jetpack Compose within aComponentDialog
as it meets both theLifecycleOwner
andSavedStateRegistryOwner
attached to the Window via theViewTree
APIs requirements. -
IntentSenderRequest.Builder.setFlags()
now allows you to set multiple flags fromIntent
, rather than only a single flag.
Kotlin Conversion
A number of Activity classes have been converted to Kotlin. All converted classes still retain their binary compatibility with previous versions. The following classes have source incompatible changes for classes written in Kotlin: ActivityResultRegistryOwner
, OnBackPressedDispatcherOwner
.
The table below provides the source conversions for the new version of Activity:
Activity 1.5 | Activity 1.6 |
---|---|
override fun getActivityResultRegistry() = activityResultRegistry | override val activityResultRegistry = activityResultRegistry |
override fun getOnBackPressedDispatcher() = onBackPressedDispatcher | override val onBackPressedDispatcher = onBackPressedDispatcher |
These classes were also converted to Kotlin, but remain source compatible: ContextAware
, ContextAwareHelper
, OnContextAvailableListener
, IntentSenderRequest
, and OnBackPressedDispatcher
FullyDrawnReporter APIs
ComponentActivity
now provides a FullyDrawnReporter
instance that allows multiple components to report when they are ready for interaction. ComponentActivity
will wait for all components to complete before calling reportFullyDrawn()
on your behalf. These APIs take care of the timing requirements for you and do not need to be called as part of an onDraw
call.
These APIs are encouraged to enable:
- Signaling the Android Runtime when startup completes, to ensure all of the code run during a multi-frame startup sequence is included and prioritized for background compilation.
- Signaling Macrobenchmark and Play Vitals when your application should be considered fully drawn for startup metrics, so you can track performance.
Three Activity Compose APIs have been added to make it more convenient to use the FullyDrawnReporter
from individual composables:
-
ReportDrawn
indicates that your composable is immediately ready for interaction. -
ReportDrawnWhen
takes a predicate (ie,list.count > 0
) to indicate when your composable is ready for interaction. -
ReportDrawnAfter
takes a suspending method that, when it completes, indicates that you are ready for interaction.
Dependency Updates
- Activity now depends on Lifecycle
2.6.1
. ( 8fc31d ) - Activity now depends on ProfileInstaller
1.3.0
. ( 83d3b1 )
Version 1.7.0-rc01
8 مارس 2023
androidx.activity:activity:1.7.0-rc01
, androidx.activity:activity-compose:1.7.0-rc01
, and androidx.activity:activity-ktx:1.7.0-rc01
are released. Version 1.7.0-rc01 contains these commits.
به روز رسانی وابستگی
- Activity now depends on
Lifecycle 2.6.0
.
Version 1.7.0-beta02
22 فوریه 2023
androidx.activity:activity:1.7.0-beta02
, androidx.activity:activity-compose:1.7.0-beta02
, and androidx.activity:activity-ktx:1.7.0-beta02
are released. Version 1.7.0-beta02 contains these commits.
تغییرات API
- The action and extra used by the
PickVisualMedia
andPickMultipleVisualMedia
contracts as a fallback for whenMediaStore.ACTION_PICK_IMAGES
is unavailable are now public constants that provide API stability to OEMs and system apps that want to provide a consistent Photo Picker experience. The implementation of this fallback is still limited to only system apps. ( Icd320 )
Version 1.7.0-beta01
8 فوریه 2023
androidx.activity:activity:1.7.0-beta01
, androidx.activity:activity-compose:1.7.0-beta01
, and androidx.activity:activity-ktx:1.7.0-beta01
are released. Version 1.7.0-beta01 contains these commits.
ویژگی های جدید
-
IntentSenderRequest.Builder.setFlags()
now allows you to set multiple flags fromIntent
, rather than only a single flag. ( Iac04c )
رفع اشکال
- The fallback for
PickVisualMedia
for when the framework Photo Picker is unavailable now correctly limits the handling to apps installed in the device's system image. ( If8ae6 )
Kotlin Conversions
-
ActivityResultRegistryOwner
is now written in Kotlin. This is a source incompatible change for those classes written in Kotlin - you must now override theactivityResultRegistry
property rather than implementing the previousgetActivityResultRegistry()
function. ( I0b00e ) -
OnBackPressedDispatcherOwner
is now written in Kotlin. This is a source incompatible change for those classes written in Kotlin - you must now override theonBackPressedDispatcher
property rather than implementing the previousgetOnBackPressedDispatcher
function. ( Ia277d ) -
ContextAware
,ContextAwareHelper
,OnContextAvailableListener
,IntentSenderRequest
andOnBackPressedDispatcher
are now written in Kotlin. ( I1a73e , Iada92 , aosp/2410754 , I18ac7 , b/257291701 )
Version 1.7.0-alpha04
25 ژانویه 2023
androidx.activity:activity:1.7.0-alpha04
, androidx.activity:activity-compose:1.7.0-alpha04
, and androidx.activity:activity-ktx:1.7.0-alpha04
are released. Version 1.7.0-alpha04 contains these commits.
ویژگی های جدید
- The
PickVisualMedia
andPickMultipleVisualMedia
Activity Result contracts will now use a Google Play services provided Photo Picker where available in cases where the Android system provided Photo Picker (eg,MediaStore.ACTION_PICK_IMAGES
) is not available. TheisPhotoPickerAvailable()
API that only detects the Android system provided Photo Picker has been deprecated. It is recommended to use the newisPhotoPickerAvailable(Context)
API, which will return if either Photo Picker is available. ( I55be6 )
Version 1.7.0-alpha03
11 ژانویه 2023
androidx.activity:activity:1.7.0-alpha03
, androidx.activity:activity-compose:1.7.0-alpha03
, and androidx.activity:activity-ktx:1.7.0-alpha03
are released. Version 1.7.0-alpha03 contains these commits.
ویژگی های جدید
-
ComponentDialog
now implementsSavedStateRegistryOwner
and has access to its ownSavedStateRegistry
and sets theSavedStateRegistryOwner
for its ViewTree. It is now possible to use Jetpack Compose within aComponentDialog
as it meets both theLifecycleOwner
andSavedStateRegistryOwner
attached to the Window via the ViewTree APIs requirements. ( Idca17 , I73468 b/261162296 )
تغییرات API
- Added a
ReportDrawn
composable that immediately marks the activity as ready to callreportFullyDrawn
. ( Ic5b14 , b/259687964 )
Kotlin Conversions
- The
ActvitiyResultCallback
andOnBackPressedCallback
classes have both been converted to Kotlin while maintaining source and binary compatibility. ( Ifc5e5 , Ide1b0 , b/257291701 )
Version 1.7.0-alpha02
24 اکتبر 2022
androidx.activity:activity:1.7.0-alpha02
, androidx.activity:activity-compose:1.7.0-alpha02
, and androidx.activity:activity-ktx:1.7.0-alpha02
are released. Version 1.7.0-alpha02 contains these commits.
رفع اشکال
- From Activity
1.6.1
: Fixed an issue with thePickMultipleVisualMedia
Activity Result contract not launching on Android R devices when using the default value formaxItems
. ( Ie2776 , b/249182130 )
Version 1.7.0-alpha01
5 اکتبر 2022
androidx.activity:activity:1.7.0-alpha01
, androidx.activity:activity-compose:1.7.0-alpha01
, and androidx.activity:activity-ktx:1.7.0-alpha01
are released. Version 1.7.0-alpha01 contains these commits.
FullyDrawnReporter APIs
ComponentActivity
now provides a FullyDrawnReporter
instance that allows multiple components to report when they are ready for interaction. ComponentActivity
will wait for all components to complete before calling reportFullyDrawn()
on your behalf. These APIs take care of the timing requirements for you and do not need to be called as part of an onDraw
call.
These APIs are encouraged to enable:
- Signaling the Android Runtime when startup completes, to ensure all of the code run during a multi-frame startup sequence is included and prioritized for background compilation.
- Signaling Macrobenchmark and Play Vitals when your application should be considered fully drawn for startup metrics, so you can track performance.
Two Activity Compose APIs have been added to make it more convenient to use the FullyDrawnReporter
from individual composables:
-
ReportDrawnWhen
takes a predicate (ie,list.count > 0
) to indicate when your composable is ready for interaction. -
ReportDrawnAfter
takes a suspending method that, when it completes, indicates that you are ready for interaction.
نسخه 1.6.1
نسخه 1.6.1
24 اکتبر 2022
androidx.activity:activity:1.6.1
, androidx.activity:activity-compose:1.6.1
, and androidx.activity:activity-ktx:1.6.1
are released. Version 1.6.1 contains these commits.
رفع اشکال
- Fixed an issue with the
PickMultipleVisualMedia
Activity Result contract not launching on Android R devices when using the default value formaxItems
. ( Ie2776 , b/249182130 )
نسخه 1.6.0
نسخه 1.6.0
21 سپتامبر 2022
androidx.activity:activity:1.6.0
, androidx.activity:activity-compose:1.6.0
, and androidx.activity:activity-ktx:1.6.0
are released. Version 1.6.0 contains these commits.
Important changes since 1.5.0
- Added
ActivityResultContracts.PickVisualMedia
andActivityResultContracts.PickMultipleVisualMedia
for providing a backward compatible contract that usesMediaStore.ACTION_PICK_IMAGES
when the Photo Picker is available andIntent.ACTION_OPEN_DOCUMENT
when it is not available. - Integrated the
OnBackInvokedCallback
in Android 13 into theOnBackPressedDispatchers
provided byComponentActivity
andComponentDialog
. This ensures that all APIs built onOnBackPressedDispatcher
work when enabling a predictive back gesture .
Version 1.6.0-rc02
7 سپتامبر 2022
androidx.activity:activity:1.6.0-rc02
, androidx.activity:activity-compose:1.6.0-rc02
, and androidx.activity:activity-ktx:1.6.0-rc02
are released. Version 1.6.0-rc02 contains these commits.
رفع اشکال
-
OnBackPressedDispatcher
now registers theOnBackInvokedCallback
with thePRIORITY_DEFAULT
instead ofPRIORITY_OVERLAY
. ( I3901f ) - Classes that extend
ComponentActivity
will now always have both of theironMultiWindowModeChanged()
callbacks dispatched. ( Ic4d85 ) - The
ActivityResultRegistry
will no longer return a result to theActivityResultCallback
when thelaunch
call throws anyException
and the callback was registered without aLifecycleOwner
. ( Ia7ff7 , b/238350794 ) -
ComponentActivity
will now properly dispatch menu calls without the need to call the super function in your activity. ( Ie33c5 , b/238057118 )
Dependency Update
- The
Activity
library now depends on Lifecycle2.5.1
. ( If6697 )
Version 1.6.0-rc01
24 آگوست 2022
androidx.activity:activity:1.6.0-rc01
, androidx.activity:activity-compose:1.6.0-rc01
, and androidx.activity:activity-ktx:1.6.0-rc01
are released. Version 1.6.0-rc01 contains these commits.
رفع اشکال
- Initializing an
OnBackPressedDispatcher
will no longer causeClassVerificationError
s when using SDK versions prior to 33. ( Ic32e1 ) - Classes that override
ComponentActivity
'sonPictureInPictureModeChanged()
callback will now always have their callbacks dispatched. ( Ib7fdb )
Version 1.6.0-beta01
August 10, 2022
androidx.activity:activity:1.6.0-beta01
, androidx.activity:activity-compose:1.6.0-beta01
, and androidx.activity:activity-ktx:1.6.0-beta01
are released. Version 1.6.0-beta01 contains these commits.
تغییرات API
- Marked the deprecated
startActivityForResult
andstartIntentSenderForResult
methods onComponentActivity
with@NonNull
because passingnull
has always resulted in a crash. ( Id2a25 , b/231476082 )
رفع اشکال
- From Activity
1.5.1
: TheActivityResultRegistry
will no longer return a result to theActivityResultCallback
when thelaunch
call throws anyException
and the callback was registered without aLifecycleOwner
. ( Ia7ff7 , b/238350794 ) - From Activity
1.5.1
:ComponentActivity
will now properly dispatch menu calls toonPrepareOptionMenu()
,onCreateOptionsMenu()
andonOptionsItemSelected()
overrides without the need to call the super function. ( Ie33c5 , b/238057118 )
Dependency Update
- From Activity
1.5.1
: TheActivity
library now depends on theLifecycle
version2.5.1
. ( If6697 )
Version 1.6.0-alpha05
15 ژوئن 2022
androidx.activity:activity:1.6.0-alpha05
, androidx.activity:activity-compose:1.6.0-alpha05
, and androidx.activity:activity-ktx:1.6.0-alpha05
are released. Version 1.6.0-alpha05 was developed in a private pre-release branch and has no public commits.
تغییرات API
-
minCompileSdk
is now 33 to align with Tiramisu Beta 3 SDK
رفع اشکال
- Fixed crash on older devices when doing SDK extension check for the
PickVisualMedia
ActivityResultContract
so that it should now work withACTION_OPEN_DOCUMENT
on devices running Android 10 and lower.
Version 1.6.0-alpha04
18 مه 2022
androidx.activity:activity:1.6.0-alpha04
and androidx.activity:activity-ktx:1.6.0-alpha04
are released.
رفع اشکال
- Fixed an error in
PickVisualMediaRequest
where attempting to create a request, either via the Builder or the top level Kotlin function, would result in a stack overflow. - Integrated the
OnBackInvokedCallback
in Android 13 Dev Beta 2 into theOnBackPressedDispatcher
provided byComponentDialog
. This ensures that all APIs built onOnBackPressedDispatcher
work when enabling a predictive back gesture .
Version 1.6.0-alpha03
27 آوریل 2022
androidx.activity:activity:1.6.0-alpha03
, androidx.activity:activity-compose:1.6.0-alpha03
, and androidx.activity:activity-ktx:1.6.0-alpha03
are released.
- Note: This version will only compile against the Android 13 Developer Beta 1 SDK.
ویژگی های جدید
- Added
ActivityResultContracts.PickVisualMedia
andActivityResultContracts.PickMultipleVisualMedia
for providing a backward compatible contract that usesMediaStore.ACTION_PICK_IMAGES
when the Photo Picker is available andIntent.ACTION_OPEN_DOCUMENT
when it is not available. - Integrated the
OnBackInvokedCallback
in Android 13 Dev Beta 1 into theOnBackPressedDispatcher
provided byComponentActivity
. This ensures that all APIs built onOnBackPressedDispatcher
work when enabling a predictive back gesture .
Version 1.6.0-alpha01
23 مارس 2022
androidx.activity:activity:1.6.0-alpha01
, androidx.activity:activity-compose:1.6.0-alpha01
, and androidx.activity:activity-ktx:1.6.0-alpha01
are released.
- Note: This version will only compile against the Android 13 Developer Preview 2 SDK.
ویژگی های جدید
- Integrated changes in Android 13 Dev Preview 2 into
ComponentActivity
.
نسخه 1.5.1
نسخه 1.5.1
27 جولای 2022
androidx.activity:activity:1.5.1
, androidx.activity:activity-compose:1.5.1
, and androidx.activity:activity-ktx:1.5.1
are released. Version 1.5.1 contains these commits.
رفع اشکال
The
ActivityResultRegistry
will no longer return a result to theActivityResultCallback
when thelaunch()
call throws anyException
and the callback was registered without aLifecycleOwner
. ( Ia7ff7 , b/238350794 )ComponentActivity
will now properly dispatch menu calls toonPrepareOptionMenu()
,onCreateOptionsMenu()
andonOptionsItemSelected()
overrides without the need to call the super function. ( Ie33c5 , b/238057118 )
به روز رسانی وابستگی
- The
Activity
library now depends on the Lifecycle2.5.1
. ( If6697 )
نسخه 1.5.0
نسخه 1.5.0
29 ژوئن 2022
androidx.activity:activity:1.5.0
, androidx.activity:activity-compose:1.5.0
, and androidx.activity:activity-ktx:1.5.0
are released. Version 1.5.0 contains these commits.
Important changes since 1.4.0
- ComponentDialog -
ComponentDialog
is a subclass ofDialog
that includes anOnBackPressedDispatcher
that will be called when the system back button is pressed and the dialog is visible. Importantly, this subclass also sets theViewTreeOnBackPressedDispatcherOwner
, allowing views a generic way to retrieve the correct dispatcher whether it exists in aComponentActivity
or aComponentDialog
. - Callback Interfaces -
ComponentActivity
now implements a set of modular callback interfaces that can be used instead of theActivity
callbacks. These interfaces include the following:OnNewIntentProvider
,OnConfigurationChangedProvider
,OnTrimMemoryProvider
,OnPictureInPictureModeChangedProvider
,OnMultiWindowModeChangedProvider
- CreationExtras Integration -
ComponentActivity
now has the ability to provide a statelessViewModelProvider.Factory
via Lifecycle2.5.0
'sCreationExtras
.
تغییرات دیگر
- The no parameter constructor for
ActivityResultContracts.CreateDocument
has been deprecated and replaced with a new constructor that takes a concrete mime type (eg, "image/png") as is required byIntent.ACTION_CREATE_DOCUMENT
.
Version 1.5.0-rc01
11 مه 2022
androidx.activity:activity:1.5.0-rc01
, androidx.activity:activity-compose:1.5.0-rc01
, and androidx.activity:activity-ktx:1.5.0-rc01
are released with no changes from 1.5.0-beta01. Version 1.5.0-rc01 contains these commits.
Version 1.5.0-beta01
20 آوریل 2022
androidx.activity:activity:1.5.0-beta01
, androidx.activity:activity-compose:1.5.0-beta01
, and androidx.activity:activity-ktx:1.5.0-beta01
are released. Version 1.5.0-beta01 contains these commits.
Dependency updates
- Activity now depends on Lifecycle
2.4.0-beta01
.
Version 1.5.0-alpha05
6 آوریل 2022
androidx.activity:activity:1.5.0-alpha05
, androidx.activity:activity-compose:1.5.0-alpha05
, and androidx.activity:activity-ktx:1.5.0-alpha05
are released. Version 1.5.0-alpha05 contains these commits.
رفع اشکال
-
ComponentActivity
'sonPanelClosed()
now calls the superonPanelClosed()
as well, fixing an issue where theonContextMenuClosed
method would not be called. ( Ib6f77 )
Version 1.5.0-alpha04
23 مارس 2022
androidx.activity:activity:1.5.0-alpha04
, androidx.activity:activity-compose:1.5.0-alpha04
, and androidx.activity:activity-ktx:1.5.0-alpha04
are released. Version 1.5.0-alpha04 contains these commits.
رفع اشکال
-
SavedStateViewFactory
now supports usingCreationExtras
even when it was initialized with aSavedStateRegistryOwner
. If extras are provided, the initialized arguments are ignored. ( I6c43b , b/224844583 )
Version 1.5.0-alpha03
23 فوریه 2022
androidx.activity:activity:1.5.0-alpha03
, androidx.activity:activity-compose:1.5.0-alpha03
, and androidx.activity:activity-ktx:1.5.0-alpha03
are released. Version 1.5.0-alpha03 contains these commits.
تغییرات API
- You can now pass
CreationExtras
to the activityby viewModels()
function ( I6a3e6 , b/217600303 )
Version 1.5.0-alpha02
9 فوریه 2022
androidx.activity:activity:1.5.0-alpha02
, androidx.activity:activity-compose:1.5.0-alpha02
, and androidx.activity:activity-ktx:1.5.0-alpha02
are released. Version 1.5.0-alpha02 contains these commits.
ویژگی های جدید
-
ComponentActivity
now implements theOnPictureInPictureModeChangedProvider
interface to allow any component to receive picture-in-picture mode change events. ( I9f567 ) -
ComponentActivity
now implements theOnMultiWindowModeChangedProvider
interface to allow any component to receive multi-window mode change events. ( I62d91 )
Version 1.5.0-alpha01
26 ژانویه 2022
androidx.activity:activity:1.5.0-alpha01
, androidx.activity:activity-compose:1.5.0-alpha01
, and androidx.activity:activity-ktx:1.5.0-alpha01
are released. Version 1.5.0-alpha01 contains these commits.
ویژگی های جدید
-
ComponentActivity
now integrates with ViewModel CreationExtras, introduced as part of Lifecycle2.5.0-alpha01
. ( Ie7e00 , b/207012584 ) - Added
ComponentDialog
, a subclass ofDialog
that includes anOnBackPressedDispatcher
that will be called when the system back button is pressed when the dialog is visible. Importantly, this subclass also sets theViewTreeOnBackPressedDispatcherOwner
, allowing views a generic way to retrieve the correct dispatcher whether it exists in aComponentActivity
or aComponentDialog
. ( I8a1bc ) -
ComponentActivity
now implements the newOnNewIntentProvider
interface to allow any component to receive these events. ( If1f8b ) -
ComponentActivity
now implements the newOnConfigurationChangedProvider
interface to allow any component to receive these events. ( If623b ) -
ComponentActivity
now implements the newOnTrimMemoryProvider
interface to allow any component to receive these events. ( Ia9295 )
تغییرات API
- The no parameter constructor for
ActivityResultContracts.CreateDocument
has been deprecated and replaced with a new constructor that takes a concrete mime type (eg,"image/png"
) as is required byIntent.ACTION_CREATE_DOCUMENT
. ( I2bec6 ) - The
OnBackPressedDispatcherOwner
associated with a View can now be retrieved via theViewTreeOnBackPressedDispatcherOwner
, rather than relying on casting theContext
. ( I74685 )
رفع اشکال
- Fixed a crash when accessing a
ViewModel
for the very first time from aregisterForActivityResult()
callback or the callbacks to aLifecycleObserver
added as part ofinit
of aComponentActivity
. ( Ife83f )
نسخه 1.4.0
نسخه 1.4.0
27 اکتبر 2021
androidx.activity:activity:1.4.0
, androidx.activity:activity-compose:1.4.0
, and androidx.activity:activity-ktx:1.4.0
are released. Version 1.4.0 contains these commits.
Important changes since 1.3.0
- AndroidX
ComponentActivity
now implements theMenuHost
interface. This allows any component to add menu items to theActionBar
by adding aMenuProvider
instance to the activity. EachMenuProvider
can optionally be added with aLifecycle
that will automatically control the visibility of those menu items based on theLifecycle
state and handle the removal of theMenuProvider
when theLifecycle
is destroyed. - The
ActivityResultContract
class has been rewritten in Kotlin to ensure that developers writing custom contracts in Kotlin can define the correct nullability for their input and output classes. - The
ActivityResultContracts
class and its contracts have been rewritten in Kotlin to ensure the proper nullability.
Version 1.4.0-rc01
13 اکتبر 2021
androidx.activity:activity:1.4.0-rc01
, androidx.activity:activity-compose:1.4.0-rc01
, and androidx.activity:activity-ktx:1.4.0-rc01
are released. Version 1.4.0-rc01 contains these commits.
رفع اشکال
- The
ActivityResultRegistry
will no longer return a result to theActivityResultCallback
when thelaunch
call throws anyException
. ( If4f91 , b/200845664 )
Version 1.4.0-beta01
29 سپتامبر 2021
androidx.activity:activity:1.4.0-beta01
, androidx.activity:activity-compose:1.4.0-beta01
, and androidx.activity:activity-ktx:1.4.0-beta01
are released. Version 1.4.0-beta01 contains these commits.
تغییرات API
- Fixed the type for the
ActivityResultContracts.OpenMultipleDocuments
andActivityResultContracts.GetMultipleContents
that caused then to use an output type ofList<? extends Uri>
when using the code from the Java programming language. ( If71de ) - Public constants within the
ActivityResultContracts.StartActivityForResult
,ActivityResultContracts.StartIntentSenderForResult
, andActivityResultContracts.RequestMultiplePermissions
classes are now accessible when using Kotlin via their now publicCompanion
objects. ( aosp/1832555 )
به روز رسانی اسناد
- The deprecation message for APIs now handled by the Activity Result APIs , namely
startActivityForResult
,startIntentSenderForResult
,onActivityResult
,requestPermissions
, andonRequestPermissionsResult
, have all been expanded with more details. ( cce80f )
Version 1.4.0-alpha02
15 سپتامبر 2021
androidx.activity:activity:1.4.0-alpha02
, androidx.activity:activity-compose:1.4.0-alpha02
, and androidx.activity:activity-ktx:1.4.0-alpha02
are released. Version 1.4.0-alpha02 contains these commits.
ویژگی های جدید
- The
activity-compose
artifact now contains aLaunchDuringComposition
lint error that prevents you from calling thelaunch
method ofActivityResultLauncher
as part of composition as composition should be side-effect free. Use the APIs for handling side-effects . ( 7c2bbe , b/191347220 )
تغییرات API
- The
ActivityResultContract
class has been rewritten in Kotlin to ensure that developers writing custom contracts in Kotlin can define the correct nullability for their input and output classes. ( I8a8f5 ) - The
ActivityResultContracts
class and its contracts have been rewritten in Kotlin to ensure the proper nullability. ( I69802 )
Version 1.4.0-alpha01
1 سپتامبر 2021
androidx.activity:activity:1.4.0-alpha01
, androidx.activity:activity-compose:1.4.0-alpha01
, and androidx.activity:activity-ktx:1.4.0-alpha01
are released. Version 1.4.0-alpha01 contains these commits.
ویژگی های جدید
- AndroidX
ComponentActivity
now implements theMenuHost
interface.. This allows any component to add menu items to theActionBar
by adding aMenuProvider
instance to the activity. EachMenuProvider
can optionally be added with aLifecycle
that will automatically control the visibility of those menu items based on theLifecycle
state and handle the removal of theMenuProvider
when theLifecycle
is destroyed. ( I3b608 ):
/**
* Using the addMenuProvider() API directly in your Activity
**/
class ExampleActivity : ComponentActivity(R.layout.activity_example) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Add menu items without overriding methods in the Activity
addMenuProvider(object : MenuProvider {
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
// Add menu items here
menuInflater.inflate(R.menu.example_menu, menu)
}
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
// Handle the menu selection
return true
}
})
}
}
/**
* Using the addMenuProvider() API in a Fragment
**/
class ExampleFragment : Fragment(R.layout.fragment_example) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
// The usage of an interface lets you inject your own implementation
val menuHost: MenuHost = requireActivity()
// Add menu items without using the Fragment Menu APIs
// Note how we can tie the MenuProvider to the viewLifecycleOwner
// and an optional Lifecycle.State (here, RESUMED) to indicate when
// the menu should be visible
menuHost.addMenuProvider(object : MenuProvider {
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
// Add menu items here
menuInflater.inflate(R.menu.example_menu, menu)
}
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
// Handle the menu selection
return true
}
}, viewLifecycleOwner, Lifecycle.State.RESUMED)
}
تغییرات رفتار
- The
ActivityResultRegistry
will now throw anIllegalStateException
when attempting to calllaunch()
on anActivityResultLauncher
that has not be registered or that has been unregistered. ( Ida75d , b/192567522 )
External Contribution
نسخه 1.3.1
نسخه 1.3.1
4 آگوست 2021
androidx.activity:activity:1.3.1
, androidx.activity:activity-compose:1.3.1
, and androidx.activity:activity-ktx:1.3.1
are released. Version 1.3.1 contains these commits.
Dependency updates
- Activity now depends on Kotlin
1.5.21
. - Activity Compose now depends on Compose
1.0.1
.
Version 1.3.0
Version 1.3.0
28 ژوئیه 2021
androidx.activity:activity:1.3.0
, androidx.activity:activity-compose:1.3.0
, and androidx.activity:activity-ktx:1.3.0
are released. Version 1.3.0 contains these commits.
Important changes since 1.2.0
- Activity Compose artifact - The
activity-compose
artifact provides thesetContent
extension method for hosting your Jetpack Compose UI in an activity and Compose specific wrappers for interacting with theComponentActivity
APIs for handling the system back button and the Activity Result APIs. برای جزئیات بیشتر به مستندات مراجعه کنید. - CaptureVideo contract - The
CaptureVideo
ActivityResultContract
replaces the now deprecatedTakeVideo
contract and returns a boolean denoting success that works across many camera apps. - Picture-In-Picture Hint View Tracking - Users of
activity-ktx
can now use thetrackPipAnimationHintView
extension method onActivity
to automatically rebuild thePictureInPictureParams
with the new position of the view as it changes position relative to the window.
Version 1.3.0-rc02
14 جولای 2021
androidx.activity:activity:1.3.0-rc02
, androidx.activity:activity-compose:1.3.0-rc02
, and androidx.activity:activity-ktx:1.3.0-rc02
are released. Version 1.3.0-rc02 contains these commits.
رفع اشکال
- The
ActivityResultRegistry
callbacks are now properly saved and restored so callbacks are not duplicated in the savedState. ( I97816 , b/191893160 )
Version 1.3.0-rc01
1 ژوئیه 2021
androidx.activity:activity:1.3.0-rc01
, androidx.activity:activity-compose:1.3.0-rc01
, and androidx.activity:activity-ktx:1.3.0-rc01
are released with no changes from 1.3.0-beta02
. Version 1.3.0-rc01 contains these commits.
Version 1.3.0-beta02
16 ژوئن 2021
androidx.activity:activity:1.3.0-beta02
, androidx.activity:activity-compose:1.3.0-beta02
, and androidx.activity:activity-ktx:1.3.0-beta02
are released. Version 1.3.0-beta02 contains these commits.
Updated activity-compose
to depend on Compose 1.0.0-beta09
. androidx.compose.ui:ui-test-junit4
now has a compile time dependency on activity-compose
.
Version 1.3.0-beta01
2 ژوئن 2021
androidx.activity:activity:1.3.0-beta01
, androidx.activity:activity-compose:1.3.0-beta01
, and androidx.activity:activity-ktx:1.3.0-beta01
are released. Version 1.3.0-beta01 contains these commits.
تغییرات API
- The previously deprecated
@Composable registerForActivityResult()
method has been removed. Please userememberLauncherForActivityResult()
. ( Ic39d3 )
Version 1.3.0-alpha08
18 مه 2021
androidx.activity:activity:1.3.0-alpha08
, androidx.activity:activity-compose:1.3.0-alpha08
, and androidx.activity:activity-ktx:1.3.0-alpha08
are released. Version 1.3.0-alpha08 contains these commits.
ویژگی های جدید
- The new
CaptureVideo
ActivityResultContract
returns a boolean to yourActivityResultCallback
indicating if your video was successfully saved to the given URI. This replaces the now deprecatedTakeVideo
contract as camera apps very rarely supported returning a thumbnail bitmap, making the result unhelpful. ( Ie21f2 , b/185938070 ) - Added new API
Activity#setPipAnimationHintView
to update the PipParams' source rect hint whenever the view moves. ( I9063d )
تغییرات API
- The
rememberLauncherForActivityResult
function now returns a launcher that deprecates theunregister()
function - registration and unregistering the launcher is handled automatically byrememberLauncherForActivityResult
. ( I2443e )
Compose Compatibility
-
androidx.activity:activity-compose:1.3.0-alpha08
is only compatible with Compose version1.0.0-beta07
and above.
Version 1.3.0-alpha07
21 آوریل 2021
androidx.activity:activity:1.3.0-alpha07
, androidx.activity:activity-compose:1.3.0-alpha07
, and androidx.activity:activity-ktx:1.3.0-alpha07
are released. Version 1.3.0-alpha07 contains these commits.
رفع اشکال
-
rememberLauncherForActivityResult
now returns a stable reference to the sameActivityResultLauncher
instance even if the contract changes due to recompositions. ( Id2d6d ) - Using unstable versions of Fragments above
1.3.0
will no longer throw a false positive lint error telling you to use1.3.0
. ( aosp/1670206 , b/184847092 )
Version 1.3.0-alpha06
7 آوریل 2021
androidx.activity:activity:1.3.0-alpha06
, androidx.activity:activity-compose:1.3.0-alpha06
, and androidx.activity:activity-ktx:1.3.0-alpha06
are released. Version 1.3.0-alpha06 contains these commits.
تغییرات API
- The
registerForActivityResult()
API has been renamed torememberLauncherForActivityResult()
to better indicate that the returnedActivityResultLauncher
is a managed object that is remembered on your behalf. Attempting to callunregister
the returnedActivityResultLauncher
will now throw an error. ( I2bb6d ) -
LocalOnBackPressedDispatcherOwner.current
andLocalActivityResultRegistryOwner.current
now return a nullable value to better determine whether it is available in the current composition. APIs that requires those APIs, such asBackHandler
andrememberLauncherForActivityResult()
, respectively, will now throw a more descriptive error if the underlying owner is not found.NavHost
now works even when anOnBackPressedDispatcherOwner
is not found, such is the case when previewing theNavHost
. ( I7d8b4 )
رفع اشکال
- The
BackHandler
will now properly intercept back presses in the event that the Activity isSTOPPED
, thenSTARTED
again, and other callbacks were added with a LifecycleOwner. ( I71de6 , b/182284739 ) - Using the
launch()
method extension with a customActivityResultContract
that has aUnit
input will no longer cause aNullPointerException
( I76282 , b/183837954 )
Version 1.3.0-alpha05
24 مارس 2021
androidx.activity:activity:1.3.0-alpha05
, androidx.activity:activity-compose:1.3.0-alpha05
, and androidx.activity:activity-ktx:1.3.0-alpha05
are released. Version 1.3.0-alpha05 contains these commits.
رفع اشکال
- From Activity 1.2.2 : Fixed an issue in the
InvalidFragmentVersionForActivityResult
lint check that led to a false positive when using Fragment 1.3.1 or higher. ( I54da1 , b/182388985 ) - From Activity 1.2.2 :
ComponentActivity
now avoids aClassNotFoundException
when launching anIntent
from anActivityResultContract
that was previously held as an extra in anotherIntent
. ( Ieff05 , b/182906230 )
Dependency Updates
- From Activity 1.2.2 : Activity now depends on Lifecycle
2.3.1
.
Version 1.3.0-alpha04
10 مارس 2021
androidx.activity:activity:1.3.0-alpha04
, androidx.activity:activity-compose:1.3.0-alpha04
, and androidx.activity:activity-ktx:1.3.0-alpha04
are released. Version 1.3.0-alpha04 contains these commits.
رفع اشکال
- From Activity
1.2.1
:RequestMultiplePermissions
now always returns results for all requested permissions instead of only permissions that weren't previously granted. ( I50bc3 , b/180884668 ) - From Activity
1.2.1
:ActivityResultRegistry
now ensures that in progresslaunch()
requests will return their results even if youunregister()
, thenregister()
again with the same key. ( I9ef34 , b/181267562 ) - Activity Compose no longer adds test dependencies to the runtime classpath. ( Ifd8b3 )
- Fixed an issue with
BackHandler
where the previously setonBack
lambda was still being used after recomposition. ( 8eb5eb )
Version 1.3.0-alpha03
24 فوریه 2021
androidx.activity:activity:1.3.0-alpha03
, androidx.activity:activity-compose:1.3.0-alpha03
, and androidx.activity:activity-ktx:1.3.0-alpha03
are released. Version 1.3.0-alpha03 contains these commits.
ویژگی های جدید
- There is a now a Composable
registerForActivityResult
function for getting results from activities within composables. ( Ia7851 , b/172690553 )
تغییرات API
-
LocalOnBackPressedDispatcherOwner
now has aprovides
functions that can be used withCompositionLocalProvider
, replacing theasProvidableCompositionLocal()
API. ( I45d24 )
Version 1.3.0-alpha02
10 فوریه 2021
androidx.activity:activity:1.3.0-alpha02
, androidx.activity:activity-compose:1.3.0-alpha02
, and androidx.activity:activity-ktx:1.3.0-alpha02
are released. Version 1.3.0-alpha02 contains these commits.
رفع اشکال
- Fixed an issue in Activity Compose
1.3.0-alpha01
that causes aNoSuchMethodError: No static method setContent
exception when using Compose1.0.0-alpha12
. All Compose users should depend on1.3.0-alpha02
and above. ( b/179911234 )
تغییرات API
- The
BackHandler
API can be used to allow a Composable to intercept the system back button. ( I58ed5 , b/172154006 )
Version 1.3.0-alpha01
10 فوریه 2021
androidx.activity:activity:1.3.0-alpha01
, androidx.activity:activity-compose:1.3.0-alpha01
, and androidx.activity:activity-ktx:1.3.0-alpha01
are released. Version 1.3.0-alpha01 contains these commits.
ویژگی های جدید
- The new
activity-compose
artifact provides Jetpack Compose specific helpers forandroidx.activity
specific APIs.-
ComponentActivity.setContent
has moved fromandroidx.compose.ui.platform.setContent
toandroidx.activity.compose.setContent
. ( Icf416 )
-
مسائل شناخته شده
- Using Activity Compose
1.3.0-alpha01
and libraries that depend on it, such asandroidx.compose.ui:ui-test-junit4:1.0.0-alpha12
, will result in aNoSuchMethodError: No static method setContent
exception. ( b/179911234 )
نسخه 1.2.4
نسخه 1.2.4
21 جولای 2021
androidx.activity:activity:1.2.4
and androidx.activity:activity-ktx:1.2.4
are released. Version 1.2.4 contains these commits.
رفع اشکال
- From Activity
1.3.0-rc02
: The ActivityResultRegistry callbacks are now properly saved and restored so callbacks are not duplicated in the savedState. ( I97816 , b/191893160 )
Version 1.2.3
Version 1.2.3
5 مه 2021
androidx.activity:activity:1.2.3
and androidx.activity:activity-ktx:1.2.3
are released. Version 1.2.3 contains these commits.
رفع اشکال
- Using the
launch()
method extension with a customActivityResultContract
that has aUnit
input will no longer cause aNullPointerException
( I76282 , b/183837954 ) - Fixed a false positive lint error telling you to use Fragment
1.3.0
when using an snapshot, alpha, beta, or RC build of a newer version of Fragments. ( f4a57e , b/184847092 )
نسخه 1.2.2
نسخه 1.2.2
24 مارس 2021
androidx.activity:activity:1.2.2
and androidx.activity:activity-ktx:1.2.2
are released. Version 1.2.2 contains these commits.
رفع اشکال
- Fixed an issue in the
InvalidFragmentVersionForActivityResult
lint check that led to a false positive when using Fragment 1.3.1 or higher. ( I54da1 , b/182388985 ) -
ComponentActivity
now avoids aClassNotFoundException
when launching anIntent
from anActivityResultContract
that was previously held as an extra in anotherIntent
. ( Ieff05 , b/182906230 )
Dependency Updates
- Activity now depends on Lifecycle
2.3.1
.
نسخه 1.2.1
نسخه 1.2.1
10 مارس 2021
androidx.activity:activity:1.2.1
and androidx.activity:activity-ktx:1.2.1
are released. Version 1.2.1 contains these commits.
رفع اشکال
-
RequestMultiplePermissions
now always returns results for all requested permissions instead of only permissions that weren't previously granted. ( I50bc3 , b/180884668 ) -
ActivityResultRegistry
now ensures that in progresslaunch()
requests will return their results even if youunregister()
, thenregister()
again with the same key. ( I9ef34 , b/181267562 )
نسخه 1.2.0
نسخه 1.2.0
10 فوریه 2021
androidx.activity:activity:1.2.0
and androidx.activity:activity-ktx:1.2.0
are released. Version 1.2.0 contains these commits.
Major changes since 1.1.0
- Activity Result APIs :
ComponentActivity
now provides anActivityResultRegistry
that lets you handlestartActivityForResult()
+onActivityResult()
as well asrequestPermissions()
+onRequestPermissionsResult()
flows without overriding methods in your Activity or Fragment, brings increased type safety viaActivityResultContract
, and provides hooks for testing these flows. See the updated Getting a Result from an Activity .
ContextAware
:ComponentActivity
now implementsContextAware
, allowing you to add one or moreOnContextAvailableListener
instances which will receive a callback before the baseActivity.onCreate()
.- A suspending Kotlin extension
withContextAvailable()
allows you to run a non-suspending block when the Context becomes available and return a result. - This API is used by
FragmentActivity
in Fragment 1.3.0 to restore the state of theFragmentManager
. Any listeners added to subclasses ofFragmentActivity
will run after that listener. - This API is used by
AppCompatActivity
in AppCompat 1.3.0-alpha02 or higher. Any listeners added to subclasses ofAppCompatActivity
will run after that listener.
- A suspending Kotlin extension
ViewTree
Support :ComponentActivity
now supports theViewTreeLifecycleOwner.get(View)
,ViewTreeViewModelStoreOwner.get(View)
, andViewTreeSavedStateRegistryOwner
APIs added in Lifecycle2.3.0
and SavedState1.1.0
such that it will return the Activity as theLifecycleOwner
,ViewModelStoreOwner
, andSavedStateRegistryOwner
for any Views directly added to theComponentActivity
.
- reportFullyDrawn() backport - The
Activity
method ofreportFullyDrawn()
has been backported inComponentActivity
to work on all API levels, fixing a crash on API 19 and adding tracing for this method for all API levels.
Version 1.2.0-rc01
16 دسامبر 2020
androidx.activity:activity:1.2.0-rc01
and androidx.activity:activity-ktx:1.2.0-rc01
are released. Version 1.2.0-rc01 contains these commits.
رفع اشکال
- The
ActivityResultRegistry
now always restores the exact state that was saved. ( Idd56b ) - Add tracing to
ComponentActivity.reportFullyDrawn
( Ic7632 )
External Contribution
-
ComponentActivity
now overridesreportFullyDrawn()
, allowing it to be called on all API levels and fixing a crash when calling this method without the appropriate system permission on API 19 devices. Thanks Simon Schiller! ( b/163239764 , #103 )
Version 1.2.0-beta02
2 دسامبر 2020
androidx.activity:activity:1.2.0-beta02
and androidx.activity:activity-ktx:1.2.0-beta02
are released. Version 1.2.0-beta02 contains these commits.
رفع اشکال
- Fixed an issue where the Activity Result API would not wait for the Lifecycle to be
STARTED
before delivering results when registered with aLifecycle
. ( I109ea )
External Contribution
- Updated the documentation for
launch()
to explicitly call out that it can throw anActivityNotFoundException
. Thanks Michał Zieliński! ( aosp/1493580 )
Version 1.2.0-beta01
1 اکتبر 2020
androidx.activity:activity:1.2.0-beta01
and androidx.activity:activity-ktx:1.2.0-beta01
are released. Version 1.2.0-beta01 contains these commits.
رفع اشکال
The
ActivityResultRegistry
now randomly generates integers until it finds one that is unallocated to use as a request coderegister()
, thus preventing the possible integer overflow caused by incrementing request codes. ( b/168779518 )Lifecycle
observers are properly removed when callingunregister()
on anActivityResultLauncher
. ( b/165608393 )
تغییرات رفتار
- The
ActivityResultRegistry
now throws anIllegalStateException
when attempting to callregister()
with aLifecycleOwner
whoseLifecycle
has already reachedSTARTED
. ( b/165435866 )
اسناد به روز شد
-
ContextAware
documentation links toLifecycleOwner
to highlightLifecycle
callbacks as the appropriate place for creation and destruction events. ( aosp/1414152 )
Version 1.2.0-alpha08
19 آگوست 2020
androidx.activity:activity:1.2.0-alpha08
and androidx.activity:activity-ktx:1.2.0-alpha08
are released. Version 1.2.0-alpha08 contains these commits.
ویژگی های جدید
-
ComponentActivity
now implementsContextAware
, allowing you to add one or moreOnContextAvailableListener
instances which will receive a callback before the baseActivity.onCreate()
. ( b/161390636 )- A suspending Kotlin extension
withContextAvailable()
allows you to run a non-suspending block when the Context becomes available and return a result. ( I8290c ) - This API is used by
FragmentActivity
in Fragment 1.3.0-alpha08 to restore the state of theFragmentManager
. Any listeners added to subclasses ofFragmentActivity
will run after that listener. ( I513da ) - This API is used by
AppCompatActivity
in AppCompat 1.3.0-alpha02 . Any listeners added to subclasses ofAppCompatActivity
will run after that listener. ( I513da )
- A suspending Kotlin extension
رفع اشکال
- Fixed an issue with the
ActivityResultFragmentVersionDetector
Lint check that caused it to break when using Lint 27.1.0 or higher. ( b/162155191 )
Version 1.2.0-alpha07
July 22, 2020
androidx.activity:activity:1.2.0-alpha07
and androidx.activity:activity-ktx:1.2.0-alpha07
are released. Version 1.2.0-alpha07 contains these commits.
ویژگی های جدید
- Added a new
InvalidFragmentVersionForActivityResult
lint check that verifies that you are using Fragment1.3.0-alpha07
when using the Activity Result API , avoiding runtime crashes due to “invalid request code” issues and non-functioning permission requests caused by using older versions of Fragments. ( b/152554847 )
External Contribution
- Fixed an
ArrayIndexOutOfBoundsException
when parsing the results for theRequestPermission
Activity Result contract. ( I8f9e3 , b/161057605 )
Version 1.2.0-alpha06
10 ژوئن 2020
androidx.activity:activity:1.2.0-alpha06
and androidx.activity:activity-ktx:1.2.0-alpha06
are released. Version 1.2.0-alpha06 contains these commits.
ویژگی های جدید
- You can now destructure the
ActivityResult
class in kotlin to directly access therequestCode
andintent
. ( b/157212935 ) -
ActivityResultLauncher
now allows you to get theActivityResultContract
that was used to register the launcher. ( b/156875743 )
تغییرات API
- Breaking change : The
invoke()
method onActivityResultRegistry
has been renamed toonLaunch()
. ( b/157496491 ) - The
OpenMultipleDocuments
contract now returns an empty list instead ofnull
to the registered callback if no result is returned. ( b/157348014 )
Version 1.2.0-alpha05
20 مه 2020
androidx.activity:activity:1.2.0-alpha05
and androidx.activity:activity-ktx:1.2.0-alpha05
are released. Version 1.2.0-alpha05 contains these commits.
ویژگی های جدید
- Added support for
ViewTreeViewModelStoreOwner
from Lifecycle2.3.0-alpha03
, andViewTreeSavedStateRegistryOwner
from SavedState1.1.0-alpha01
when using aView
within aComponentActivity
. ( aosp/1297993 , aosp/1300264 )
تغییرات API
- The
TakePicture
contract now returns aboolean
indicating success rather than a thumbnailBitmap
as this was very rarely supported by camera apps when writing the image to the providedUri
. ( b/154302879 ) - The
invoke()
extensions onActivityResultLauncher
have been removed in favor of explicitly usinglaunch()
to better indicate that these are asynchronous operations. Kotlin extensions forlaunch
have been added to theandroidx.activity.result
package forActivityResultLauncher<Void>
andActivityResultLauncher<Unit>
that remove the need to pass innull
orUnit
, respectively, mirroring that behavior from the previouslyinvoke()
extensions. ( aosp/1304674 , aosp/1304675 ) - The
IntentSenderRequest.Builder
methods forsetFlagsMask()
andsetFlagsValues()
has been combined into a singlesetFlags()
method. ( aosp/1302111 )
رفع اشکال
- When registering an
ActivityResultCallback
with aLifecycleOwner
, fixed an issue where the callback would be triggered before the state reachesSTARTED
. ( aosp/1309744 )
تغییرات رفتار
- The
ActivityResultRegistry
now generates request codes starting at0xFFFF
rather than at0
, preventing overlap when usingstartActivityForResult()
orrequestPermissions()
in an activity. ( aosp/1302324 )
Version 1.2.0-alpha04
29 آوریل 2020
androidx.activity:activity:1.2.0-alpha04
and androidx.activity:activity-ktx:1.2.0-alpha04
are released. Version 1.2.0-alpha04 contains these commits.
ویژگی های جدید
- Added a contract that can call startIntentSenderForResult to the ActivityResult APIs. ( b/153007517 )
تغییرات API
- The
prepareCall()
method has been renamed toregisterForActivityResult()
, both onComponentActivity
here and in Fragment1.3.0-alpha04
. ( aosp/1278717 ) - The
GetContents
,OpenDocuments
, andRequestPermissions
contracts have been renamed toGetMultipleContents
,OpenMultipleDocuments
, andRequestMultiplePermissions
, respectively. ( aosp/1280161 ) -
ComponentActivity
now implements theActivityResultRegisteryOwner
interface. ( aosp/1290888 ) - - The
startActivityForResult()
/onActivityResult()
andonRequestPermissionsResult()
APIs onComponentActivity
have been deprecated. Please use the Activity Result APIs . ( b/154751887 )
رفع اشکال
- When using the
GetMultipleContents
andOpenMultipleDocuments
contracts and selecting a single item, it is now correctly returned to your callback. ( b/152941153 )
Version 1.2.0-alpha03
1 آوریل 2020
androidx.activity:activity:1.2.0-alpha03
and androidx.activity:activity-ktx:1.2.0-alpha03
are released. Version 1.2.0-alpha03 contains these commits.
ویژگی های جدید
- Added the
TakeVideo
,PickContact
,GetContent
,GetContents
,OpenDocument
,OpenDocuments
,OpenDocumentTree
, andCreateDocument
contracts to the set of pre-built contracts provided byActivityResultContracts
. ( aosp/1262482 , aosp/1266916 , aosp/1268960 ) - The Activity Result APIs now support launching an activity for result with an optional
ActivityOptionsCompat
. ( b/151860054 )
تغییرات API
- The
TakePicture
contract now takes aUri
input for where the image should be stored. The previous contract that does not take any input has been renamed toTakePicturePreview
. ( aosp/1262482 ) - The
registerActivityResultCallback()
method onActivityResultRegistry
has been renamed toregister()
. ( aosp/1267621 ) - The
dispose()
method onActivityResultLauncher
has been renamed tounregister()
and theunregisterResultCallback()
onActivityResultRegistry
has been removed. ( aosp/1267621 ) - The
createIntent()
method ofActivityResultContact
now takes aContext
in addition to the input to make it possible to create explicit Intents. ( aosp/1238800 ) - An
ActivityResultContract
can now overridegetSynchronousResult()
to deliver a result without callingstartActivityForResult
. This is used by theRequestPermission
andRequestPermissions
contracts to correctly deliver a 'granted' status if the requested permissions are already granted. ( b/151110799 ) - The previously available
Dial
contract has been removed as thatIntent
is not meant to be used withstartActivityForResult()
. ( aosp/1266916 ) - Many of the Activity Result APIs not meant to be extended are now
final
. This includesgetActivityResultRegistry()
, theprepareCall()
methods, all methods ofActivityResultRegistry
exceptinvoke()
, and a number of the default contracts that do not support optional extras. ( b/152439361 )
رفع اشکال
- Fixed a
NullPointerException
inActivityResultRegistry
when attempting to deliver results to a callback that has not yet been re-registered after a configuration change;ActivityResultRegistry
now holds onto these pending results and delivers them when the callback is re-registered. ( b/152137004 )
Version 1.2.0-alpha02
18 مارس 2020
androidx.activity:activity:1.2.0-alpha02
and androidx.activity:activity-ktx:1.2.0-alpha02
are released. Version 1.2.0-alpha02 contains these commits.
ویژگی های جدید
- ActivityResultRegistry :
ComponentActivity
now provides anActivityResultRegistry
that lets you handle thestartActivityForResult()
+onActivityResult()
as well asrequestPermissions()
+onRequestPermissionsResult()
flows without overriding methods in your Activity or Fragment, brings increased type safety viaActivityResultContract
, and provides hooks for testing these flows. See the updated Getting a Result from an Activity . ( b/125158199 )
Version 1.2.0-alpha01
4 مارس 2020
androidx.activity:activity:1.2.0-alpha01
and androidx.activity:activity-ktx:1.2.0-alpha01
are released. Version 1.2.0-alpha01 contains these commits.
ویژگی های جدید
- Added support for the
ViewTreeLifecycleOwner.get(View)
API added in Lifecycle2.3.0-alpha01
such that it will return the Activity as theLifecycleOwner
for any Views directly added to the Activity. ( aosp/1182955 )
رفع اشکال
- Fixed a regression introduced in Activity
1.1.0
when running on older versions of the platform whereonBackPressed()
would cause anIllegalStateException
due to a bug in theandroid.app.FragmentManager
. ( b/146290338 )
نسخه 1.1.0
نسخه 1.1.0
22 ژانویه 2020
androidx.activity:activity:1.1.0
is released. Version 1.1.0 contains these commits .
Important changes since 1.0.0
- Lifecycle ViewModel SavedState Integration :
SavedStateViewModelFactory
is now the default factory used when usingby viewModels()
, theViewModelProvider
constructor, orViewModelProviders.of()
with aComponentActivity
or its subclasses.
Version 1.1.0-rc03
4 دسامبر 2019
androidx.activity:activity:1.1.0-rc03
and androidx.activity:activity-ktx:1.1.0-rc03
are released. Version 1.1.0-rc03 contains these commits .
Dependency changes
- Activity now depends on Lifecycle
2.2.0-rc03
and Lifecycle ViewModel SavedState1.0.0-rc03
.
Version 1.1.0-rc02
7 نوامبر 2019
androidx.activity:activity:1.1.0-rc02
and androidx.activity:activity-ktx:1.1.0-rc02
are released. Version 1.1.0-rc02 contains these commits .
Dependency changes
- Activity now depends on lifecycle
2.2.0-rc02
.
Version 1.1.0-rc01
23 اکتبر 2019
androidx.activity:activity:1.1.0-rc01
and androidx.activity:activity-ktx:1.1.0-rc01
are released with no changes from 1.1.0-beta01
. Version 1.1.0-rc01 contains these commits .
Version 1.1.0-beta01
9 اکتبر 2019
androidx.activity:activity:1.1.0-beta01
and androidx.activity:activity-ktx:1.1.0-beta01
are released. Version 1.1.0-beta01 contains these commits .
Dependency changes
- Activity now depends on SavedState 1.0.0 stable.
Version 1.1.0-alpha03
5 سپتامبر 2019
androidx.activity:activity:1.1.0-alpha03
and androidx.activity:activity-ktx:1.1.0-alpha03
are released. The commits included in this version can be found here .
ویژگی های جدید
- Activity now depends on Core 1.1.0 stable.
رفع اشکال
- Activity now depends on Lifecycle
2.2.0-alpha04
.
Version 1.1.0-alpha02
7 آگوست 2019
androidx.activity:activity:1.1.0-alpha02
and androidx.activity:activity-ktx:1.1.0-alpha02
are released. The commits included in this version can be found here .
ویژگی های جدید
-
SavedStateViewModelFactory
is now the default factory used when usingby viewModels()
, theViewModelProvider
constructor, orViewModelProviders.of()
with aComponentActivity
( b/135716331 )
Version 1.1.0-alpha01
2 جولای 2019
androidx.activity:activity:1.1.0-alpha01
and androidx.activity:activity-ktx:1.1.0-alpha01
are released. The commits included in this version can be found here .
ویژگی های جدید
-
activity
now depends on Lifecycle2.2.0-alpha02
. ( aosp/1007817 ) -
activity-ktx
added a dependency onlifecycle-runtime-ktx
; you no longer need to explicitly add it to your dependencies when usingactivity-ktx
or libraries that depend onactivity-ktx
(such asfragment-ktx
). ( aosp/987162 )
Version 1.0.0
Version 1.0.0
5 سپتامبر 2019
androidx.activity:activity:1.0.0
and androidx.activity:activity-ktx:1.0.0
are released. The commits included in this version can be found here .
Major Features of 1.0.0
- ComponentActivity :
ComponentActivity
serves as the new base class forFragmentActivity
in Fragment1.1.0
and, by extension,AppCompatActivity
in AppCompat1.1.0
. - activity-ktx : The
activity-ktx
module includes aby viewModels
Kotlin property extension for accessing ViewModels. This module is automatically included when you includefragment-ktx
from Fragment1.1.0
. - OnBackPressedDispatcher : As a composable alternative to overriding
onBackPressed()
, you can now register aOnBackPressedCallback
from anyLifecycleOwner
(such as a fragment) to intercept system back button events. A lambda with receiver versionaddCallback
has been added toactivity-ktx
. See Provide custom back navigation documentation for more details. - onRetainCustomNonConfigurationInstance deprecation : the
onRetainCustomNonConfigurationInstance()
and the relatedgetLastCustomNonConfigurationInstance()
APIs have been deprecated. It is strongly recommended to use ViewModels to store non-configuration state as they offer a composable solution suitable for anyViewModelStoreOwner
that makes the ownership of the retained objects clear and provides anonCleared()
callback for cleaning up resources when the activity is finally destroyed.
Version 1.0.0-rc01
2 جولای 2019
androidx.activity:activity:1.0.0-rc01
and androidx.activity:activity-ktx:1.0.0-rc01
are released with no changes from 1.0.0-beta01
. The commits included in this version can be found here .
Version 1.0.0-beta01
5 ژوئن 2019
androidx.activity::activity:1.0.0-beta01
and androidx.activity:activity-ktx:1.0.0-beta01
are released with no changes from 1.0.0-alpha08
. The commits included in this version can be found here .
Version 1.0.0-alpha08
7 مه 2019
androidx.activity:activity:1.0.0-alpha08
and androidx.activity:activity-ktx:1.0.0-alpha08
are released. The commits included in this version can be found here .
API changes
- Breaking change: The previously deprecated
addOnBackPressedCallback
andremoveOnBackPressedCallback
methods onComponentActivity
have been removed. aosp/953857 - The
setEnabled()
andisEnabled()
methods ofOnBackPressedCallback
are now final. b/131416833 - The
remove()
method ofOnBackPressedCallback
is now final. aosp/952720 -
OnBackPressedDispatcher
now has public constructors, allowing you to construct your own instances for testing, etc. aosp/953431 -
onBackPressed()
forComponentActivity
is now explicitly marked as@MainThread
aosp/952721
رفع اشکال
- Fixed a
ConcurrentModificationException
when callingremove()
from within thehandleOnBackPressed()
method of aOnBackPressedCalback
that was added with aLifecycleOwner
. b/131765095
Version 1.0.0-alpha07
April 25th, 2019
androidx.activity:activity:1.0.0-alpha07
and androidx.activity:activity-ktx:1.0.0-alpha07
are released. The commits included in this version can be found here .
API changes
This release makes significant changes to the handling of the onBackPressed()
. See the updated custom back documentation for more details.
- The methods for
OnBackPressedCallback
andOnBackPressedDispatcher
have been marked as@MainThread
. ( aosp/943813 ) - The
handleOnBackPressed()
method no longer returns aboolean
. Instead,OnBackPressedCallback
is now an abstract class that can be enabled or disabled - only when the newisEnabled()
method returns true willhandleOnBackPressed()
be called, in which you must handle the back button. ( aosp/944518 ) - The
addCallback
methods ofOnBackPressedDispatcher
no longer return aCancellable
instance.OnBackPressedCallback
now contain aremove()
method that fulfill this functionality, allowing you to callremove()
duringhandleOnBackPressed()
. ( aosp/944519 ) ( aosp/946316 ) -
activity-ktx
now contains a receiver scoped callback foraddCallback
that accepts a lamdba that implementshandleOnBackPressed()
and has access toisEnabled
andremove()
( aosp/944520 )
Version 1.0.0-alpha06
3 آوریل 2019
androidx.activity:activity:1.0.0-alpha06
and androidx.activity:activity-ktx:1.0.0-alpha06
are released. The commits included in this version can be found here .
API changes
- ComponentActivity now contain a second constructor that takes a
@LayoutRes int
, which replaces the previous behavior of annotating your AppCompatActivity class with@ContentView
. This approach works in both app and library modules. ( b/128352521 ) - The
OnBackPressedCallback
related APIs on ComponentActivity have been deprecated in favor of the newOnBackPressedDispatcher
, retrievable viagetOnBackPressedDispatcher()
. ( aosp/922523 ) - Methods to add a new
OnBackPressedCallback
to theOnBackPressedDispatcher
now return aCancellable
object, allowing removal of the callback without requiring an explicit reference to theOnBackPressedDispatcher
. ( aosp/922523 ) - Adding a
OnBackPressedCallback
with an associatedLifecycleOwner
now results in adding and removing theOnBackPressedCallback
as the Lifecycle is started and stopped, respectively. ( aosp/922523 )
Version 1.0.0-alpha05
13 مارس 2019
androidx.activity:activity:1.0.0-alpha05
and androidx.activity:activity-ktx:1.0.0-alpha05
are released. The full list of commits included in this release can be found here .
ویژگی های جدید
-
@ContentView
annotation lookups are now cached ( b/123709449 )
Version 1.0.0-alpha04
30 ژانویه 2019
androidx.activity:activity 1.0.0-alpha04
and androidx.activity:activity-ktx 1.0.0-alpha04
are released.
ویژگی های جدید
- Added support for the
@ContentView
class annotation that allows you to indicate which layout XML file should be inflated as an alternative to usingsetContentView()
. ( aosp/837619 )
API changes
- Added a note that
getViewModelStore()
should not be overridden and will be made final in a future release. Please file a feature request if you are currently overriding this method. ( aosp/837619 )
رفع اشکال
- The
activity
module now depends on version 2.1.0-alpha02 of ViewModel to match theactivity-ktx
module's dependency.
Version 1.0.0-alpha03
17 دسامبر 2018
androidx.activity 1.0.0-alpha03
is released.
ویژگی های جدید
- ComponentActivity now implements
BundleSavedStateRegistryOwner
and depends on the newly released SavedState library [ aosp/815133 ] - ComponentActivity now works around an Android framework bug that would cause InputMethodManager to leak the last focused view [ b/37122102 ]
Version 1.0.0-alpha02
3 دسامبر 2018
API changes
- Added a note that
getLifecycle()
should not be overridden and will be madefinal
in a future release. Please file a feature request if you are currently overriding this method. ( aosp/815834 )
Version 1.0.0-alpha01
5 نوامبر 2018
androidx.activity 1.0.0-alpha01
introduces ComponentActivity
, a new base class of the existing FragmentActivity
and AppCompatActivity
.
ویژگی های جدید
- You can now register an
OnBackPressedCallback
viaaddOnBackPressedCallback
to receiveonBackPressed()
callbacks without needing to override the method in your activity. - Added a new
by viewModels()
Kotlin property delegate for retrievingViewModel
s from aComponentActivity
. - Pending input events (such as clicks) are now canceled in
onStop()
.
API changes
- The implementation of
LifecycleOwner
andViewModelStoreOwner
have been moved fromFragmentActivity
toComponentActivity
. -
onRetainCustomNonConfigurationInstance
has been deprecated. Use aViewModel
for storing objects that need to survive configuration changes.
فعالیت
آخرین به روز رسانی | انتشار پایدار | کاندید را آزاد کنید | نسخه بتا | Alpha Release |
---|---|---|---|---|
9 آوریل 2025 | 1.10.1 | - | 1.11.0-beta01 | - |
اعلام وابستگی ها
To add a dependency on Activity, you must add the Google Maven repository to your project. Read Google's Maven repository for more information.
Add the dependencies for the artifacts you need in the build.gradle
file for your app or module:
شیار
dependencies { def activity_version = "1.10.1" // Java language implementation implementation "androidx.activity:activity:$activity_version" // Kotlin implementation "androidx.activity:activity-ktx:$activity_version" }
کاتلین
dependencies { val activity_version = "1.10.1" // Java language implementation implementation("androidx.activity:activity:$activity_version") // Kotlin implementation("androidx.activity:activity-ktx:$activity_version") }
For more information about dependencies, see Add build dependencies .
بازخورد
Your feedback helps make Jetpack better. Let us know if you discover new issues or have ideas for improving this library. Please take a look at the existing issues in this library before you create a new one. You can add your vote to an existing issue by clicking the star button.
See the Issue Tracker documentation for more information.
نسخه 1.11
Version 1.11.0-beta01
9 آوریل 2025
androidx.activity:activity:1.11.0-beta01
, androidx.activity:activity-compose:1.11.0-beta01
, and androidx.activity:activity-ktx:1.11.0-beta01
are released. Version 1.11.0-beta01 contains these commits .
Version 1.11.0-alpha02
26 مارس 2025
androidx.activity:activity:1.11.0-alpha02
, androidx.activity:activity-compose:1.11.0-alpha02
, and androidx.activity:activity-ktx:1.11.0-alpha02
are released. Version 1.11.0-alpha02 contains these commits .
تغییرات API
- Integrated the new
EDGE_NONE
andframeTimeMillis
from Android 16 Beta03 into theBackEventCompat
provided byOnBackPressedCallback
'shandleOnBackStarted
andhandleOnBackProgressed
functions.
Dependency Updates
- Activity is now compiled with API 36. ( I510e8 , b/301910674 )
Version 1.11.0-alpha01
12 مارس 2025
androidx.activity:activity:1.11.0-alpha01
, androidx.activity:activity-compose:1.11.0-alpha01
, and androidx.activity:activity-ktx:1.11.0-alpha01
are released. Version 1.11.0-alpha01 contains these commits .
ویژگی های جدید
- Added
MediaCapabilities
API toPickVisualMediaRequest
to let applications specify its media capabilities, such as supported HDR Types. ( Ic3ee7 )
نسخه 1.10
نسخه 1.10.1
26 فوریه 2025
androidx.activity:activity:1.10.1
, androidx.activity:activity-compose:1.10.1
, and androidx.activity:activity-ktx:1.10.1
are released. Version 1.10.1 contains these commits .
رفع اشکال
-
ViewTree
OnBackPressedDispatcherOwners
andFullyDrawnReporterOwners
can now be resolved through disjoint parents of a view, such as aViewOverlay
. See the release notes of core or the documentation inViewTree.setViewTreeDisjointParent
for more information on disjoint view parents. ( Ie7750 )
نسخه 1.10.0
15 ژانویه 2025
androidx.activity:activity:1.10.0
, androidx.activity:activity-compose:1.10.0
, and androidx.activity:activity-ktx:1.10.0
are released. Version 1.10.0 contains these commits .
Important changes since 1.9.0
-
PhotoPicker
now allows picking images in order and choosing which tab (either albums or images) should be initially visible. - The
PickVisualMedia
andPickMultipleVisualMedia
Activity Result contracts that trigger the Photo Picker no longer directly delegates to Google Play services if the system Photo picker is not available, but uses the publicACTION_SYSTEM_FALLBACK_PICK_IMAGES
action and related extras to provide a consistent Photo Picker experience to OEMs and system apps as a fallback. - New
LocalActivity
composition local that provides theActivity
for the current scope, removing the need for developers to get anActivity
from theLocalContext
.
Version 1.10.0-rc01
11 دسامبر 2024
androidx.activity:activity:1.10.0-rc01
, androidx.activity:activity-compose:1.10.0-rc01
, and androidx.activity:activity-ktx:1.10.0-rc01
are released. Version 1.10.0-rc01 contains these commits .
رفع اشکال
- Fixed an issue where changing the enabled state while the
PredictiveBackHandler
is currently active would short circuit the callback immediately. It will now finish the current callback regardless of the enabled status changes. ( Ib8719 )
Version 1.10.0-beta01
13 نوامبر 2024
androidx.activity:activity:1.10.0-beta01
, androidx.activity:activity-compose:1.10.0-beta01
, and androidx.activity:activity-ktx:1.10.0-beta01
are released with no changes since the last alpha. Version 1.10.0-beta01 contains these commits .
Version 1.10.0-alpha03
30 اکتبر 2024
androidx.activity:activity:1.10.0-alpha03
, androidx.activity:activity-compose:1.10.0-alpha03
, and androidx.activity:activity-ktx:1.10.0-alpha03
are released. Version 1.10.0-alpha03 contains these commits .
تغییرات API
- Added a new
LocalActivity
composition local that provides theActivity
for the current scope, removing the need for developers to get anActivity
from theLocalContext
. It also comes with a new lint rule that checks when theLocalContext
is incorrectly being cast to anActivity
. ( I7746a , b/283009666 )
رفع اشکال
- From Activity
1.9.3
:PredictiveBackHandler
will no longer fire it's callback after the handler has been disabled. This will fix an issue where theNavHost
from Navigation Compose would throw anIndexOutOfBoundsException
. ( I3f75e , b/365027664 , b/340202286 )
Dependency Update
- Activity Compose now depends on Compose Runtime 1.7.0 ( I7746a , b/283009666 )
Version 1.10.0-alpha02
4 سپتامبر 2024
androidx.activity:activity:1.10.0-alpha02
, androidx.activity:activity-compose:1.10.0-alpha02
, and androidx.activity:activity-ktx:1.10.0-alpha02
are released. Version 1.10.0-alpha02 contains these commits .
تغییرات رفتار
- The
PickVisualMedia
andPickMultipleVisualMedia
Activity Result contracts that trigger the Photo Picker no longer directly delegates to Google Play services if the system Photo picker is not available, but uses the publicACTION_SYSTEM_FALLBACK_PICK_IMAGES
action and related extras to provide a consistent Photo Picker experience to OEMs and system apps as a fallback. This should have no effect on the user experience for devices that have a recent version of Google Play services. ( I3513d )
رفع اشکال
- Removed manual outlining of access to new platform APIs since this happens automatically via API modeling when using R8 with AGP 7.3 or later (eg R8 version 3.3) and for all builds when using AGP 8.1 or later (eg D8 version 8.1). Clients who are not using AGP are advised to update to D8 version 8.1 or later. برای جزئیات بیشتر به این مقاله مراجعه کنید. ( I9496c , b/345472586 )
- From Activity
1.9.2
: Fixed an issue where the Activity ComposePredictiveBackHandler
API would continue to handle the system back gesture on the frame it was disabled, which could result in libraries like Navigation Compose to handle back even with an empty back stack, resulting in it throwing anIndexOutOfBoundsException
. ( Ie3301 , b/340202286 ) - From Activity
1.9.1
: Fixed an issue withPredictiveBackHandler
where after doing system back, attempting to doonBackPressed
from theOnBackPressedDispatcher
would fail. ( I5f1f8 )
Version 1.10.0-alpha01
26 ژوئن 2024
androidx.activity:activity:1.10.0-alpha01
, androidx.activity:activity-compose:1.10.0-alpha01
, and androidx.activity:activity-ktx:1.10.0-alpha01
are released. This version is developed in an internal branch.
ویژگی های جدید
- Added support for new
PhotoPicker
features introduced in Android V including being able to pick images in order and choose which tab (either albums or images) should be initially visible.
نسخه 1.9
نسخه 1.9.3
16 اکتبر 2024
androidx.activity:activity:1.9.3
, androidx.activity:activity-compose:1.9.3
, and androidx.activity:activity-ktx:1.9.3
are released. Version 1.9.3 contains these commits .
رفع اشکال
-
PredictiveBackHandler
will no longer fire it's callback after the handler has been disabled. This will fix an issue where theNavHost
from Navigation Compose would throw anIndexOutOfBoundsException
. ( I3f75e , b/340202286 )
Version 1.9.2
4 سپتامبر 2024
androidx.activity:activity:1.9.2
, androidx.activity:activity-compose:1.9.2
, and androidx.activity:activity-ktx:1.9.2
are released. Version 1.9.2 contains these lthcocommits .
رفع اشکال
- Fixed an issue where the Activity Compose
PredictiveBackHandler
API would continue to handle the system back gesture on the frame it was disabled, which could result in libraries like Navigation Compose to handle back even with an empty back stack, resulting in it throwing anIndexOutOfBoundsException
. ( Ie3301 , b/340202286 )
Version 1.9.1
24 جولای 2024
androidx.activity:activity:1.9.1
, androidx.activity:activity-compose:1.9.1
, and androidx.activity:activity-ktx:1.9.1
are released. Version 1.9.1 contains these commits .
رفع اشکال
- Fixed an issue with
PredictiveBackHandler
where after doing system back, attempting to doonBackPressed
from theOnBackPressedDispatcher
would fail. ( I5f1f8 )
نسخه 1.9.0
17 آوریل 2024
androidx.activity:activity:1.9.0
, androidx.activity:activity-compose:1.9.0
, and androidx.activity:activity-ktx:1.9.0
are released. Version 1.9.0 contains these commits .
Important changes since 1.8.0
-
ComponentActivity
now implementsOnUserLeaveHintProvider
to allow components to callbacks foronUserLeaveHint
events. - The
OnBackPressedCallback
,BackHandler
, andPredictiveBackHandler
APIs now warn when callingonBackPressedDispatcher.onBackPressed()
when handling back as that will always break the Predictive Back Animation . See the best practices guide for more details. - The remainder of the Activity APIs have been rewritten in Kotlin and all extensions previously available in
activity-ktx
have been moved toactivity
.activity-ktx
is now completely empty.- As part of the conversion of
ActivityResultLauncher
to Kotlin, thegetContract
method is now an abstract Kotlin property. This is a binary compatible change, but source breaking if your implementation ofActivityResultLauncher
is written in Kotlin.
- As part of the conversion of
Version 1.9.0-rc01
3 آوریل 2024
androidx.activity:activity:1.9.0-rc01
, androidx.activity:activity-compose:1.9.0-rc01
, and androidx.activity:activity-ktx:1.9.0-rc01
are released. Version 1.9.0-rc01 contains these commits .
به روز رسانی وابستگی
- Activity now depends on Profile Installer 1.3.1 .
Version 1.9.0-beta01
20 مارس 2024
androidx.activity:activity:1.9.0-beta01
, androidx.activity:activity-compose:1.9.0-beta01
, and androidx.activity:activity-ktx:1.9.0-beta01
are released. Version 1.9.0-beta01 contains these commits .
رفع اشکال
- Fixed an Activity startup performance regression introduced in Activity
1.9.0-alpha02
caused by calling theOnBackPressedDispatcher
as part of the creation of the Activity. ( Ie75e3 )
Version 1.9.0-alpha03
7 فوریه 2024
androidx.activity:activity:1.9.0-alpha03
, androidx.activity:activity-compose:1.9.0-alpha03
, and androidx.activity:activity-ktx:1.9.0-alpha03
are released. Version 1.9.0-alpha03 contains these commits.
Lint Warning
- The
OnBackPressedCallback
,BackHandler
, andPredictiveBackHandler
APIs now warn when callingonBackPressedDispatcher.onBackPressed()
when handling back as that will always break the Predictive Back Animation . See the best practices guide for more details. ( 1e4222 , 2c950d , b/287505200 )
رفع اشکال
- If a back event is sent from the system started during an already running Predictive Back Gesture, the currently running Predictive Back Gesture is canceled and the new back event takes over to begin a new Predictive Back Gesture. ( I3482e )
- Fixed a crash when accessing the
onBackPressedDispatcher
from aComponentActivity
for the first time from a background thread. It is now safe to access theonBackPressedDispatcher
on any thread. ( I79955 )
Version 1.9.0-alpha02
24 ژانویه 2024
androidx.activity:activity:1.9.0-alpha02
, androidx.activity:activity-compose:1.9.0-alpha02
, and androidx.activity:activity-ktx:1.9.0-alpha02
are released. Version 1.9.0-alpha02 contains these commits.
Kotlin Conversions
-
ActivityResultRegistry
has been rewritten in Kotlin. This ensures that the nullability of the generics on the contract passed toregister
will correctly be passed through to theActivityResultLauncher
returned to you. ( I121f0 ) -
ActivityResult
has been rewritten in Kotlin. TheActivityResult
Kotlin extensions that support destructuring into theresultCode
anddata
fields have been moved fromactivity-ktx
toactivity
. ( I0565a ) - The Kotlin extensions of
by viewModels()
forComponentActivity
andtrackPipAnimationHintView
have been moved fromactivity-ktx
toactivity
. Theactivity-ktx
artifact is now completely empty. ( I0a444 )
رفع اشکال
- The
enableEdgeToEdge
API now draws around any display cutouts. ( a3644b , b/311173461 ) - From Activity
1.8.2
: Fixed the extra passed to the Photo Picker Activity Contract'sACTION_SYSTEM_FALLBACK_PICK_IMAGES
to correctly pass it theEXTRA_SYSTEM_FALLBACK_PICK_IMAGES_MAX
key, rather than using the extra with the key"com.google.android.gms.provider.extra.PICK_IMAGES_MAX"
. It is strongly recommended if you are an OEM who implements a system fallback Photo Picker to support both extras to ensure the widest compatibility. ( I96a00 )
Version 1.9.0-alpha01
29 نوامبر 2023
androidx.activity:activity:1.9.0-alpha01
, androidx.activity:activity-compose:1.9.0-alpha01
, and androidx.activity:activity-ktx:1.9.0-alpha01
are released. Version 1.9.0-alpha01 contains these commits.
ویژگی های جدید
-
ComponentActivity
now implementsOnUserLeaveHintProvider
to allow components to callbacks foronUserLeaveHint
events. ( I54892 )
تغییرات API
-
ComponentActivity
has been rewritten in Kotlin. ( I14f31 ) -
ActivityResultCaller
has been rewritten in Kotlin. ( Ib02e4 ) -
ActivityResultLauncher
has been rewritten in Kotlin. As part of that conversion, thegetContract
method is now an abstract Kotlin property. This is a binary compatible change, but source breaking if your implementation ofActivityResultLauncher
is written in Kotlin. ( Id4615 ) -
PickVisualMediaRequest
now has the same minimum API level of 19 as thePickVisualMedia
Activity Result contract. ( Id6e21 )
Dependency Update
- Activity now depends on Core
1.13.0-alpha01
. ( I14f31 )
نسخه 1.8
نسخه 1.8.2
13 دسامبر 2023
androidx.activity:activity:1.8.2
, androidx.activity:activity-compose:1.8.2
, and androidx.activity:activity-ktx:1.8.2
are released. Version 1.8.2 contains these commits.
رفع اشکال
- Fixed the extra passed to the Photo Picker Activity Contract's
ACTION_SYSTEM_FALLBACK_PICK_IMAGES
to correctly pass it theEXTRA_SYSTEM_FALLBACK_PICK_IMAGES_MAX
key, rather than using the extra with the key"com.google.android.gms.provider.extra.PICK_IMAGES_MAX"
. It is strongly recommended if you are an OEM who implements a system fallback Photo Picker to support both extras to ensure the widest compatibility. ( I96a00 )
نسخه 1.8.1
15 نوامبر 2023
androidx.activity:activity:1.8.1
, androidx.activity:activity-compose:1.8.1
, and androidx.activity:activity-ktx:1.8.1
are released. Version 1.8.1 contains these commits.
رفع اشکال
-
OnBackPressedDispatcher
now continues to dispatch to the correctOnBackPressedCallback
even after a newOnBackPressedCallback
is added while the back gesture is being handled. ( Id0ff6 )
نسخه 1.8.0
4 اکتبر 2023
androidx.activity:activity:1.8.0
, androidx.activity:activity-compose:1.8.0
, and androidx.activity:activity-ktx:1.8.0
are released. Version 1.8.0 contains these commits.
Important changes since 1.7.0
- Predictive Back - The
OnBackPressedCallback
now offers new Predictive Back callbacks for handling the back gesture starting, progress throughout the gesture, and the back gesture being canceled in addition to the previoushandleOnBackPressed()
callback for when the back gesture is committed. This also comes with thePredictiveBackHandler
Composable to handle predictive back gesture events in Activity Compose. It provides a Flow of BackEventCompat objects that must be collected in the suspending lamba you provide:
PredictiveBackHandler { progress: Flow<BackEventCompat> ->
// code for gesture back started
try {
progress.collect { backEvent ->
// code for progress
}
// code for completion
} catch (e: CancellationException) {
// code for cancellation
}
}
ComponentActivity.onBackPressed()
has now been deprecated in favor of the APIs for handling back. Developers should now utilize the OnBackPressedDispatcher
, rather than overriding this method.
- EdgeToEdge -
ComponentActivity.enableEdgeToEdge()
has been added to easily set up the edge-to-edge display in a backward-compatible manner.
Version 1.8.0-rc01
20 سپتامبر 2023
androidx.activity:activity:1.8.0-rc01
, androidx.activity:activity-compose:1.8.0-rc01
, and androidx.activity:activity-ktx:1.8.0-rc01
are released. Version 1.8.0-rc01 contains these commits.
Version 1.8.0-beta01
6 سپتامبر 2023
androidx.activity:activity:1.8.0-beta01
, androidx.activity:activity-compose:1.8.0-beta01
, and androidx.activity:activity-ktx:1.8.0-beta01
are released. Version 1.8.0-beta01 contains these commits.
Documentation Improvement
- Improved the documentation of
BackEventCompat
. ( aosp/2722254 )
Version 1.8.0-alpha07
23 آگوست 2023
androidx.activity:activity:1.8.0-alpha07
, androidx.activity:activity-compose:1.8.0-alpha07
, and androidx.activity:activity-ktx:1.8.0-alpha07
are released. Version 1.8.0-alpha07 contains these commits.
ویژگی های جدید
Activity Compose has added a new
PredictiveBackHandler
Composable to handle predictive back gesture events. It provides aFlow
ofBackEventCompat
objects that must be collected in the suspending lamba you provide:PredictiveBackHandler { progress: Flow<BackEventCompat> -> // code for gesture back started try { progress.collect { backEvent -> // code for progress } // code for completion } catch (e: CancellationException) { // code for cancellation } }
It also comes with a compile time warning via lint rule to ensure the
Flow
callscollect()
. ( Id2773 , b/294884345 )The
onBackPressedDispatcher
inComponentActivity
is now initialized lazily so that it is only created when required. ( I0bf8e )
رفع اشکال
-
ComponentActivity
will no longer show a NPE on Android 13 when it gets anonBackPressed()
callback and the Activity has already beenDESTROYED
. ( Idb055 , b/291869278 ) - Removed usages of experimental
isAtLeastU()
API ( Ie9117 , b/289269026 )
Version 1.8.0-alpha06
21 ژوئن 2023
androidx.activity:activity:1.8.0-alpha06
, androidx.activity:activity-compose:1.8.0-alpha06
, and androidx.activity:activity-ktx:1.8.0-alpha06
are released. Version 1.8.0-alpha06 contains these commits.
ویژگی های جدید
- The
OnBackPressedDispatcher
now correctly cancels any callbacks that are removed during a Predictive Back Gesture. ( I3f90f )
تغییرات API
- When passing
SystemBarStyle.auto
to theenableEdgeToEdge
API, you can now override thedetectDarkMode
lambda parameter to provide custom logic for detecting night mode. ( aosp/2546393 , b/278263793 )
Version 1.8.0-alpha05
7 ژوئن 2023
androidx.activity:activity:1.8.0-alpha05
, androidx.activity:activity-compose:1.8.0-alpha05
, and androidx.activity:activity-ktx:1.8.0-alpha05
are released. This version is developed in an internal branch.
تغییرات API
- Activity now provides a
BackEventCompat
class that serves as a backward compatible version ofBackEvent
that is decoupled from the frameworkBackEvent
class. - Breaking change: The
handleOnBackStarted
andhandleOnBackProgressed
methods ofOnBackPressedCallback
now receive anandroidx.activity.BackEventCompat
instance rather than a frameworkandroid.window.BackEvent
class. The equivalent@VisibleForTesting
APIs onOnBackPressedDispatcher
have also been updated. - The constructor for
OnBackPressedDispatcher
now takes an optionalConsumer<Boolean>
instance that allows the owners of the dispatcher to receive a callback whenever the number of enabled callbacks changes from zero to non-zero or vice versa.
رفع اشکال
- From Activity
1.7.2
: FixReportDrawn
crashing when navigating away from a screen beforereport
is called. ( Ic46f1 , b/260506820 )
Version 1.8.0-alpha04
10 مه 2023
androidx.activity:activity:1.8.0-alpha04
, androidx.activity:activity-compose:1.8.0-alpha04
, and androidx.activity:activity-ktx:1.8.0-alpha04
are released. This was released from an internal branch.
رفع اشکال
- From Activity 1.7.1 : - The
ReportFullyDrawExecuter
no longer leaks when usingComponentActivity
withActivityScenario
. ( Id2ff2 , b/277434271 )
Version 1.8.0-alpha03
12 آوریل 2023
androidx.activity:activity:1.8.0-alpha03
, androidx.activity:activity-compose:1.8.0-alpha03
, and androidx.activity:activity-ktx:1.8.0-alpha03
are released. This was released from an internal branch.
ویژگی های جدید
- Added
ComponentActivity.setUpEdgeToEdge()
to easily set up the edge-to-edge display in a backward-compatible manner.
تغییرات API
-
ComponentActivity.onBackPressed()
has now been deprecated in favor of the APIs for handling back. Developers should now utilize theOnBackPressedDispatcher
, rather than overriding this method. ( Ibce2f , b/271596918 ) -
ComponentDialog
andComponentActivity
now contain public APIinitViewTreeOwners()
to be used to initialize all view tree owners before setting the content view. ( Ibdce0 , b/261314581 )
رفع اشکال
- Fixed an issue where Fragments were incorrectly invalidating MenuHosts and causing other menus in the Activity to have unexpected behavior. ( I9404e , b/244336571 )
سایر تغییرات
- The
ActivityResultRegister
now uses KotlinRandom
instead of Java. ( I4d98f , b/272096025 )
Version 1.8.0-alpha02
8 مارس 2023
androidx.activity:activity:1.8.0-alpha02
, androidx.activity:activity-compose:1.8.0-alpha02
, and androidx.activity:activity-ktx:1.8.0-alpha02
are released. Developed from an internal branch.
به روز رسانی وابستگی
- From Activity
1.7.0-rc01
: Activity now depends onLifecycle 2.6.0
.
Version 1.8.0-alpha01
8 فوریه 2023
androidx.activity:activity:1.8.0-alpha01
, androidx.activity:activity-compose:1.8.0-alpha01
, and androidx.activity:activity-ktx:1.8.0-alpha01
are released. This was built from an internal branch.
ویژگی های جدید
- The
OnBackPressedCallback
class now contains new Predictive Back progress callbacks for handling the back gesture starting, progress throughout the gesture, and the back gesture being canceled in addition to the previoushandleOnBackPressed()
callback for when the back gesture is committed.
نسخه 1.7
نسخه 1.7.2
24 مه 2023
androidx.activity:activity:1.7.2
, androidx.activity:activity-compose:1.7.2
, and androidx.activity:activity-ktx:1.7.2
are released. Version 1.7.2 contains these commits.
رفع اشکال
- Fix
ReportDrawn
crashing when navigating away from a screen beforereport
is called. ( Ic46f1 , b/260506820 )
نسخه 1.7.1
19 آوریل 2023
androidx.activity:activity:1.7.1
, androidx.activity:activity-compose:1.7.1
, and androidx.activity:activity-ktx:1.7.1
are released. Version 1.7.1 contains these commits.
رفع اشکال
- The
ReportFullyDrawExecuter
no longer leaks when usingComponentActivity
withActivityScenario
. ( Id2ff2 , b/277434271 )
نسخه 1.7.0
22 مارس 2023
androidx.activity:activity:1.7.0
, androidx.activity:activity-compose:1.7.0
, and androidx.activity:activity-ktx:1.7.0
are released. Version 1.7.0 contains these commits.
Important changes since 1.6.0
- The Photo Picker activity contracts in
PickVisualMedia
andPickMultipleVisualMedia
have been updated to contain an additional fallback for whenMediaStore.ACTION_PICK_IMAGES
is unavailable that allows OEMs and system apps, such as Google Play services, to provide a consistent Photo Picker experience on a wider range of Android devices and API levels by implementing the fallback action . The Photo Picker will use this fallback if it is available before falling back to usingIntent.ACTION_OPEN_DOCUMENT
, which remains to support all API 19 and higher devices. -
ComponentDialog
now implementsSavedStateRegistryOwner
and has access to its ownSavedStateRegistry
and sets theSavedStateRegistryOwner
for itsViewTree
. It is now possible to use Jetpack Compose within aComponentDialog
as it meets both theLifecycleOwner
andSavedStateRegistryOwner
attached to the Window via theViewTree
APIs requirements. -
IntentSenderRequest.Builder.setFlags()
now allows you to set multiple flags fromIntent
, rather than only a single flag.
Kotlin Conversion
A number of Activity classes have been converted to Kotlin. All converted classes still retain their binary compatibility with previous versions. The following classes have source incompatible changes for classes written in Kotlin: ActivityResultRegistryOwner
, OnBackPressedDispatcherOwner
.
The table below provides the source conversions for the new version of Activity:
Activity 1.5 | Activity 1.6 |
---|---|
override fun getActivityResultRegistry() = activityResultRegistry | override val activityResultRegistry = activityResultRegistry |
override fun getOnBackPressedDispatcher() = onBackPressedDispatcher | override val onBackPressedDispatcher = onBackPressedDispatcher |
These classes were also converted to Kotlin, but remain source compatible: ContextAware
, ContextAwareHelper
, OnContextAvailableListener
, IntentSenderRequest
, and OnBackPressedDispatcher
FullyDrawnReporter APIs
ComponentActivity
now provides a FullyDrawnReporter
instance that allows multiple components to report when they are ready for interaction. ComponentActivity
will wait for all components to complete before calling reportFullyDrawn()
on your behalf. These APIs take care of the timing requirements for you and do not need to be called as part of an onDraw
call.
These APIs are encouraged to enable:
- Signaling the Android Runtime when startup completes, to ensure all of the code run during a multi-frame startup sequence is included and prioritized for background compilation.
- Signaling Macrobenchmark and Play Vitals when your application should be considered fully drawn for startup metrics, so you can track performance.
Three Activity Compose APIs have been added to make it more convenient to use the FullyDrawnReporter
from individual composables:
-
ReportDrawn
indicates that your composable is immediately ready for interaction. -
ReportDrawnWhen
takes a predicate (ie,list.count > 0
) to indicate when your composable is ready for interaction. -
ReportDrawnAfter
takes a suspending method that, when it completes, indicates that you are ready for interaction.
Dependency Updates
- Activity now depends on Lifecycle
2.6.1
. ( 8fc31d ) - Activity now depends on ProfileInstaller
1.3.0
. ( 83d3b1 )
Version 1.7.0-rc01
8 مارس 2023
androidx.activity:activity:1.7.0-rc01
, androidx.activity:activity-compose:1.7.0-rc01
, and androidx.activity:activity-ktx:1.7.0-rc01
are released. Version 1.7.0-rc01 contains these commits.
به روز رسانی وابستگی
- Activity now depends on
Lifecycle 2.6.0
.
Version 1.7.0-beta02
22 فوریه 2023
androidx.activity:activity:1.7.0-beta02
, androidx.activity:activity-compose:1.7.0-beta02
, and androidx.activity:activity-ktx:1.7.0-beta02
are released. Version 1.7.0-beta02 contains these commits.
تغییرات API
- The action and extra used by the
PickVisualMedia
andPickMultipleVisualMedia
contracts as a fallback for whenMediaStore.ACTION_PICK_IMAGES
is unavailable are now public constants that provide API stability to OEMs and system apps that want to provide a consistent Photo Picker experience. The implementation of this fallback is still limited to only system apps. ( Icd320 )
Version 1.7.0-beta01
8 فوریه 2023
androidx.activity:activity:1.7.0-beta01
, androidx.activity:activity-compose:1.7.0-beta01
, and androidx.activity:activity-ktx:1.7.0-beta01
are released. Version 1.7.0-beta01 contains these commits.
ویژگی های جدید
-
IntentSenderRequest.Builder.setFlags()
now allows you to set multiple flags fromIntent
, rather than only a single flag. ( Iac04c )
رفع اشکال
- The fallback for
PickVisualMedia
for when the framework Photo Picker is unavailable now correctly limits the handling to apps installed in the device's system image. ( If8ae6 )
Kotlin Conversions
-
ActivityResultRegistryOwner
is now written in Kotlin. This is a source incompatible change for those classes written in Kotlin - you must now override theactivityResultRegistry
property rather than implementing the previousgetActivityResultRegistry()
function. ( I0b00e ) -
OnBackPressedDispatcherOwner
is now written in Kotlin. This is a source incompatible change for those classes written in Kotlin - you must now override theonBackPressedDispatcher
property rather than implementing the previousgetOnBackPressedDispatcher
function. ( Ia277d ) -
ContextAware
,ContextAwareHelper
,OnContextAvailableListener
,IntentSenderRequest
andOnBackPressedDispatcher
are now written in Kotlin. ( I1a73e , Iada92 , aosp/2410754 , I18ac7 , b/257291701 )
Version 1.7.0-alpha04
25 ژانویه 2023
androidx.activity:activity:1.7.0-alpha04
, androidx.activity:activity-compose:1.7.0-alpha04
, and androidx.activity:activity-ktx:1.7.0-alpha04
are released. Version 1.7.0-alpha04 contains these commits.
ویژگی های جدید
- The
PickVisualMedia
andPickMultipleVisualMedia
Activity Result contracts will now use a Google Play services provided Photo Picker where available in cases where the Android system provided Photo Picker (eg,MediaStore.ACTION_PICK_IMAGES
) is not available. TheisPhotoPickerAvailable()
API that only detects the Android system provided Photo Picker has been deprecated. It is recommended to use the newisPhotoPickerAvailable(Context)
API, which will return if either Photo Picker is available. ( I55be6 )
Version 1.7.0-alpha03
11 ژانویه 2023
androidx.activity:activity:1.7.0-alpha03
, androidx.activity:activity-compose:1.7.0-alpha03
, and androidx.activity:activity-ktx:1.7.0-alpha03
are released. Version 1.7.0-alpha03 contains these commits.
ویژگی های جدید
-
ComponentDialog
now implementsSavedStateRegistryOwner
and has access to its ownSavedStateRegistry
and sets theSavedStateRegistryOwner
for its ViewTree. It is now possible to use Jetpack Compose within aComponentDialog
as it meets both theLifecycleOwner
andSavedStateRegistryOwner
attached to the Window via the ViewTree APIs requirements. ( Idca17 , I73468 b/261162296 )
تغییرات API
- Added a
ReportDrawn
composable that immediately marks the activity as ready to callreportFullyDrawn
. ( Ic5b14 , b/259687964 )
Kotlin Conversions
- The
ActvitiyResultCallback
andOnBackPressedCallback
classes have both been converted to Kotlin while maintaining source and binary compatibility. ( Ifc5e5 , Ide1b0 , b/257291701 )
Version 1.7.0-alpha02
24 اکتبر 2022
androidx.activity:activity:1.7.0-alpha02
, androidx.activity:activity-compose:1.7.0-alpha02
, and androidx.activity:activity-ktx:1.7.0-alpha02
are released. Version 1.7.0-alpha02 contains these commits.
رفع اشکال
- From Activity
1.6.1
: Fixed an issue with thePickMultipleVisualMedia
Activity Result contract not launching on Android R devices when using the default value formaxItems
. ( Ie2776 , b/249182130 )
Version 1.7.0-alpha01
5 اکتبر 2022
androidx.activity:activity:1.7.0-alpha01
, androidx.activity:activity-compose:1.7.0-alpha01
, and androidx.activity:activity-ktx:1.7.0-alpha01
are released. Version 1.7.0-alpha01 contains these commits.
FullyDrawnReporter APIs
ComponentActivity
now provides a FullyDrawnReporter
instance that allows multiple components to report when they are ready for interaction. ComponentActivity
will wait for all components to complete before calling reportFullyDrawn()
on your behalf. These APIs take care of the timing requirements for you and do not need to be called as part of an onDraw
call.
These APIs are encouraged to enable:
- Signaling the Android Runtime when startup completes, to ensure all of the code run during a multi-frame startup sequence is included and prioritized for background compilation.
- Signaling Macrobenchmark and Play Vitals when your application should be considered fully drawn for startup metrics, so you can track performance.
Two Activity Compose APIs have been added to make it more convenient to use the FullyDrawnReporter
from individual composables:
-
ReportDrawnWhen
takes a predicate (ie,list.count > 0
) to indicate when your composable is ready for interaction. -
ReportDrawnAfter
takes a suspending method that, when it completes, indicates that you are ready for interaction.
نسخه 1.6.1
نسخه 1.6.1
24 اکتبر 2022
androidx.activity:activity:1.6.1
, androidx.activity:activity-compose:1.6.1
, and androidx.activity:activity-ktx:1.6.1
are released. Version 1.6.1 contains these commits.
رفع اشکال
- Fixed an issue with the
PickMultipleVisualMedia
Activity Result contract not launching on Android R devices when using the default value formaxItems
. ( Ie2776 , b/249182130 )
نسخه 1.6.0
نسخه 1.6.0
21 سپتامبر 2022
androidx.activity:activity:1.6.0
, androidx.activity:activity-compose:1.6.0
, and androidx.activity:activity-ktx:1.6.0
are released. Version 1.6.0 contains these commits.
Important changes since 1.5.0
- Added
ActivityResultContracts.PickVisualMedia
andActivityResultContracts.PickMultipleVisualMedia
for providing a backward compatible contract that usesMediaStore.ACTION_PICK_IMAGES
when the Photo Picker is available andIntent.ACTION_OPEN_DOCUMENT
when it is not available. - Integrated the
OnBackInvokedCallback
in Android 13 into theOnBackPressedDispatchers
provided byComponentActivity
andComponentDialog
. This ensures that all APIs built onOnBackPressedDispatcher
work when enabling a predictive back gesture .
Version 1.6.0-rc02
7 سپتامبر 2022
androidx.activity:activity:1.6.0-rc02
, androidx.activity:activity-compose:1.6.0-rc02
, and androidx.activity:activity-ktx:1.6.0-rc02
are released. Version 1.6.0-rc02 contains these commits.
رفع اشکال
-
OnBackPressedDispatcher
now registers theOnBackInvokedCallback
with thePRIORITY_DEFAULT
instead ofPRIORITY_OVERLAY
. ( I3901f ) - Classes that extend
ComponentActivity
will now always have both of theironMultiWindowModeChanged()
callbacks dispatched. ( Ic4d85 ) - The
ActivityResultRegistry
will no longer return a result to theActivityResultCallback
when thelaunch
call throws anyException
and the callback was registered without aLifecycleOwner
. ( Ia7ff7 , b/238350794 ) -
ComponentActivity
will now properly dispatch menu calls without the need to call the super function in your activity. ( Ie33c5 , b/238057118 )
Dependency Update
- The
Activity
library now depends on Lifecycle2.5.1
. ( If6697 )
Version 1.6.0-rc01
24 آگوست 2022
androidx.activity:activity:1.6.0-rc01
, androidx.activity:activity-compose:1.6.0-rc01
, and androidx.activity:activity-ktx:1.6.0-rc01
are released. Version 1.6.0-rc01 contains these commits.
رفع اشکال
- Initializing an
OnBackPressedDispatcher
will no longer causeClassVerificationError
s when using SDK versions prior to 33. ( Ic32e1 ) - Classes that override
ComponentActivity
'sonPictureInPictureModeChanged()
callback will now always have their callbacks dispatched. ( Ib7fdb )
Version 1.6.0-beta01
August 10, 2022
androidx.activity:activity:1.6.0-beta01
, androidx.activity:activity-compose:1.6.0-beta01
, and androidx.activity:activity-ktx:1.6.0-beta01
are released. Version 1.6.0-beta01 contains these commits.
تغییرات API
- Marked the deprecated
startActivityForResult
andstartIntentSenderForResult
methods onComponentActivity
with@NonNull
because passingnull
has always resulted in a crash. ( Id2a25 , b/231476082 )
رفع اشکال
- From Activity
1.5.1
: TheActivityResultRegistry
will no longer return a result to theActivityResultCallback
when thelaunch
call throws anyException
and the callback was registered without aLifecycleOwner
. ( Ia7ff7 , b/238350794 ) - From Activity
1.5.1
:ComponentActivity
will now properly dispatch menu calls toonPrepareOptionMenu()
,onCreateOptionsMenu()
andonOptionsItemSelected()
overrides without the need to call the super function. ( Ie33c5 , b/238057118 )
Dependency Update
- From Activity
1.5.1
: TheActivity
library now depends on theLifecycle
version2.5.1
. ( If6697 )
Version 1.6.0-alpha05
15 ژوئن 2022
androidx.activity:activity:1.6.0-alpha05
, androidx.activity:activity-compose:1.6.0-alpha05
, and androidx.activity:activity-ktx:1.6.0-alpha05
are released. Version 1.6.0-alpha05 was developed in a private pre-release branch and has no public commits.
تغییرات API
-
minCompileSdk
is now 33 to align with Tiramisu Beta 3 SDK
رفع اشکال
- Fixed crash on older devices when doing SDK extension check for the
PickVisualMedia
ActivityResultContract
so that it should now work withACTION_OPEN_DOCUMENT
on devices running Android 10 and lower.
Version 1.6.0-alpha04
18 مه 2022
androidx.activity:activity:1.6.0-alpha04
and androidx.activity:activity-ktx:1.6.0-alpha04
are released.
رفع اشکال
- Fixed an error in
PickVisualMediaRequest
where attempting to create a request, either via the Builder or the top level Kotlin function, would result in a stack overflow. - Integrated the
OnBackInvokedCallback
in Android 13 Dev Beta 2 into theOnBackPressedDispatcher
provided byComponentDialog
. This ensures that all APIs built onOnBackPressedDispatcher
work when enabling a predictive back gesture .
Version 1.6.0-alpha03
27 آوریل 2022
androidx.activity:activity:1.6.0-alpha03
, androidx.activity:activity-compose:1.6.0-alpha03
, and androidx.activity:activity-ktx:1.6.0-alpha03
are released.
- Note: This version will only compile against the Android 13 Developer Beta 1 SDK.
ویژگی های جدید
- Added
ActivityResultContracts.PickVisualMedia
andActivityResultContracts.PickMultipleVisualMedia
for providing a backward compatible contract that usesMediaStore.ACTION_PICK_IMAGES
when the Photo Picker is available andIntent.ACTION_OPEN_DOCUMENT
when it is not available. - Integrated the
OnBackInvokedCallback
in Android 13 Dev Beta 1 into theOnBackPressedDispatcher
provided byComponentActivity
. This ensures that all APIs built onOnBackPressedDispatcher
work when enabling a predictive back gesture .
Version 1.6.0-alpha01
23 مارس 2022
androidx.activity:activity:1.6.0-alpha01
, androidx.activity:activity-compose:1.6.0-alpha01
, and androidx.activity:activity-ktx:1.6.0-alpha01
are released.
- Note: This version will only compile against the Android 13 Developer Preview 2 SDK.
ویژگی های جدید
- Integrated changes in Android 13 Dev Preview 2 into
ComponentActivity
.
نسخه 1.5.1
نسخه 1.5.1
27 جولای 2022
androidx.activity:activity:1.5.1
, androidx.activity:activity-compose:1.5.1
, and androidx.activity:activity-ktx:1.5.1
are released. Version 1.5.1 contains these commits.
رفع اشکال
The
ActivityResultRegistry
will no longer return a result to theActivityResultCallback
when thelaunch()
call throws anyException
and the callback was registered without aLifecycleOwner
. ( Ia7ff7 , b/238350794 )ComponentActivity
will now properly dispatch menu calls toonPrepareOptionMenu()
,onCreateOptionsMenu()
andonOptionsItemSelected()
overrides without the need to call the super function. ( Ie33c5 , b/238057118 )
به روز رسانی وابستگی
- The
Activity
library now depends on the Lifecycle2.5.1
. ( If6697 )
نسخه 1.5.0
نسخه 1.5.0
29 ژوئن 2022
androidx.activity:activity:1.5.0
, androidx.activity:activity-compose:1.5.0
, and androidx.activity:activity-ktx:1.5.0
are released. Version 1.5.0 contains these commits.
Important changes since 1.4.0
- ComponentDialog -
ComponentDialog
is a subclass ofDialog
that includes anOnBackPressedDispatcher
that will be called when the system back button is pressed and the dialog is visible. Importantly, this subclass also sets theViewTreeOnBackPressedDispatcherOwner
, allowing views a generic way to retrieve the correct dispatcher whether it exists in aComponentActivity
or aComponentDialog
. - Callback Interfaces -
ComponentActivity
now implements a set of modular callback interfaces that can be used instead of theActivity
callbacks. These interfaces include the following:OnNewIntentProvider
,OnConfigurationChangedProvider
,OnTrimMemoryProvider
,OnPictureInPictureModeChangedProvider
,OnMultiWindowModeChangedProvider
- CreationExtras Integration -
ComponentActivity
now has the ability to provide a statelessViewModelProvider.Factory
via Lifecycle2.5.0
'sCreationExtras
.
تغییرات دیگر
- The no parameter constructor for
ActivityResultContracts.CreateDocument
has been deprecated and replaced with a new constructor that takes a concrete mime type (eg, "image/png") as is required byIntent.ACTION_CREATE_DOCUMENT
.
Version 1.5.0-rc01
11 مه 2022
androidx.activity:activity:1.5.0-rc01
, androidx.activity:activity-compose:1.5.0-rc01
, and androidx.activity:activity-ktx:1.5.0-rc01
are released with no changes from 1.5.0-beta01. Version 1.5.0-rc01 contains these commits.
Version 1.5.0-beta01
20 آوریل 2022
androidx.activity:activity:1.5.0-beta01
, androidx.activity:activity-compose:1.5.0-beta01
, and androidx.activity:activity-ktx:1.5.0-beta01
are released. Version 1.5.0-beta01 contains these commits.
Dependency updates
- Activity now depends on Lifecycle
2.4.0-beta01
.
Version 1.5.0-alpha05
6 آوریل 2022
androidx.activity:activity:1.5.0-alpha05
, androidx.activity:activity-compose:1.5.0-alpha05
, and androidx.activity:activity-ktx:1.5.0-alpha05
are released. Version 1.5.0-alpha05 contains these commits.
رفع اشکال
-
ComponentActivity
'sonPanelClosed()
now calls the superonPanelClosed()
as well, fixing an issue where theonContextMenuClosed
method would not be called. ( Ib6f77 )
Version 1.5.0-alpha04
23 مارس 2022
androidx.activity:activity:1.5.0-alpha04
, androidx.activity:activity-compose:1.5.0-alpha04
, and androidx.activity:activity-ktx:1.5.0-alpha04
are released. Version 1.5.0-alpha04 contains these commits.
رفع اشکال
-
SavedStateViewFactory
now supports usingCreationExtras
even when it was initialized with aSavedStateRegistryOwner
. If extras are provided, the initialized arguments are ignored. ( I6c43b , b/224844583 )
Version 1.5.0-alpha03
23 فوریه 2022
androidx.activity:activity:1.5.0-alpha03
, androidx.activity:activity-compose:1.5.0-alpha03
, and androidx.activity:activity-ktx:1.5.0-alpha03
are released. Version 1.5.0-alpha03 contains these commits.
تغییرات API
- You can now pass
CreationExtras
to the activityby viewModels()
function ( I6a3e6 , b/217600303 )
Version 1.5.0-alpha02
9 فوریه 2022
androidx.activity:activity:1.5.0-alpha02
, androidx.activity:activity-compose:1.5.0-alpha02
, and androidx.activity:activity-ktx:1.5.0-alpha02
are released. Version 1.5.0-alpha02 contains these commits.
ویژگی های جدید
-
ComponentActivity
now implements theOnPictureInPictureModeChangedProvider
interface to allow any component to receive picture-in-picture mode change events. ( I9f567 ) -
ComponentActivity
now implements theOnMultiWindowModeChangedProvider
interface to allow any component to receive multi-window mode change events. ( I62d91 )
Version 1.5.0-alpha01
26 ژانویه 2022
androidx.activity:activity:1.5.0-alpha01
, androidx.activity:activity-compose:1.5.0-alpha01
, and androidx.activity:activity-ktx:1.5.0-alpha01
are released. Version 1.5.0-alpha01 contains these commits.
ویژگی های جدید
-
ComponentActivity
now integrates with ViewModel CreationExtras, introduced as part of Lifecycle2.5.0-alpha01
. ( Ie7e00 , b/207012584 ) - Added
ComponentDialog
, a subclass ofDialog
that includes anOnBackPressedDispatcher
that will be called when the system back button is pressed when the dialog is visible. Importantly, this subclass also sets theViewTreeOnBackPressedDispatcherOwner
, allowing views a generic way to retrieve the correct dispatcher whether it exists in aComponentActivity
or aComponentDialog
. ( I8a1bc ) -
ComponentActivity
now implements the newOnNewIntentProvider
interface to allow any component to receive these events. ( If1f8b ) -
ComponentActivity
now implements the newOnConfigurationChangedProvider
interface to allow any component to receive these events. ( If623b ) -
ComponentActivity
now implements the newOnTrimMemoryProvider
interface to allow any component to receive these events. ( Ia9295 )
تغییرات API
- The no parameter constructor for
ActivityResultContracts.CreateDocument
has been deprecated and replaced with a new constructor that takes a concrete mime type (eg,"image/png"
) as is required byIntent.ACTION_CREATE_DOCUMENT
. ( I2bec6 ) - The
OnBackPressedDispatcherOwner
associated with a View can now be retrieved via theViewTreeOnBackPressedDispatcherOwner
, rather than relying on casting theContext
. ( I74685 )
رفع اشکال
- Fixed a crash when accessing a
ViewModel
for the very first time from aregisterForActivityResult()
callback or the callbacks to aLifecycleObserver
added as part ofinit
of aComponentActivity
. ( Ife83f )
نسخه 1.4.0
نسخه 1.4.0
27 اکتبر 2021
androidx.activity:activity:1.4.0
, androidx.activity:activity-compose:1.4.0
, and androidx.activity:activity-ktx:1.4.0
are released. Version 1.4.0 contains these commits.
Important changes since 1.3.0
- AndroidX
ComponentActivity
now implements theMenuHost
interface. This allows any component to add menu items to theActionBar
by adding aMenuProvider
instance to the activity. EachMenuProvider
can optionally be added with aLifecycle
that will automatically control the visibility of those menu items based on theLifecycle
state and handle the removal of theMenuProvider
when theLifecycle
is destroyed. - The
ActivityResultContract
class has been rewritten in Kotlin to ensure that developers writing custom contracts in Kotlin can define the correct nullability for their input and output classes. - The
ActivityResultContracts
class and its contracts have been rewritten in Kotlin to ensure the proper nullability.
Version 1.4.0-rc01
13 اکتبر 2021
androidx.activity:activity:1.4.0-rc01
, androidx.activity:activity-compose:1.4.0-rc01
, and androidx.activity:activity-ktx:1.4.0-rc01
are released. Version 1.4.0-rc01 contains these commits.
رفع اشکال
- The
ActivityResultRegistry
will no longer return a result to theActivityResultCallback
when thelaunch
call throws anyException
. ( If4f91 , b/200845664 )
Version 1.4.0-beta01
29 سپتامبر 2021
androidx.activity:activity:1.4.0-beta01
, androidx.activity:activity-compose:1.4.0-beta01
, and androidx.activity:activity-ktx:1.4.0-beta01
are released. Version 1.4.0-beta01 contains these commits.
تغییرات API
- Fixed the type for the
ActivityResultContracts.OpenMultipleDocuments
andActivityResultContracts.GetMultipleContents
that caused then to use an output type ofList<? extends Uri>
when using the code from the Java programming language. ( If71de ) - Public constants within the
ActivityResultContracts.StartActivityForResult
,ActivityResultContracts.StartIntentSenderForResult
, andActivityResultContracts.RequestMultiplePermissions
classes are now accessible when using Kotlin via their now publicCompanion
objects. ( aosp/1832555 )
به روز رسانی اسناد
- The deprecation message for APIs now handled by the Activity Result APIs , namely
startActivityForResult
,startIntentSenderForResult
,onActivityResult
,requestPermissions
, andonRequestPermissionsResult
, have all been expanded with more details. ( cce80f )
Version 1.4.0-alpha02
15 سپتامبر 2021
androidx.activity:activity:1.4.0-alpha02
, androidx.activity:activity-compose:1.4.0-alpha02
, and androidx.activity:activity-ktx:1.4.0-alpha02
are released. Version 1.4.0-alpha02 contains these commits.
ویژگی های جدید
- The
activity-compose
artifact now contains aLaunchDuringComposition
lint error that prevents you from calling thelaunch
method ofActivityResultLauncher
as part of composition as composition should be side-effect free. Use the APIs for handling side-effects . ( 7c2bbe , b/191347220 )
تغییرات API
- The
ActivityResultContract
class has been rewritten in Kotlin to ensure that developers writing custom contracts in Kotlin can define the correct nullability for their input and output classes. ( I8a8f5 ) - The
ActivityResultContracts
class and its contracts have been rewritten in Kotlin to ensure the proper nullability. ( I69802 )
Version 1.4.0-alpha01
1 سپتامبر 2021
androidx.activity:activity:1.4.0-alpha01
, androidx.activity:activity-compose:1.4.0-alpha01
, and androidx.activity:activity-ktx:1.4.0-alpha01
are released. Version 1.4.0-alpha01 contains these commits.
ویژگی های جدید
- AndroidX
ComponentActivity
now implements theMenuHost
interface.. This allows any component to add menu items to theActionBar
by adding aMenuProvider
instance to the activity. EachMenuProvider
can optionally be added with aLifecycle
that will automatically control the visibility of those menu items based on theLifecycle
state and handle the removal of theMenuProvider
when theLifecycle
is destroyed. ( I3b608 ):
/**
* Using the addMenuProvider() API directly in your Activity
**/
class ExampleActivity : ComponentActivity(R.layout.activity_example) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Add menu items without overriding methods in the Activity
addMenuProvider(object : MenuProvider {
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
// Add menu items here
menuInflater.inflate(R.menu.example_menu, menu)
}
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
// Handle the menu selection
return true
}
})
}
}
/**
* Using the addMenuProvider() API in a Fragment
**/
class ExampleFragment : Fragment(R.layout.fragment_example) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
// The usage of an interface lets you inject your own implementation
val menuHost: MenuHost = requireActivity()
// Add menu items without using the Fragment Menu APIs
// Note how we can tie the MenuProvider to the viewLifecycleOwner
// and an optional Lifecycle.State (here, RESUMED) to indicate when
// the menu should be visible
menuHost.addMenuProvider(object : MenuProvider {
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
// Add menu items here
menuInflater.inflate(R.menu.example_menu, menu)
}
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
// Handle the menu selection
return true
}
}, viewLifecycleOwner, Lifecycle.State.RESUMED)
}
تغییرات رفتار
- The
ActivityResultRegistry
will now throw anIllegalStateException
when attempting to calllaunch()
on anActivityResultLauncher
that has not be registered or that has been unregistered. ( Ida75d , b/192567522 )
External Contribution
نسخه 1.3.1
نسخه 1.3.1
4 آگوست 2021
androidx.activity:activity:1.3.1
, androidx.activity:activity-compose:1.3.1
, and androidx.activity:activity-ktx:1.3.1
are released. Version 1.3.1 contains these commits.
Dependency updates
- Activity now depends on Kotlin
1.5.21
. - Activity Compose now depends on Compose
1.0.1
.
Version 1.3.0
Version 1.3.0
28 ژوئیه 2021
androidx.activity:activity:1.3.0
, androidx.activity:activity-compose:1.3.0
, and androidx.activity:activity-ktx:1.3.0
are released. Version 1.3.0 contains these commits.
Important changes since 1.2.0
- Activity Compose artifact - The
activity-compose
artifact provides thesetContent
extension method for hosting your Jetpack Compose UI in an activity and Compose specific wrappers for interacting with theComponentActivity
APIs for handling the system back button and the Activity Result APIs. برای جزئیات بیشتر به مستندات مراجعه کنید. - CaptureVideo contract - The
CaptureVideo
ActivityResultContract
replaces the now deprecatedTakeVideo
contract and returns a boolean denoting success that works across many camera apps. - Picture-In-Picture Hint View Tracking - Users of
activity-ktx
can now use thetrackPipAnimationHintView
extension method onActivity
to automatically rebuild thePictureInPictureParams
with the new position of the view as it changes position relative to the window.
Version 1.3.0-rc02
14 جولای 2021
androidx.activity:activity:1.3.0-rc02
, androidx.activity:activity-compose:1.3.0-rc02
, and androidx.activity:activity-ktx:1.3.0-rc02
are released. Version 1.3.0-rc02 contains these commits.
رفع اشکال
- The
ActivityResultRegistry
callbacks are now properly saved and restored so callbacks are not duplicated in the savedState. ( I97816 , b/191893160 )
Version 1.3.0-rc01
1 ژوئیه 2021
androidx.activity:activity:1.3.0-rc01
, androidx.activity:activity-compose:1.3.0-rc01
, and androidx.activity:activity-ktx:1.3.0-rc01
are released with no changes from 1.3.0-beta02
. Version 1.3.0-rc01 contains these commits.
Version 1.3.0-beta02
16 ژوئن 2021
androidx.activity:activity:1.3.0-beta02
, androidx.activity:activity-compose:1.3.0-beta02
, and androidx.activity:activity-ktx:1.3.0-beta02
are released. Version 1.3.0-beta02 contains these commits.
Updated activity-compose
to depend on Compose 1.0.0-beta09
. androidx.compose.ui:ui-test-junit4
now has a compile time dependency on activity-compose
.
Version 1.3.0-beta01
2 ژوئن 2021
androidx.activity:activity:1.3.0-beta01
, androidx.activity:activity-compose:1.3.0-beta01
, and androidx.activity:activity-ktx:1.3.0-beta01
are released. Version 1.3.0-beta01 contains these commits.
تغییرات API
- The previously deprecated
@Composable registerForActivityResult()
method has been removed. Please userememberLauncherForActivityResult()
. ( Ic39d3 )
Version 1.3.0-alpha08
18 مه 2021
androidx.activity:activity:1.3.0-alpha08
, androidx.activity:activity-compose:1.3.0-alpha08
, and androidx.activity:activity-ktx:1.3.0-alpha08
are released. Version 1.3.0-alpha08 contains these commits.
ویژگی های جدید
- The new
CaptureVideo
ActivityResultContract
returns a boolean to yourActivityResultCallback
indicating if your video was successfully saved to the given URI. This replaces the now deprecatedTakeVideo
contract as camera apps very rarely supported returning a thumbnail bitmap, making the result unhelpful. ( Ie21f2 , b/185938070 ) - Added new API
Activity#setPipAnimationHintView
to update the PipParams' source rect hint whenever the view moves. ( I9063d )
تغییرات API
- The
rememberLauncherForActivityResult
function now returns a launcher that deprecates theunregister()
function - registration and unregistering the launcher is handled automatically byrememberLauncherForActivityResult
. ( I2443e )
Compose Compatibility
-
androidx.activity:activity-compose:1.3.0-alpha08
is only compatible with Compose version1.0.0-beta07
and above.
Version 1.3.0-alpha07
21 آوریل 2021
androidx.activity:activity:1.3.0-alpha07
, androidx.activity:activity-compose:1.3.0-alpha07
, and androidx.activity:activity-ktx:1.3.0-alpha07
are released. Version 1.3.0-alpha07 contains these commits.
رفع اشکال
-
rememberLauncherForActivityResult
now returns a stable reference to the sameActivityResultLauncher
instance even if the contract changes due to recompositions. ( Id2d6d ) - Using unstable versions of Fragments above
1.3.0
will no longer throw a false positive lint error telling you to use1.3.0
. ( aosp/1670206 , b/184847092 )
Version 1.3.0-alpha06
7 آوریل 2021
androidx.activity:activity:1.3.0-alpha06
, androidx.activity:activity-compose:1.3.0-alpha06
, and androidx.activity:activity-ktx:1.3.0-alpha06
are released. Version 1.3.0-alpha06 contains these commits.
تغییرات API
- The
registerForActivityResult()
API has been renamed torememberLauncherForActivityResult()
to better indicate that the returnedActivityResultLauncher
is a managed object that is remembered on your behalf. Attempting to callunregister
the returnedActivityResultLauncher
will now throw an error. ( I2bb6d ) -
LocalOnBackPressedDispatcherOwner.current
andLocalActivityResultRegistryOwner.current
now return a nullable value to better determine whether it is available in the current composition. APIs that requires those APIs, such asBackHandler
andrememberLauncherForActivityResult()
, respectively, will now throw a more descriptive error if the underlying owner is not found.NavHost
now works even when anOnBackPressedDispatcherOwner
is not found, such is the case when previewing theNavHost
. ( I7d8b4 )
رفع اشکال
- The
BackHandler
will now properly intercept back presses in the event that the Activity isSTOPPED
, thenSTARTED
again, and other callbacks were added with a LifecycleOwner. ( I71de6 , b/182284739 ) - Using the
launch()
method extension with a customActivityResultContract
that has aUnit
input will no longer cause aNullPointerException
( I76282 , b/183837954 )
Version 1.3.0-alpha05
24 مارس 2021
androidx.activity:activity:1.3.0-alpha05
, androidx.activity:activity-compose:1.3.0-alpha05
, and androidx.activity:activity-ktx:1.3.0-alpha05
are released. Version 1.3.0-alpha05 contains these commits.
رفع اشکال
- From Activity 1.2.2 : Fixed an issue in the
InvalidFragmentVersionForActivityResult
lint check that led to a false positive when using Fragment 1.3.1 or higher. ( I54da1 , b/182388985 ) - From Activity 1.2.2 :
ComponentActivity
now avoids aClassNotFoundException
when launching anIntent
from anActivityResultContract
that was previously held as an extra in anotherIntent
. ( Ieff05 , b/182906230 )
Dependency Updates
- From Activity 1.2.2 : Activity now depends on Lifecycle
2.3.1
.
Version 1.3.0-alpha04
10 مارس 2021
androidx.activity:activity:1.3.0-alpha04
, androidx.activity:activity-compose:1.3.0-alpha04
, and androidx.activity:activity-ktx:1.3.0-alpha04
are released. Version 1.3.0-alpha04 contains these commits.
رفع اشکال
- From Activity
1.2.1
:RequestMultiplePermissions
now always returns results for all requested permissions instead of only permissions that weren't previously granted. ( I50bc3 , b/180884668 ) - From Activity
1.2.1
:ActivityResultRegistry
now ensures that in progresslaunch()
requests will return their results even if youunregister()
, thenregister()
again with the same key. ( I9ef34 , b/181267562 ) - Activity Compose no longer adds test dependencies to the runtime classpath. ( Ifd8b3 )
- Fixed an issue with
BackHandler
where the previously setonBack
lambda was still being used after recomposition. ( 8eb5eb )
Version 1.3.0-alpha03
24 فوریه 2021
androidx.activity:activity:1.3.0-alpha03
, androidx.activity:activity-compose:1.3.0-alpha03
, and androidx.activity:activity-ktx:1.3.0-alpha03
are released. Version 1.3.0-alpha03 contains these commits.
ویژگی های جدید
- There is a now a Composable
registerForActivityResult
function for getting results from activities within composables. ( Ia7851 , b/172690553 )
تغییرات API
-
LocalOnBackPressedDispatcherOwner
now has aprovides
functions that can be used withCompositionLocalProvider
, replacing theasProvidableCompositionLocal()
API. ( I45d24 )
Version 1.3.0-alpha02
10 فوریه 2021
androidx.activity:activity:1.3.0-alpha02
, androidx.activity:activity-compose:1.3.0-alpha02
, and androidx.activity:activity-ktx:1.3.0-alpha02
are released. Version 1.3.0-alpha02 contains these commits.
رفع اشکال
- Fixed an issue in Activity Compose
1.3.0-alpha01
that causes aNoSuchMethodError: No static method setContent
exception when using Compose1.0.0-alpha12
. All Compose users should depend on1.3.0-alpha02
and above. ( b/179911234 )
تغییرات API
- The
BackHandler
API can be used to allow a Composable to intercept the system back button. ( I58ed5 , b/172154006 )
Version 1.3.0-alpha01
10 فوریه 2021
androidx.activity:activity:1.3.0-alpha01
, androidx.activity:activity-compose:1.3.0-alpha01
, and androidx.activity:activity-ktx:1.3.0-alpha01
are released. Version 1.3.0-alpha01 contains these commits.
ویژگی های جدید
- The new
activity-compose
artifact provides Jetpack Compose specific helpers forandroidx.activity
specific APIs.-
ComponentActivity.setContent
has moved fromandroidx.compose.ui.platform.setContent
toandroidx.activity.compose.setContent
. ( Icf416 )
-
مسائل شناخته شده
- Using Activity Compose
1.3.0-alpha01
and libraries that depend on it, such asandroidx.compose.ui:ui-test-junit4:1.0.0-alpha12
, will result in aNoSuchMethodError: No static method setContent
exception. ( b/179911234 )
نسخه 1.2.4
نسخه 1.2.4
21 جولای 2021
androidx.activity:activity:1.2.4
and androidx.activity:activity-ktx:1.2.4
are released. Version 1.2.4 contains these commits.
رفع اشکال
- From Activity
1.3.0-rc02
: The ActivityResultRegistry callbacks are now properly saved and restored so callbacks are not duplicated in the savedState. ( I97816 , b/191893160 )
Version 1.2.3
Version 1.2.3
5 مه 2021
androidx.activity:activity:1.2.3
and androidx.activity:activity-ktx:1.2.3
are released. Version 1.2.3 contains these commits.
رفع اشکال
- Using the
launch()
method extension with a customActivityResultContract
that has aUnit
input will no longer cause aNullPointerException
( I76282 , b/183837954 ) - Fixed a false positive lint error telling you to use Fragment
1.3.0
when using an snapshot, alpha, beta, or RC build of a newer version of Fragments. ( f4a57e , b/184847092 )
نسخه 1.2.2
نسخه 1.2.2
24 مارس 2021
androidx.activity:activity:1.2.2
and androidx.activity:activity-ktx:1.2.2
are released. Version 1.2.2 contains these commits.
رفع اشکال
- Fixed an issue in the
InvalidFragmentVersionForActivityResult
lint check that led to a false positive when using Fragment 1.3.1 or higher. ( I54da1 , b/182388985 ) -
ComponentActivity
now avoids aClassNotFoundException
when launching anIntent
from anActivityResultContract
that was previously held as an extra in anotherIntent
. ( Ieff05 , b/182906230 )
Dependency Updates
- Activity now depends on Lifecycle
2.3.1
.
نسخه 1.2.1
نسخه 1.2.1
10 مارس 2021
androidx.activity:activity:1.2.1
and androidx.activity:activity-ktx:1.2.1
are released. Version 1.2.1 contains these commits.
رفع اشکال
-
RequestMultiplePermissions
now always returns results for all requested permissions instead of only permissions that weren't previously granted. ( I50bc3 , b/180884668 ) -
ActivityResultRegistry
now ensures that in progresslaunch()
requests will return their results even if youunregister()
, thenregister()
again with the same key. ( I9ef34 , b/181267562 )
نسخه 1.2.0
نسخه 1.2.0
10 فوریه 2021
androidx.activity:activity:1.2.0
and androidx.activity:activity-ktx:1.2.0
are released. Version 1.2.0 contains these commits.
Major changes since 1.1.0
- Activity Result APIs :
ComponentActivity
now provides anActivityResultRegistry
that lets you handlestartActivityForResult()
+onActivityResult()
as well asrequestPermissions()
+onRequestPermissionsResult()
flows without overriding methods in your Activity or Fragment, brings increased type safety viaActivityResultContract
, and provides hooks for testing these flows. See the updated Getting a Result from an Activity .
ContextAware
:ComponentActivity
now implementsContextAware
, allowing you to add one or moreOnContextAvailableListener
instances which will receive a callback before the baseActivity.onCreate()
.- A suspending Kotlin extension
withContextAvailable()
allows you to run a non-suspending block when the Context becomes available and return a result. - This API is used by
FragmentActivity
in Fragment 1.3.0 to restore the state of theFragmentManager
. Any listeners added to subclasses ofFragmentActivity
will run after that listener. - This API is used by
AppCompatActivity
in AppCompat 1.3.0-alpha02 or higher. Any listeners added to subclasses ofAppCompatActivity
will run after that listener.
- A suspending Kotlin extension
ViewTree
Support :ComponentActivity
now supports theViewTreeLifecycleOwner.get(View)
,ViewTreeViewModelStoreOwner.get(View)
, andViewTreeSavedStateRegistryOwner
APIs added in Lifecycle2.3.0
and SavedState1.1.0
such that it will return the Activity as theLifecycleOwner
,ViewModelStoreOwner
, andSavedStateRegistryOwner
for any Views directly added to theComponentActivity
.
- reportFullyDrawn() backport - The
Activity
method ofreportFullyDrawn()
has been backported inComponentActivity
to work on all API levels, fixing a crash on API 19 and adding tracing for this method for all API levels.
Version 1.2.0-rc01
16 دسامبر 2020
androidx.activity:activity:1.2.0-rc01
and androidx.activity:activity-ktx:1.2.0-rc01
are released. Version 1.2.0-rc01 contains these commits.
رفع اشکال
- The
ActivityResultRegistry
now always restores the exact state that was saved. ( Idd56b ) - Add tracing to
ComponentActivity.reportFullyDrawn
( Ic7632 )
External Contribution
-
ComponentActivity
now overridesreportFullyDrawn()
, allowing it to be called on all API levels and fixing a crash when calling this method without the appropriate system permission on API 19 devices. Thanks Simon Schiller! ( b/163239764 , #103 )
Version 1.2.0-beta02
2 دسامبر 2020
androidx.activity:activity:1.2.0-beta02
and androidx.activity:activity-ktx:1.2.0-beta02
are released. Version 1.2.0-beta02 contains these commits.
رفع اشکال
- Fixed an issue where the Activity Result API would not wait for the Lifecycle to be
STARTED
before delivering results when registered with aLifecycle
. ( I109ea )
External Contribution
- Updated the documentation for
launch()
to explicitly call out that it can throw anActivityNotFoundException
. Thanks Michał Zieliński! ( aosp/1493580 )
Version 1.2.0-beta01
1 اکتبر 2020
androidx.activity:activity:1.2.0-beta01
and androidx.activity:activity-ktx:1.2.0-beta01
are released. Version 1.2.0-beta01 contains these commits.
رفع اشکال
The
ActivityResultRegistry
now randomly generates integers until it finds one that is unallocated to use as a request coderegister()
, thus preventing the possible integer overflow caused by incrementing request codes. ( b/168779518 )Lifecycle
observers are properly removed when callingunregister()
on anActivityResultLauncher
. ( b/165608393 )
تغییرات رفتار
- The
ActivityResultRegistry
now throws anIllegalStateException
when attempting to callregister()
with aLifecycleOwner
whoseLifecycle
has already reachedSTARTED
. ( b/165435866 )
اسناد به روز شد
-
ContextAware
documentation links toLifecycleOwner
to highlightLifecycle
callbacks as the appropriate place for creation and destruction events. ( aosp/1414152 )
Version 1.2.0-alpha08
19 آگوست 2020
androidx.activity:activity:1.2.0-alpha08
and androidx.activity:activity-ktx:1.2.0-alpha08
are released. Version 1.2.0-alpha08 contains these commits.
ویژگی های جدید
-
ComponentActivity
now implementsContextAware
, allowing you to add one or moreOnContextAvailableListener
instances which will receive a callback before the baseActivity.onCreate()
. ( b/161390636 )- A suspending Kotlin extension
withContextAvailable()
allows you to run a non-suspending block when the Context becomes available and return a result. ( I8290c ) - This API is used by
FragmentActivity
in Fragment 1.3.0-alpha08 to restore the state of theFragmentManager
. Any listeners added to subclasses ofFragmentActivity
will run after that listener. ( I513da ) - This API is used by
AppCompatActivity
in AppCompat 1.3.0-alpha02 . Any listeners added to subclasses ofAppCompatActivity
will run after that listener. ( I513da )
- A suspending Kotlin extension
رفع اشکال
- Fixed an issue with the
ActivityResultFragmentVersionDetector
Lint check that caused it to break when using Lint 27.1.0 or higher. ( b/162155191 )
Version 1.2.0-alpha07
July 22, 2020
androidx.activity:activity:1.2.0-alpha07
and androidx.activity:activity-ktx:1.2.0-alpha07
are released. Version 1.2.0-alpha07 contains these commits.
ویژگی های جدید
- Added a new
InvalidFragmentVersionForActivityResult
lint check that verifies that you are using Fragment1.3.0-alpha07
when using the Activity Result API , avoiding runtime crashes due to “invalid request code” issues and non-functioning permission requests caused by using older versions of Fragments. ( b/152554847 )
External Contribution
- Fixed an
ArrayIndexOutOfBoundsException
when parsing the results for theRequestPermission
Activity Result contract. ( I8f9e3 , b/161057605 )
Version 1.2.0-alpha06
10 ژوئن 2020
androidx.activity:activity:1.2.0-alpha06
and androidx.activity:activity-ktx:1.2.0-alpha06
are released. Version 1.2.0-alpha06 contains these commits.
ویژگی های جدید
- You can now destructure the
ActivityResult
class in kotlin to directly access therequestCode
andintent
. ( b/157212935 ) -
ActivityResultLauncher
now allows you to get theActivityResultContract
that was used to register the launcher. ( b/156875743 )
تغییرات API
- Breaking change : The
invoke()
method onActivityResultRegistry
has been renamed toonLaunch()
. ( b/157496491 ) - The
OpenMultipleDocuments
contract now returns an empty list instead ofnull
to the registered callback if no result is returned. ( b/157348014 )
Version 1.2.0-alpha05
20 مه 2020
androidx.activity:activity:1.2.0-alpha05
and androidx.activity:activity-ktx:1.2.0-alpha05
are released. Version 1.2.0-alpha05 contains these commits.
ویژگی های جدید
- Added support for
ViewTreeViewModelStoreOwner
from Lifecycle2.3.0-alpha03
, andViewTreeSavedStateRegistryOwner
from SavedState1.1.0-alpha01
when using aView
within aComponentActivity
. ( aosp/1297993 , aosp/1300264 )
تغییرات API
- The
TakePicture
contract now returns aboolean
indicating success rather than a thumbnailBitmap
as this was very rarely supported by camera apps when writing the image to the providedUri
. ( b/154302879 ) - The
invoke()
extensions onActivityResultLauncher
have been removed in favor of explicitly usinglaunch()
to better indicate that these are asynchronous operations. Kotlin extensions forlaunch
have been added to theandroidx.activity.result
package forActivityResultLauncher<Void>
andActivityResultLauncher<Unit>
that remove the need to pass innull
orUnit
, respectively, mirroring that behavior from the previouslyinvoke()
extensions. ( aosp/1304674 , aosp/1304675 ) - The
IntentSenderRequest.Builder
methods forsetFlagsMask()
andsetFlagsValues()
has been combined into a singlesetFlags()
method. ( aosp/1302111 )
رفع اشکال
- When registering an
ActivityResultCallback
with aLifecycleOwner
, fixed an issue where the callback would be triggered before the state reachesSTARTED
. ( aosp/1309744 )
تغییرات رفتار
- The
ActivityResultRegistry
now generates request codes starting at0xFFFF
rather than at0
, preventing overlap when usingstartActivityForResult()
orrequestPermissions()
in an activity. ( aosp/1302324 )
Version 1.2.0-alpha04
29 آوریل 2020
androidx.activity:activity:1.2.0-alpha04
and androidx.activity:activity-ktx:1.2.0-alpha04
are released. Version 1.2.0-alpha04 contains these commits.
ویژگی های جدید
- Added a contract that can call startIntentSenderForResult to the ActivityResult APIs. ( b/153007517 )
تغییرات API
- The
prepareCall()
method has been renamed toregisterForActivityResult()
, both onComponentActivity
here and in Fragment1.3.0-alpha04
. ( aosp/1278717 ) - The
GetContents
,OpenDocuments
, andRequestPermissions
contracts have been renamed toGetMultipleContents
,OpenMultipleDocuments
, andRequestMultiplePermissions
, respectively. ( aosp/1280161 ) -
ComponentActivity
now implements theActivityResultRegisteryOwner
interface. ( aosp/1290888 ) - - The
startActivityForResult()
/onActivityResult()
andonRequestPermissionsResult()
APIs onComponentActivity
have been deprecated. Please use the Activity Result APIs . ( b/154751887 )
رفع اشکال
- When using the
GetMultipleContents
andOpenMultipleDocuments
contracts and selecting a single item, it is now correctly returned to your callback. ( b/152941153 )
Version 1.2.0-alpha03
1 آوریل 2020
androidx.activity:activity:1.2.0-alpha03
and androidx.activity:activity-ktx:1.2.0-alpha03
are released. Version 1.2.0-alpha03 contains these commits.
ویژگی های جدید
- Added the
TakeVideo
,PickContact
,GetContent
,GetContents
,OpenDocument
,OpenDocuments
,OpenDocumentTree
, andCreateDocument
contracts to the set of pre-built contracts provided byActivityResultContracts
. ( aosp/1262482 , aosp/1266916 , aosp/1268960 ) - The Activity Result APIs now support launching an activity for result with an optional
ActivityOptionsCompat
. ( b/151860054 )
تغییرات API
- The
TakePicture
contract now takes aUri
input for where the image should be stored. The previous contract that does not take any input has been renamed toTakePicturePreview
. ( aosp/1262482 ) - The
registerActivityResultCallback()
method onActivityResultRegistry
has been renamed toregister()
. ( aosp/1267621 ) - The
dispose()
method onActivityResultLauncher
has been renamed tounregister()
and theunregisterResultCallback()
onActivityResultRegistry
has been removed. ( aosp/1267621 ) - The
createIntent()
method ofActivityResultContact
now takes aContext
in addition to the input to make it possible to create explicit Intents. ( aosp/1238800 ) - An
ActivityResultContract
can now overridegetSynchronousResult()
to deliver a result without callingstartActivityForResult
. This is used by theRequestPermission
andRequestPermissions
contracts to correctly deliver a 'granted' status if the requested permissions are already granted. ( b/151110799 ) - The previously available
Dial
contract has been removed as thatIntent
is not meant to be used withstartActivityForResult()
. ( aosp/1266916 ) - Many of the Activity Result APIs not meant to be extended are now
final
. This includesgetActivityResultRegistry()
, theprepareCall()
methods, all methods ofActivityResultRegistry
exceptinvoke()
, and a number of the default contracts that do not support optional extras. ( b/152439361 )
رفع اشکال
- Fixed a
NullPointerException
inActivityResultRegistry
when attempting to deliver results to a callback that has not yet been re-registered after a configuration change;ActivityResultRegistry
now holds onto these pending results and delivers them when the callback is re-registered. ( b/152137004 )
Version 1.2.0-alpha02
18 مارس 2020
androidx.activity:activity:1.2.0-alpha02
and androidx.activity:activity-ktx:1.2.0-alpha02
are released. Version 1.2.0-alpha02 contains these commits.
ویژگی های جدید
- ActivityResultRegistry :
ComponentActivity
now provides anActivityResultRegistry
that lets you handle thestartActivityForResult()
+onActivityResult()
as well asrequestPermissions()
+onRequestPermissionsResult()
flows without overriding methods in your Activity or Fragment, brings increased type safety viaActivityResultContract
, and provides hooks for testing these flows. See the updated Getting a Result from an Activity . ( b/125158199 )
Version 1.2.0-alpha01
4 مارس 2020
androidx.activity:activity:1.2.0-alpha01
and androidx.activity:activity-ktx:1.2.0-alpha01
are released. Version 1.2.0-alpha01 contains these commits.
ویژگی های جدید
- Added support for the
ViewTreeLifecycleOwner.get(View)
API added in Lifecycle2.3.0-alpha01
such that it will return the Activity as theLifecycleOwner
for any Views directly added to the Activity. ( aosp/1182955 )
رفع اشکال
- Fixed a regression introduced in Activity
1.1.0
when running on older versions of the platform whereonBackPressed()
would cause anIllegalStateException
due to a bug in theandroid.app.FragmentManager
. ( b/146290338 )
نسخه 1.1.0
نسخه 1.1.0
22 ژانویه 2020
androidx.activity:activity:1.1.0
is released. Version 1.1.0 contains these commits .
Important changes since 1.0.0
- Lifecycle ViewModel SavedState Integration :
SavedStateViewModelFactory
is now the default factory used when usingby viewModels()
, theViewModelProvider
constructor, orViewModelProviders.of()
with aComponentActivity
or its subclasses.
Version 1.1.0-rc03
4 دسامبر 2019
androidx.activity:activity:1.1.0-rc03
and androidx.activity:activity-ktx:1.1.0-rc03
are released. Version 1.1.0-rc03 contains these commits .
Dependency changes
- Activity now depends on Lifecycle
2.2.0-rc03
and Lifecycle ViewModel SavedState1.0.0-rc03
.
Version 1.1.0-rc02
7 نوامبر 2019
androidx.activity:activity:1.1.0-rc02
and androidx.activity:activity-ktx:1.1.0-rc02
are released. Version 1.1.0-rc02 contains these commits .
Dependency changes
- Activity now depends on lifecycle
2.2.0-rc02
.
Version 1.1.0-rc01
23 اکتبر 2019
androidx.activity:activity:1.1.0-rc01
and androidx.activity:activity-ktx:1.1.0-rc01
are released with no changes from 1.1.0-beta01
. Version 1.1.0-rc01 contains these commits .
Version 1.1.0-beta01
9 اکتبر 2019
androidx.activity:activity:1.1.0-beta01
and androidx.activity:activity-ktx:1.1.0-beta01
are released. Version 1.1.0-beta01 contains these commits .
Dependency changes
- Activity now depends on SavedState 1.0.0 stable.
Version 1.1.0-alpha03
5 سپتامبر 2019
androidx.activity:activity:1.1.0-alpha03
and androidx.activity:activity-ktx:1.1.0-alpha03
are released. The commits included in this version can be found here .
ویژگی های جدید
- Activity now depends on Core 1.1.0 stable.
رفع اشکال
- Activity now depends on Lifecycle
2.2.0-alpha04
.
Version 1.1.0-alpha02
7 آگوست 2019
androidx.activity:activity:1.1.0-alpha02
and androidx.activity:activity-ktx:1.1.0-alpha02
are released. The commits included in this version can be found here .
ویژگی های جدید
-
SavedStateViewModelFactory
is now the default factory used when usingby viewModels()
, theViewModelProvider
constructor, orViewModelProviders.of()
with aComponentActivity
( b/135716331 )
Version 1.1.0-alpha01
2 جولای 2019
androidx.activity:activity:1.1.0-alpha01
and androidx.activity:activity-ktx:1.1.0-alpha01
are released. The commits included in this version can be found here .
ویژگی های جدید
-
activity
now depends on Lifecycle2.2.0-alpha02
. ( aosp/1007817 ) -
activity-ktx
added a dependency onlifecycle-runtime-ktx
; you no longer need to explicitly add it to your dependencies when usingactivity-ktx
or libraries that depend onactivity-ktx
(such asfragment-ktx
). ( aosp/987162 )
Version 1.0.0
Version 1.0.0
5 سپتامبر 2019
androidx.activity:activity:1.0.0
and androidx.activity:activity-ktx:1.0.0
are released. The commits included in this version can be found here .
Major Features of 1.0.0
- ComponentActivity :
ComponentActivity
serves as the new base class forFragmentActivity
in Fragment1.1.0
and, by extension,AppCompatActivity
in AppCompat1.1.0
. - activity-ktx : The
activity-ktx
module includes aby viewModels
Kotlin property extension for accessing ViewModels. This module is automatically included when you includefragment-ktx
from Fragment1.1.0
. - OnBackPressedDispatcher : As a composable alternative to overriding
onBackPressed()
, you can now register aOnBackPressedCallback
from anyLifecycleOwner
(such as a fragment) to intercept system back button events. A lambda with receiver versionaddCallback
has been added toactivity-ktx
. See Provide custom back navigation documentation for more details. - onRetainCustomNonConfigurationInstance deprecation : the
onRetainCustomNonConfigurationInstance()
and the relatedgetLastCustomNonConfigurationInstance()
APIs have been deprecated. It is strongly recommended to use ViewModels to store non-configuration state as they offer a composable solution suitable for anyViewModelStoreOwner
that makes the ownership of the retained objects clear and provides anonCleared()
callback for cleaning up resources when the activity is finally destroyed.
Version 1.0.0-rc01
2 جولای 2019
androidx.activity:activity:1.0.0-rc01
and androidx.activity:activity-ktx:1.0.0-rc01
are released with no changes from 1.0.0-beta01
. The commits included in this version can be found here .
Version 1.0.0-beta01
5 ژوئن 2019
androidx.activity::activity:1.0.0-beta01
and androidx.activity:activity-ktx:1.0.0-beta01
are released with no changes from 1.0.0-alpha08
. The commits included in this version can be found here .
Version 1.0.0-alpha08
7 مه 2019
androidx.activity:activity:1.0.0-alpha08
and androidx.activity:activity-ktx:1.0.0-alpha08
are released. The commits included in this version can be found here .
API changes
- Breaking change: The previously deprecated
addOnBackPressedCallback
andremoveOnBackPressedCallback
methods onComponentActivity
have been removed. aosp/953857 - The
setEnabled()
andisEnabled()
methods ofOnBackPressedCallback
are now final. b/131416833 - The
remove()
method ofOnBackPressedCallback
is now final. aosp/952720 -
OnBackPressedDispatcher
now has public constructors, allowing you to construct your own instances for testing, etc. aosp/953431 -
onBackPressed()
forComponentActivity
is now explicitly marked as@MainThread
aosp/952721
رفع اشکال
- Fixed a
ConcurrentModificationException
when callingremove()
from within thehandleOnBackPressed()
method of aOnBackPressedCalback
that was added with aLifecycleOwner
. b/131765095
Version 1.0.0-alpha07
April 25th, 2019
androidx.activity:activity:1.0.0-alpha07
and androidx.activity:activity-ktx:1.0.0-alpha07
are released. The commits included in this version can be found here .
API changes
This release makes significant changes to the handling of the onBackPressed()
. See the updated custom back documentation for more details.
- The methods for
OnBackPressedCallback
andOnBackPressedDispatcher
have been marked as@MainThread
. ( aosp/943813 ) - The
handleOnBackPressed()
method no longer returns aboolean
. Instead,OnBackPressedCallback
is now an abstract class that can be enabled or disabled - only when the newisEnabled()
method returns true willhandleOnBackPressed()
be called, in which you must handle the back button. ( aosp/944518 ) - The
addCallback
methods ofOnBackPressedDispatcher
no longer return aCancellable
instance.OnBackPressedCallback
now contain aremove()
method that fulfill this functionality, allowing you to callremove()
duringhandleOnBackPressed()
. ( aosp/944519 ) ( aosp/946316 ) -
activity-ktx
now contains a receiver scoped callback foraddCallback
that accepts a lamdba that implementshandleOnBackPressed()
and has access toisEnabled
andremove()
( aosp/944520 )
Version 1.0.0-alpha06
3 آوریل 2019
androidx.activity:activity:1.0.0-alpha06
and androidx.activity:activity-ktx:1.0.0-alpha06
are released. The commits included in this version can be found here .
API changes
- ComponentActivity now contain a second constructor that takes a
@LayoutRes int
, which replaces the previous behavior of annotating your AppCompatActivity class with@ContentView
. This approach works in both app and library modules. ( b/128352521 ) - The
OnBackPressedCallback
related APIs on ComponentActivity have been deprecated in favor of the newOnBackPressedDispatcher
, retrievable viagetOnBackPressedDispatcher()
. ( aosp/922523 ) - Methods to add a new
OnBackPressedCallback
to theOnBackPressedDispatcher
now return aCancellable
object, allowing removal of the callback without requiring an explicit reference to theOnBackPressedDispatcher
. ( aosp/922523 ) - Adding a
OnBackPressedCallback
with an associatedLifecycleOwner
now results in adding and removing theOnBackPressedCallback
as the Lifecycle is started and stopped, respectively. ( aosp/922523 )
Version 1.0.0-alpha05
13 مارس 2019
androidx.activity:activity:1.0.0-alpha05
and androidx.activity:activity-ktx:1.0.0-alpha05
are released. The full list of commits included in this release can be found here .
ویژگی های جدید
-
@ContentView
annotation lookups are now cached ( b/123709449 )
Version 1.0.0-alpha04
30 ژانویه 2019
androidx.activity:activity 1.0.0-alpha04
and androidx.activity:activity-ktx 1.0.0-alpha04
are released.
ویژگی های جدید
- Added support for the
@ContentView
class annotation that allows you to indicate which layout XML file should be inflated as an alternative to usingsetContentView()
. ( aosp/837619 )
API changes
- Added a note that
getViewModelStore()
should not be overridden and will be made final in a future release. Please file a feature request if you are currently overriding this method. ( aosp/837619 )
رفع اشکال
- The
activity
module now depends on version 2.1.0-alpha02 of ViewModel to match theactivity-ktx
module's dependency.
Version 1.0.0-alpha03
17 دسامبر 2018
androidx.activity 1.0.0-alpha03
is released.
ویژگی های جدید
- ComponentActivity now implements
BundleSavedStateRegistryOwner
and depends on the newly released SavedState library [ aosp/815133 ] - ComponentActivity now works around an Android framework bug that would cause InputMethodManager to leak the last focused view [ b/37122102 ]
Version 1.0.0-alpha02
3 دسامبر 2018
API changes
- Added a note that
getLifecycle()
should not be overridden and will be madefinal
in a future release. Please file a feature request if you are currently overriding this method. ( aosp/815834 )
Version 1.0.0-alpha01
5 نوامبر 2018
androidx.activity 1.0.0-alpha01
introduces ComponentActivity
, a new base class of the existing FragmentActivity
and AppCompatActivity
.
ویژگی های جدید
- You can now register an
OnBackPressedCallback
viaaddOnBackPressedCallback
to receiveonBackPressed()
callbacks without needing to override the method in your activity. - Added a new
by viewModels()
Kotlin property delegate for retrievingViewModel
s from aComponentActivity
. - Pending input events (such as clicks) are now canceled in
onStop()
.
API changes
- The implementation of
LifecycleOwner
andViewModelStoreOwner
have been moved fromFragmentActivity
toComponentActivity
. -
onRetainCustomNonConfigurationInstance
has been deprecated. Use aViewModel
for storing objects that need to survive configuration changes.