The code is using deprecated Android APIs, the following warning logs appear when compiling the app:
> Task :compileUnbrandedDebugJavaWithJavac
/home/mokhtar/app/medic/cht-android/src/main/java/org/medicmobile/webapp/mobile/util/Vibrator.java:43: warning: [deprecation] VIBRATOR_SERVICE in Context has been deprecated
return (android.os.Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
^
/home/mokhtar/app/medic/cht-android/src/main/java/org/medicmobile/webapp/mobile/util/Vibrator.java:54: warning: [deprecation] vibrate(long) in Vibrator has been deprecated
getVibrator().vibrate(milliseconds);
^
/home/mokhtar/app/medic/cht-android/src/main/java/org/medicmobile/webapp/mobile/SettingsDialogActivity.java:124: warning: [deprecation] onBackPressed() in ComponentActivity has been deprecated
@Override public void onBackPressed() {
^
/home/mokhtar/app/medic/cht-android/src/main/java/org/medicmobile/webapp/mobile/SettingsDialogActivity.java:136: warning: [deprecation] onBackPressed() in ComponentActivity has been deprecated
super.onBackPressed();
^
/home/mokhtar/app/medic/cht-android/src/main/java/org/medicmobile/webapp/mobile/EmbeddedBrowserActivity.java:103: warning: [deprecation] getFragmentManager() in Activity has been deprecated
getFragmentManager()
^
/home/mokhtar/app/medic/cht-android/src/main/java/org/medicmobile/webapp/mobile/EmbeddedBrowserActivity.java:104: warning: [deprecation] beginTransaction() in FragmentManager has been deprecated
.beginTransaction()
^
/home/mokhtar/app/medic/cht-android/src/main/java/org/medicmobile/webapp/mobile/EmbeddedBrowserActivity.java:105: warning: [deprecation] add(Fragment,String) in FragmentTransaction has been deprecated
.add(new OpenSettingsDialogFragment(container), OpenSettingsDialogFragment.class.getName())
^
/home/mokhtar/app/medic/cht-android/src/main/java/org/medicmobile/webapp/mobile/EmbeddedBrowserActivity.java:106: warning: [deprecation] commit() in FragmentTransaction has been deprecated
.commit();
^
/home/mokhtar/app/medic/cht-android/src/main/java/org/medicmobile/webapp/mobile/EmbeddedBrowserActivity.java:171: warning: [deprecation] onBackPressed() in Activity has been deprecated
@Override public void onBackPressed() {
^
/home/mokhtar/app/medic/cht-android/src/main/java/org/medicmobile/webapp/mobile/ChtExternalApp.java:265: warning: [deprecation] get(String) in BaseBundle has been deprecated
Object value = bundle.get(key);
^
/home/mokhtar/app/medic/cht-android/src/main/java/org/medicmobile/webapp/mobile/SmsSender.java:354: warning: [deprecation] getDefault() in SmsManager has been deprecated
return SmsManager.getDefault();
^
/home/mokhtar/app/medic/cht-android/src/main/java/org/medicmobile/webapp/mobile/SmsSender.java:368: warning: [deprecation] createFromPdu(byte[]) in SmsMessage has been deprecated
return SmsMessage.createFromPdu(intent.getByteArrayExtra("pdu"));
^
/home/mokhtar/app/medic/cht-android/src/main/java/org/medicmobile/webapp/mobile/UrlHandler.java:48: warning: [deprecation] onReceivedError(WebView,int,String,String) in WebViewClient has been deprecated
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
^
/home/mokhtar/app/medic/cht-android/src/main/java/org/medicmobile/webapp/mobile/UrlHandler.java:52: warning: [deprecation] onReceivedError(WebView,int,String,String) in WebViewClient has been deprecated
super.onReceivedError(view, errorCode, description, failingUrl);
^
/home/mokhtar/app/medic/cht-android/src/main/java/org/medicmobile/webapp/mobile/MedicAndroidJavascript.java:229: warning: [deprecation] versionCode in PackageInfo has been deprecated
long versionCode = Build.VERSION.SDK_INT < Build.VERSION_CODES.P ? (long)packageInfo.versionCode : packageInfo.getLongVersionCode();
^
/home/mokhtar/app/medic/cht-android/src/main/java/org/medicmobile/webapp/mobile/MedicAndroidJavascript.java:281: warning: [deprecation] NetworkInfo in android.net has been deprecated
NetworkInfo netInfo = connectivityManager.getActiveNetworkInfo();
^
/home/mokhtar/app/medic/cht-android/src/main/java/org/medicmobile/webapp/mobile/MedicAndroidJavascript.java:281: warning: [deprecation] getActiveNetworkInfo() in ConnectivityManager has been deprecated
NetworkInfo netInfo = connectivityManager.getActiveNetworkInfo();
^
/home/mokhtar/app/medic/cht-android/src/main/java/org/medicmobile/webapp/mobile/MedicAndroidJavascript.java:328: warning: [deprecation] Theme_Holo_Dialog in style has been deprecated
DatePickerDialog dialog = new DatePickerDialog(parent, android.R.style.Theme_Holo_Dialog, listener,
^
/home/mokhtar/app/medic/cht-android/src/main/java/org/medicmobile/webapp/mobile/MedicAndroidJavascript.java:332: warning: [deprecation] setCalendarViewShown(boolean) in DatePicker has been deprecated
picker.setCalendarViewShown(false);
^
/home/mokhtar/app/medic/cht-android/src/main/java/org/medicmobile/webapp/mobile/MedicAndroidJavascript.java:333: warning: [deprecation] setSpinnersShown(boolean) in DatePicker has been deprecated
picker.setSpinnersShown(true);
^
/home/mokhtar/app/medic/cht-android/src/main/java/org/medicmobile/webapp/mobile/ClosableAppActivity.java:31: warning: [deprecation] onBackPressed() in Activity has been deprecated
@Override public void onBackPressed() {
^
/home/mokhtar/app/medic/cht-android/src/main/java/org/medicmobile/webapp/mobile/OpenSettingsDialogFragment.java:17: warning: [deprecation] Fragment in android.app has been deprecated
public class OpenSettingsDialogFragment extends Fragment {
^
/home/mokhtar/app/medic/cht-android/src/main/java/org/medicmobile/webapp/mobile/OpenSettingsDialogFragment.java:35: warning: [deprecation] Fragment() in Fragment has been deprecated
public OpenSettingsDialogFragment(View view) {
^
/home/mokhtar/app/medic/cht-android/src/main/java/org/medicmobile/webapp/mobile/OpenSettingsDialogFragment.java:40: warning: [deprecation] onCreate(Bundle) in Fragment has been deprecated
public void onCreate(@Nullable Bundle savedInstanceState) {
^
/home/mokhtar/app/medic/cht-android/src/main/java/org/medicmobile/webapp/mobile/OpenSettingsDialogFragment.java:41: warning: [deprecation] onCreate(Bundle) in Fragment has been deprecated
super.onCreate(savedInstanceState);
^
/home/mokhtar/app/medic/cht-android/src/main/java/org/medicmobile/webapp/mobile/OpenSettingsDialogFragment.java:81: warning: [deprecation] getActivity() in Fragment has been deprecated
Activity activity = getActivity();
^
/home/mokhtar/app/medic/cht-android/src/main/java/org/medicmobile/webapp/mobile/OpenSettingsDialogFragment.java:82: warning: [deprecation] startActivity(Intent) in Fragment has been deprecated
startActivity(new Intent(activity, SettingsDialogActivity.class));
^
Some aren't relevant since the code is there to support older Android APIs while using the newer APIs when targeting those versions like the ones in src/main/java/org/medicmobile/webapp/mobile/util/Vibrator.java. But most of the others are relevant and we should probably do something about them.
Describe the improvement you'd like
Shut Gradle/Javac about the deprecated APIs we intentionally support and provide alternatives for more recent Android versions
Provide supported alternatives for the deprecated APIs we rely on
Describe the issue
The code is using deprecated Android APIs, the following warning logs appear when compiling the app:
Some aren't relevant since the code is there to support older Android APIs while using the newer APIs when targeting those versions like the ones in
src/main/java/org/medicmobile/webapp/mobile/util/Vibrator.java
. But most of the others are relevant and we should probably do something about them.Describe the improvement you'd like
Describe alternatives you've considered N/A