is close to front side of the phone. Unit: binary (close, not close) or cm Magnetometer Measures the strength of earth’s magnetic field Unit: tesla [T]
light. Used for calibrating screen brightness. Unit: Lux Thermometer Battery temperature and/or ambient temperature. Unit: °C Humidity Measures the relative ambient humidity. Unit: %
commonly portrait > landscape > portrait. Activity is destroyed, but you can prevent this: <activity android:name=".MyActivity" android:configChanges="orientation|screenSize" android:label="@string/app_name"> Downside: configuration specific layout won’t work (but you could override onConfigurationChanged(Configuration newConfig) in activity)
folder 3)reference local file in build.gradle dependencies { compile files('libs/something_local.jar') } Downsides: • time consuming • it is not recommended to host large binaries in code repository
Example: compile 'com.google.code.gson:gson:2.3.1' Downsides: • can't clean or first compile project without internet connection • when using unofficial dependency repo and repo goes down = problem
int resource, int textViewResourceId, T[] objects) ArrayAdapter(Context context, int resource, List<T> objects) ArrayAdapter(Context context, int resource, int textViewResourceId, List<T> objects)
as an anonymous class. private OnItemClickListener handler= new OnItemClickListener() { public void onItemClick(AdapterView parent, View v, int position, long id) { // Do something in response to the click } }; listView.setOnItemClickListener(handler);
of all (visible) children at once ArrayList<String> list = new ArrayList<>(); list.add(“first”); ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, list); ListView listView = (ListView) findViewById(R.id.listview); listView.setAdapter(adapter); //in some other callback list.add(“second”); listView.getAdapter().notifyDataSetChanged();
• Tighter integration of viewholder pattern (caching) • Better animation support Can use in older versions through support library: dependencies { compile 'com.android.support:recyclerview-v7:21.0.+' }
JSONObject jObj = new JSONObject(json); Person person = new Person(); person.name = jObj.getString("name"); person.surname = jObj.getString("surname"); person.phone = jObj.getInt("phone"); person.age = jObj.getInt("age"); JSONArray jArr = jObj.getJSONArray("cars"); for (int i=0; i < jArr.length(); i++) { JSONObject obj = jArr.getJSONObject(i); Car car = new Car(); car.manu………... }