最新消息:20210917 已从crifan.com换到crifan.org

【未解决】Android项目rcsjta的子项目api_cnx编译报错:android.app中的ProgressDialog已过时

Android crifan 693浏览 0评论
折腾:
【未解决】Android Studio中用PreferenceFragmentCompat实现rcsjta的tts的参数设置页面
期间,结果由于把
RCS/rcsjta/samples/api/tts/build.gradle
    implementation 'com.android.support:support-v4:25.0.1'
改为了:
    implementation 'com.android.support:preference-v7:26.+'
导致又出现新警告
rcsjta/libs/api_cnx/src/main/java/com/gsma/rcs/api/connection/utils/RcsListActivity.java:166: 警告: [deprecation] android.app中的ProgressDialog已过时
    public ProgressDialog showProgressDialog(String msg) {
           ^
代码是:
src/main/java/com/gsma/rcs/api/connection/utils/RcsListActivity.java
@Override
public ProgressDialog showProgressDialog(String msg) {
    return DialogUtil.showProgressDialog(this, msg);
}
android.app中的ProgressDialog已过时
android.app.progressdialog deprecated
ProgressDialog过时(废弃)的替代方案_chamber_of_secrets的博客-CSDN博客_progressdialog过时
在API level 26 中,ProgressDialog被声明不赞成使用,应使用的替代方法是ProgressBar
Android Studio编译提示警告xxx已过时_川峰的博客-CSDN博客_警告: [deprecation] android.app中的progressdialog已过时
android — 不推荐使用ProgressDialog。使用的替代方法是什么?
https://www.it-swarm.dev/zh/android/不推荐使用progressdialog%E3%80%82使用的替代方法是什么?/833164383/
android – ProgressDialog is deprecated.What is the alternate one to use? – Stack Overflow
此处修改起来很麻烦的样子啊
因为此处代码:showProgressDialog 被多处调用了:
且调用地方是
src/com/gsma/rcs/ri/extension/messaging/MessagingSessionView.java
private void showProgressDialog() {
    mProgressDialog = showProgressDialog(getString(R.string.label_command_in_progress));
    mProgressDialog.setOnCancelListener(new OnCancelListener() {
        public void onCancel(DialogInterface dialog) {
            Toast.makeText(MessagingSessionView.this,
                    getString(R.string.label_session_canceled), Toast.LENGTH_SHORT).show();
            quitSession();
        }
    });
}


private void hideProgressDialog() {
    if (mProgressDialog != null && mProgressDialog.isShowing()) {
        mProgressDialog.dismiss();
        mProgressDialog = null;
    }
}
还继续用到了mProgressDialog
android – ProgressDialog is deprecated – Stack Overflow
android – As ProgressDialog is deprecated now, how to set message through progressBar? – Stack Overflow
android – ProgressDialog is now deprecated – Stack Overflow
此处,除了要实现之前的ProgressDialog
还要实现对应的setOnCancelListener之类的逻辑才可以。。
先去搜索:
Android ProgressBar setOnCancelListener
ProgressDialog  |  Android 开发者  |  Android Developers
ProgressBar  |  Android 开发者  |  Android Developers
https://developer.android.com/reference/android/widget/ProgressBar
另外代码中
src/com/gsma/rcs/ri/extension/messaging/MessagingSessionView.java
private void hideProgressDialog() {
    if (mProgressDialog != null && mProgressDialog.isShowing()) {
        mProgressDialog.dismiss();
        mProgressDialog = null;
    }
}
isShowing
找了下,发现是:
android.app.Dialog
Dialog  |  Android 开发者  |  Android Developers
如果换成ProgressBar
估计还好办
可以改为:
参考
https://stackoverflow.com/questions/45373007/progressdialog-is-deprecated-what-is-the-alternate-one-to-use
的setVisibility
以为有visibility相关的api
ProgressBar  |  Android 开发者  |  Android Developers
竟然找不到
android ProgressBar visibility
Changing visibility of Android ProgressBar – Stack Overflow
            if (someProgressBar.getVisibility() == View.GONE) {
                someProgressBar.setVisibility(View.VISIBLE);
            } else {
                someProgressBar.setVisibility(View.GONE);
            }
所以对于此处的 ProgressBar 连setVisibility 都没有
不过突然想起来了:
估计是父类有
去找找
View  |  Android 开发者  |  Android Developers
果然是的:
除了:
void
setVisibility(int visibility)
Set the visibility state of this view.
也有getVisibility:
int
getVisibility()
Returns the visibility status for this view.

getVisibility


Added in API level 1
public int getVisibility ()
Returns the visibility status for this view.
Related XML Attributes:
android:visibility
Returns
int
One of VISIBLE, INVISIBLE, or GONE. Value is VISIBLE, INVISIBLE, or GONE
总之:
之前的ProgressDialog的isShowing
可以改为ProgressBar的getVisibility是否是View.GONE(或INVISIBLE?)
但是对于setOnCancelListener去找找是否有相关替代的
android setOnCancelListener
看来是针对于Dialog才有的接口
而对于ProgressBar 没有cancel相关逻辑和接口
此处暂且不继续了,先回头看看
【未解决】rcsjta的RI启动报错:Cannot connect service API Failed to get result for com.gsma.services.rcs.action.GET_SERVICE_STARTING_STATE
能否解决掉。
如果解决掉。就不用继续花时间解决api兼容性问题了。

转载请注明:在路上 » 【未解决】Android项目rcsjta的子项目api_cnx编译报错:android.app中的ProgressDialog已过时

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
93 queries in 0.183 seconds, using 23.39MB memory