N
N
nikita0710032020-05-24 00:45:37
Android
nikita071003, 2020-05-24 00:45:37

Can't get android version version, why?

I'm trying to display the version in the logs

Log.d("=--=-=-=", getText(android.os.Build.VERSION.SDK_INT).toString());


The application crashes

If I do this algorithm:

if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
                    Toast.makeText(getApplicationContext(), "Меньше", Toast.LENGTH_SHORT);
                }
                else{
                    Toast.makeText(getApplicationContext(), "Больше", Toast.LENGTH_SHORT);
                }


Then Android Studio just skips it.

How can I get the Android version or what's wrong here?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Vodakov, 2020-05-25
@WaterSmith

Change

Log.d("=--=-=-=", getText(android.os.Build.VERSION.SDK_INT).toString());

On the
Log.d("=--=-=-=", Integer.toString(android.os.Build.VERSION.SDK_INT));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question