You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a number of Fragments in the superapp, we use setHasOptionsMenu in order to declare that a given Fragment would like to participate in populating the options menu by receiving a call to onCreateOptionsMenu. However, the setHasOptionsMenu API is deprecated and its use produces a number of deprecation warnings when we build the superapp. Therefore, in an effort to clean the superapp from deprecation warnings, we want to replace this API with its modern counterpart.
Recommended Actions
The Android Developer documentation proposes that we use the addMenuProvider() API instead. This API function a member function of ComponentActivity. Here is the relevant code example that shows an example of how to use that API:
The addMenuProvider() API was introduced in version 1.4.0 of AndroidX Activity. In order to declare that version, I guessed that I should add the following line to the build.gradle of each module (e.g: debug, musicdao etc...):
But that doesn't correctly upgrade ComponentActivity so that it implements the addMenuProvider() function that we need. Let's take the debug module for example to show what's going on.
As you can see here, the DebugActivity inherits from the BaseActivity
As you can see here, the BaseActivity inherits from the AndroidX AppCompatActivity.
Through a series of inheritances (AppCompatActivity -> FragmentActivity -> ComponentActivity), we derive that DebugActivity inherits from ComponentActivity, therefore we should be able to use the desired addMenuProvider() member function of ComponentActivity.
However, when I trace back the code, I see that we're still using an outdated version of activity (version 1.2.0 instead of the desired 1.4.0) and I can't seem to update it through the build.gradle file.
I just found out that the latest version of the androidx.appcompat:appcompat dependency that contains the AppCompatActivity that we're using depends on androidx.activity:activity:1.1.0 which is lower than 1.4.0 where the new API was introduced. So, it seems that if we want to get rid of this deprecation warning, we must use a different Activity than AppCompatActivity.
Overview
This is part of #161.
In a number of Fragments in the superapp, we use
setHasOptionsMenu
in order to declare that a given Fragment would like to participate in populating the options menu by receiving a call toonCreateOptionsMenu
. However, thesetHasOptionsMenu
API is deprecated and its use produces a number of deprecation warnings when we build the superapp. Therefore, in an effort to clean the superapp from deprecation warnings, we want to replace this API with its modern counterpart.Recommended Actions
The Android Developer documentation proposes that we use the
addMenuProvider()
API instead. This API function a member function ofComponentActivity
. Here is the relevant code example that shows an example of how to use that API:The Problem
The
addMenuProvider()
API was introduced in version1.4.0
of AndroidX Activity. In order to declare that version, I guessed that I should add the following line to thebuild.gradle
of each module (e.g:debug
,musicdao
etc...):implementation 'androidx.activity:activity:1.4.0'
.But that doesn't correctly upgrade
ComponentActivity
so that it implements theaddMenuProvider()
function that we need. Let's take thedebug
module for example to show what's going on.DebugActivity
inherits from theBaseActivity
BaseActivity
inherits from the AndroidXAppCompatActivity
.AppCompatActivity
->FragmentActivity
->ComponentActivity
), we derive thatDebugActivity
inherits fromComponentActivity
, therefore we should be able to use the desiredaddMenuProvider()
member function ofComponentActivity
.However, when I trace back the code, I see that we're still using an outdated version of activity (version
1.2.0
instead of the desired1.4.0
) and I can't seem to update it through the build.gradle file.@InvictusRMC Any ideas?
CC @synctext
The text was updated successfully, but these errors were encountered: