Why certain code has shown as strike in Android?
Please see the figure. Here Conta开发者_StackOverflow社区cts has stroked. Why so?
Because It is deprecated in your version of Android API.
It means that class is deprecated.
A deprecated class is a class that has been superseded by a new class that has supposedly better and improved functionality. It is not recommended to use deprecated classes although it may be necessary to support all Android devices like those running SDK 1.5.
If you then go into the online API for the deprecated class, in your instance:
http://developer.android.com/reference/android/provider/Contacts.html
It explains it is deprecated and if your lucky says what class you should use instead:
This class is deprecated. The APIs have been superseded by ContactsContract. The newer APIs allow access multiple accounts and support aggregation of similar contacts. These APIs continue to work but will only return data for the first Google account created, which matches the original behavior
When reading the documentation note the original API Contacts is from API level 1. Android 1.0
and the new API ContactsContract is from API level 5. Android 2.0
Therefore you will want to continue using your deprecated class if you want to support older devices.
Its because of its deprecated(removed) from the current api.
That means that the particular code that you are using has been deprecated in Android SDK.
look around, there must be something new at its place.
精彩评论