What exactly does Android’s @hide annotation do?

What exactly does this do? It controls what is in the android.jar that you are compiling against. When you have, say, compileSdkVersion 19 in your build.gradle file, what is really happening is that $ANDROID_SDK/platforms/android-19/android.jar is being added to your compile-time classpath. That JAR is created as part of compiling Android itself. The Android framework classes … Read more

What is better: @SuppressLint or @TargetApi?

I have issues in my app regarding StrictMode and added the code snippet that basically disables the StrictModeHelper Please fix the networking bug. Which method is prefered ..or are they basically doing the same? @TargetApi and @SuppressLint have the same core effect: they suppress the Lint error. The difference is that with @TargetApi, you declare, … Read more

Compiler warning for function defined without prototype in scope?

If you need an option which works on both gcc and clang, your best bet is probably -Wmissing-prototypes. As indicated in the gcc documentation, this will trigger if a global function is defined and either: There was no previous declaration; or The previous declaration had no prototype. It does not complain if the previous declaration … Read more

Lint error “Do not treat position as fixed; only use immediately…”

The documentation of RecyclerView.Adapter.onBindViewHolder() states: Note that unlike ListView, RecyclerView will not call this method again if the position of the item changes in the data set unless the item itself is invalidated or the new position cannot be determined. For this reason, you should only use the position parameter while acquiring the related data … Read more

How to resolve “Missing PendingIntent mutability flag” lint warning in android api 30+?

You can set your pending intent as val updatedPendingIntent = PendingIntent.getActivity( applicationContext, NOTIFICATION_REQUEST_CODE, updatedIntent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT // setting the mutability flag ) According to the docs here: https://developer.android.com/about/versions/12/behavior-changes-12#pending-intent-mutability Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies … Read more

Visual Studio Code formatting for “{ }”

base on @Chris Drew’s answer Go Preferences -> Settings Search for C_Cpp.clang_format_fallbackStyle Click Edit, Copy to Settings Change from “Visual Studio” to “{ BasedOnStyle: Google, IndentWidth: 4 }” e.g. “C_Cpp.clang_format_fallbackStyle”: “{ BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 0}” btw ColumnLimit: 0 is helpful too, because google limit will break your code to next line when you … Read more