29 Haziran 2016 Çarşamba

SoundPool Sınıfı

constructor
Şöyle yaparız.
SoundPool soundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 100);
load metodu
Şöyle yaparız.
soundId = soundPool.load(Environment.getExternalStorageDirectory()
                         + "/sample.wav", 1);
play metodu
Şöyle yaparız.
float playbackSpeed=1.5f; 
soundId = ...;
float volume = ...
soundPool.play(soundId, volume, volume, 1, 0, playbackSpeed);
setOnLoadComplate metodu
Şöyle yaparız.
final float volume = ...;

soundPool.setOnLoadCompleteListener(new OnLoadCompleteListener()
{
  @Override
  public void onLoadComplete(SoundPool arg0, int arg1, int arg2)
  {
    soundPool.play(soundId, volume, volume, 1, 0, playbackSpeed);
  }
});

AudioRecord Sınıfı

constructor
Şöyle yaparız.
İlk parametre audioSource,
ikinci parametre sampleRate,
üçüncü parametre channelConfig,
dördüncü parametre audioFormat
beşinci parametre bufferSizeInBytes
anlamına gelir.
AudioRecord recorder = new AudioRecord(MediaRecorder.AudioSource.MIC, ..., AudioFormat.CHANNEL_IN_MONO, ..., 160);
Şöyle yaparız.
int sampleRate = ...;
int bufferSize = ...;
AudioRecord recorder
= new AudioRecord( AudioSource.VOICE_RECOGNITION, sampleRate, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, bufferSize);

getMinBufferSize metodu
Şöyle yaparız.
int bufferSize = AudioRecord.getMinBufferSize(sampleRate,
  AudioFormat.CHANNEL_IN_MONO,
  AudioFormat.ENCODING_PCM_16BIT);
getState metodu
Şöyle yaparız.
if (recorder.getState() == AudioRecord.STATE_UNINITIALIZED) {
  recorder.release();
  ...
}
read metodu
Şöyle yaparız.
short[] wavbuffer = new short[160];
int totalRead = 0, dataRead;
while(totalRead < 160)
{
  dataRead = recorder.read(wavbuffer, totalRead, 160 - totalRead);  totalRead = totalRead + dataRead;
}
release metodu
Şöyle yaparız.
recorder.release();
startRecording metodu
Şöyle yaparız.
recorder.startRecording();





28 Haziran 2016 Salı

Filter Sınıfı

Giriş
Şu satırı dahil ederiz.
import android.widget.Filter;
performFiltering metodu
İmzası şöyledir.
@Override
protected FilterResults performFiltering(CharSequence constraint);
publishResults metodu
İmzası şöyledir.
@Override
protected void publishResults(CharSequence constraint,
                              FilterResults results);

GoogleApiClient Sınıfı

GoogleApiClient.Builder Sınıfı
addConnectionCallbacks metodu
 GoogleApiClient.ConnectionCallbacks arayüzünü gerçekleştiren bir nesne ekler.Şöyle yaparız.
googleApiClient.addConnectionCallbacks (this);
build metodu
GoogleApiClient nesnesi döner. Şöyle yaparız.
GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this)
  .addConnectionCallbacks(this)
  .addOnConnectionFailedListener(this)
  .addApi(LocationServices.API)
  .addApi(Places.GEO_DATA_API)
  .addApi(Places.PLACE_DETECTION_API)
  .enableAutoManage(this, this)
  .build();
GoogleApiClient.OnConnectionFailedListener Arayüzü
onConnectionFailed metodu
İskeleti şöyledir.
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
  ...
}

27 Haziran 2016 Pazartesi

GCMBaseIntentService Sınıfı

Giriş
Şu satırı dahil ederiz.
import com.google.android.gms.GCMBaseIntentService;
onRegistered metodu
Şöyle yaparız.
@Override
protected void onRegistered(final Context context, String registrationId) {
   Log.i(TAG, "Device registered: regId = " + registrationId);
}
registrationId şuna benzer bir şeydir.
|ID|1|: dSyzRPhBqSg:

23 Haziran 2016 Perşembe

Parcel Sınıfı

dataSize metodu
Şöyle yaparız.
int size = parcel.dataSize ()
obtain metodu
Şöyle yaparız.
Parcel parcel = Parcel.obtain ();
readInt metodu
Şöyle yaparız.
int number = parcel.readInt ();
readLong metodu
Şöyle yaparız.
long number = parcel.readLong ();
readString metodu
Şöyle yaparız.
String number = parcel.readString ();
readStringArray metodu
Şöyle yaparız.
String id;
String name;
String grade;

String[] data = new String[3];
parcel.readStringArray (data);
id    = data[0];
name  = data[1];
grade = data[2];
recycle metodu
Şöyle yaparız.
parcel.recycle();
writeInt metodu
Şöyle yaparız.
int number = ...;
parcel.writeInt (nummber);
writeLong metodu
Şöyle yaparız.
long number = ...;
parcel.writeLong (nummber);
writeParcelable metodu
Şöyle yaparız. Eğer yazılan veri 1 MB'den büyük olmamalıdır
Intent testIntent = ...;
parcel.writeParcelable (testIntent,0);
writeString metodu
Şöyle yaparız.
String str = ...;
parcel.writeString (str);
writeStringArray metodu
Şöyle yaparız.
String id = ...;
String name = ...;String grade = ...;
parcel.writeStringArray (new String[] {id,
                                       name,
                                       grade});




20 Haziran 2016 Pazartesi

Google-Maps Marker Sınıfı

remove metodu
Marker eklendikten sonra saklanmalıdır.
Marker marker= map.addMarker(new MarkerOptions().position(latLng).title("Title"));
Daha sonra şöyle silinir.
markerName.remove();

showInfoWindow metodu
Açıklamsı şöyle
An info window allows you to display information to the user when they tap on a marker. Only one info window is displayed at a time. If a user clicks on another marker, the current info window will be hidden and the new info window will be displayed
Yani şu kod ilk pencereyi kapatır ve yenisini açar.
MarkerOptions marker = new MarkerOptions().position(...).title("...");
Marker m1 = googleMap.addMarker(marker);
m1.showInfoWindow();

MarkerOptions marker2 = new MarkerOptions().position(...).title("...");
Marker m2=googleMap.addMarker(marker2);
m2.showInfoWindow();