During the test of the app, the activity called the Isdestroyed () method and reported a java.lang.NoSuchMethodError error.
Own mobile Mi 2S, version 4.1.1.
In fact, the reason is isdestroyed () This method is introduced in 4.2, so the 4.1.1 on the increase in this method will be an error.
Need to make a version of the judgment, Build.VERSION.SDK_INT < 17.
So the question is, how do you judge the version introduced by a function? From the Android developer site, you'll find
Actually want to see in the source code, but there is no description in the source code.
Https://developer.android.com/reference/android/app/Activity.html#isDestroyed ()
Summary: There are several points to note when calling a method:
(1) Note the API version number introduced by this method;
(2) It is best not to call @deprecated tag classes and methods, as the third party may delete the source code that is @deprecated tagged;
(3) Mark @hide is also best not to call, remember when beginners, quite a lot of people use the way of reflection to obtain private data and call the appropriate method, at that time, it was quite a research spirit;
Focus: When you are now standing in the perspective of maintenance, a lot of users in your products, a variety of different mobile phones, models appear, resulting in different bugs. It makes sense to follow the above rules.
Attach some of the better articles:
Spiritual Brother speaks Crash (i): Unsatisfiedlinkerror
Spiritual Brother speaks Crash (ii): Java.lang.NoSuchMethodError
Little Lori said crash (a): Unrecognized selector sent to instance xxxx
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Activity calls the Isdestroyed () method to report that the Java.lang.NoSuchMethodError