27 Temmuz 2016 Çarşamba

Geocoder Sınıfı

Giriş
Address nesnesi elde etmek için kullanılır.

Constructor - context
Context nesnesi ile kurulur.
Context cxt = ...;
Geocoder coder = new Geocoder(cxt);
Şöyle yaparız.
Geocoder geocoder = new Geocoder(getActivity());
Constructor - context + locale
Şöyle yaparız.
Geocoder geocoder = new Geocoder(getActivity(), Locale.getDefault());
Şöyle yaparız.
Geocoder geocoder= new Geocoder(this, Locale.ENGLISH);
getFromLocationName
Elimizde bir adres olsun.
String address = ...
List<Address> tipinde bir sonuç döner. Şöyle yaparız.
List<Address> list = geocoder.getFromLocationName(address, 1);
Sonucun dolu olduğunu kontrol etmek gerekir.
if (list.size() > 0) {...}
getFromLocation metodu
Enlem ve boylama göre sonuç döner. Sonuç listesini sınırlayabiliriz. Şöyle yaparız.
int maxAddress = ...;
double longitude = ...;
double latitude = ...;
List<Address> addressList = geocoder.getFromLocation(latitude, longitude,
  maxAddress);
1 tane sonuç dönmesini istiyoruz.
double latitude = ...; double longitude = ...;
List<Address> list = geocoder.getFromLocation(latitude, longitude, 1);
Sonucun dolu olduğunu kontrol etmek gerekir.
if (list != null && list.size() > 0) {...}



25 Temmuz 2016 Pazartesi

ExifInterface Sınıfı

constructor 
Şöyle yaparız.
String filePath = ...;
ExifInterface exif = new ExifInterface(filePath); //API Level 5
getAttribute metodu
Şöyle yaparız.
String orientation = exif.getAttribute (ExifInterface.TAG_ORIENTATION);
getAttributeInt metodu
Şöyle yaparız.
int orientation = exif.getAttributeInt(
            ExifInterface.TAG_ORIENTATION, 0);



BitmapShader Sınıfı

constructor
Şöyle yaparız.
Bitmap bitmap = ...;
BitmapShader shader = 
 new BitmapShader(bitmap, Shader.TileMode.REPEAT, Shader.TileMode.CLAMP);



NfcManager Sınıfı

constructor
Şöyle yaparız.
NfcManager manager = (NfcManager)context.getSystemService(Context.NFC_SERVICE);
getDefaultAdapter metodu
Şöyle yaparız.
NfcAdapter adapter = manager.getDefaultAdapter();

24 Temmuz 2016 Pazar

ListActivity Sınıfı

setAdapter metodu
Şöyle yaparız.
public class MyActivity extends ListActivity implements OnClickListener {
  ArrayList<Bookmark> values
  ... 


  @Override
  protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.bookmarks);
    
    //instantiate custom adapter
    MyCustomAdapter adapter = new MyCustomAdapter(values, this);

    setAdapter(adapter);
}



19 Temmuz 2016 Salı

LayoutInflater Sınıfı

Giriş
Şu satırı dahil ederiz.
import android.view.LayoutInflater;
Bu nesne Contex nesnesi kullanılarak elde edilir.

constructor
Şöyle yaparız.
LayoutInflater inflater = (LayoutInflater) context.getSystemService(
 Context.LAYOUT_INFLATER_SERVICE);
inflate metodu
Şöyle yaparız.
View v = inflater.inflate (R.layout.activity_main, parent);
parent null verilebilir. Şöyle yaparız.
View v = inflater.inflate (R.layout.activity_main, null);

ValueAnimator Sınıfı

Giriş
CounDownTimer sınıfıyla benzeşir.

constructor
Şöyle yaparız.
float initialValue = ...; float finalValue = ...;
ValueAnimator va = ValueAnimator.ofFloat (initialValue, finalValue);
addUpdateListener metodu
Şöyle yaparız.
va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
  @Override
  public void onAnimationUpdate(ValueAnimator valueAnimator) {
    ...
  }
});
setDuration metodu
Şöyle yaparız.
va.setDuration(1500);
start metodu
Şöyle yaparız.
va.start();