method added in API 17 works in lower API levels too

android

Solution

When Google say that something was introduced in API level 17, all they mean that it became publicly available and documented in API level 17.

The actual implementation might have been there since the first day of Android, but it was hidden from the developer using special annotations or just by using `private`.

Edit: Below is the actual method signature + documentation from the Gingerbread source code, showing the use of such anotation

/**
 * Like {@link #setText(CharSequence)}, except that it can disable filtering.
 *
 * @param filter If <code>false</code>, no filtering will be performed
 * as a result of this call.
 *
 * @hide Pending API council approval.
 */
 public void setText(CharSequence text, boolean filter)

Problem

The method `setText(CharSequence text, boolean filter)` of `AutoCompleteTextView` which was introduced in API 17, seems to be working in lower android versions too. I was expecting it to crash in 2.3 device with `NoSuchMethodError`, but it is just working fine. That's not really a problem, but I am just curious to know how it is working :) Here is my code - ``` <AutoCompleteTextView android:id="@+id/autoCompleteTextView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/textView1" android:textColor="@android:color/black" android:ems="10" android:text="AutoCompleteTextView" > <requestFocus /> </AutoCompleteTextView> ``` .... ``` import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.widget.AutoCompleteTextView; public class MainActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView1); //method introduced in API 17!! autoCompleteTextView.setText("Example text", false); } } ```

Original source