31 Ekim 2016 Pazartesi

MediaCodec Sınıfı

Giriş
Şu satırı dahil ederiz.
import android.media.MediaCodec;
configure metodu - encoder
Şöyle yaparız.
MediaFormat mediaFormat = ...;
encoder.configure (mediaFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
configure metodu - decoder
Şöyle yaparız.
import android.view.Surface;
Surface surface = ...;
MediaFormat mediaFormat = ...;
decoder.configure (mediaFormat, surface, null, 0);
createDecoderByType metodu
Şöyle yaparız.
MediaCodec decoder = MediaCodec.createDecoderByType("video/avc");
createEncoderByType metodu
Şöyle yaparız.
MediaCodec encoder = MediaCodec.createEncoderByType ("video/avc");
getInputBuffers metodu
Şu satırı dahil ederiz.
import java.nio.ByteBuffer;
Şöyle yaparız.
ByteBuffer[] inputBuffers = decoder.getInputBuffers();
Şöyle yaparız.
ByteBuffer[] inputBuffers = encoder.getInputBuffers();
getOutputBuffers metodu
Şu satırı dahil ederiz.
import java.nio.ByteBuffer;
Şöyle yaparız.
ByteBuffer[] outputBuffers = encoder.getOutputBuffers();
release metodu
Şöyle yaparız.
encoder.release ();
decoder.release ();
start metodu
Şöyle yaparız.
encoder.start ();
decoder.start ();
stop metodu
Şöyle yaparız.
encoder.stop ();
decoder.stop ();


23 Ekim 2016 Pazar

DownloadManager.Request Sınıfı

Giriş
Şöyle kullanılır.
DownloadManager dm = ...;
DownloadManager.Request request = ...;
...
dm.enqueue (request);
constructor
Şöyle yaparız.
Uri downloadUri = ...;
DownloadManager.Request request = new DownloadManager.Request (downloadUri);
setAllowedNetworkTypes metodu
Şöyle yaparız.
request.setAllowedNetworkTypes(
  DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE);
setAllowedOverRoaming metodu
Şöyle yaparız.
request.setAllowedOverRoaming (false);
setDescription metodu
Şöyle yaparız.
request.setDescription("Downloading...");
setVisible metodu
Şöyle yaparız.
request.setVisibleInDownloadsUi (true)




DataSnapshot Sınıfı

getChildren metodu
Şöyle yaparız.
DataSnapshot dataSnapshot = ...;
ArrayList list = new ArrayList<String>();                

// Result will be holded Here
for (DataSnapshot dsp : dataSnapshot.getChildren()) {
  list.add(String.valueOf(dsp.geValue())); //add result into array list

}
getValue metodu
Eğer nesne Map ise şöyle yaparız.
DataSnapshot dataSnapshot = ...;

Map<String,Object> users = ((Map<String,Object>) dataSnapshot.getValue());
Eğer nesne String ise şöyle yaparız
String str =  String.valueOf (dataSnapshot.geValue());
getValue metodu - Class
Şöyle yaparız.
for (DataSnapshot dsp : dataSnapshot.getChildren()) {
  Foo foo = dsp.getValue (Foo.class);
  ...
}

5 Ekim 2016 Çarşamba

Firebase Sınıfı

Giriş
3.0 SDK ile bu sınıf yerini DatabaseReference sınıfına bıraktı.

constructor
URL örüntüsü şöyledir
https://<app-id>.firebaseio.com
Şöyle yaparız.
Firebase db = new Firebase (
  "https://docs-examples.firebaseio.com/web/saving-data/fireblog/posts");
addListenerForSingleValueEvent metodu
Şöyle yaparız
ref.addListenerForSingleValueEvent(new ValueEventListener() {
  @Override
  public void onDataChange(DataSnapshot dataSnapshot) {
    ...
  }

  @Override
  public void onCancelled(FirebaseError firebaseError) {
    ...
  }
});
addValueEventListener metodu
Açıklaması şöyle
This method will be called anytime new data is added to our Firebase reference, and we don't need to write any extra code to make this happen.
Şöyle yaparız.
// Attach an listener to read the data at our posts reference
db.addValueEventListener(new ValueEventListener() {
  @Override
  public void onDataChange(DataSnapshot snapshot) {
    System.out.println(snapshot.getValue());
  }
  @Override
  public void onCancelled(FirebaseError firebaseError) {
    System.out.println("The read failed: " + firebaseError.getMessage());
  }
});
child metodu
Şöyle yaparız
Firebase ref = db.child ("BusNumber");

2 Ekim 2016 Pazar

SubscriptionManager Sınıfı

from metodu
Şöyle yaparız.
SubscriptionManager sm = SubscriptionManager.from(getApplicationContext());
getActiveSubscriptionInfoList metodu
Şöyle yaparız.
List<SubscriptionInfo> subscriptionInfos = sm.getActiveSubscriptionInfoList();
Listeyi dolaşmak için şöyle yaparız.
for(int i=0; i<subscriptionInfos.size();i++)
{
  SubscriptionInfo lsuSubscriptionInfo = subscriptionInfos.get(i);
  Log.d(TAG, "getNumber "+ lsuSubscriptionInfo.getNumber());
  Log.d(TAG, "network name : "+ lsuSubscriptionInfo.getCarrierName());
  Log.d(TAG, "getCountryIso "+ lsuSubscriptionInfo.getCountryIso());
}