Tuesday 29 October 2013

Object Serialization

Worrying about loosing object states? Let's do the recovery.....

[Recover and retrieve previous states of objects using Object Serialization]

First see the basic of serialization. You can see and understand what Serialization is. Also in android sometimes there's a need of save the whole state of the object especially when you are making games. Here is the demo project developed by me. https://github.com/jatinmalwal/demo-object-serialization. You'll find it very easy to understand this project and implement it into your application. Whole project is properly documented. The basic implementation of object serialization is similar as Java.

This image properly describes the Java Object Serialization.

Tuesday 17 September 2013

Are you playing with sounds in your app?

Here is the playground for u.....




If you developing an app and struggling with managing sounds here is the solution;

SoundPoolDemo
Some code snippet :

public class LauncherActivity extends Activity implements OnTouchListener {
private SoundPool soundPool;
final static int MAX_STREAMS = 5;
private boolean isLoaded = false;
private int soundOneID;
private int soundTwoID;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_launcher);
((RelativeLayout) findViewById(R.id.bg)).setOnTouchListener(this);
// Set the hardware buttons to control the music
this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
// Load the sound
soundPool = new SoundPool(MAX_STREAMS, AudioManager.STREAM_MUSIC, 0);
soundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() {

@Override
public void onLoadComplete(SoundPool soundPool, int sampleId,
int status) {
Log.d("TESTING", "sampleId :" + sampleId + " status :" + status);
isLoaded = true;
}

});

soundOneID = soundPool.load(this, R.raw.shoot_1, 1);
soundTwoID = soundPool.load(this, R.raw.shoot_2, 1);

Log.d("TESTING", "soundOneID :" + soundOneID);
Log.d("TESTING", "soundTwoID :" + soundTwoID);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.launcher, menu);
return true;
}

@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
float actualVolume = (float) audioManager
.getStreamVolume(AudioManager.STREAM_MUSIC);
float maxVolume = (float) audioManager
.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
float volume = actualVolume / maxVolume;
Log.d("TESTING", actualVolume + ":  actualVolume");
Log.d("TESTING", maxVolume + ":  maxVolume");
Log.d("TESTING", volume + ": volume");
if (isLoaded) {
soundPool.play(soundOneID, volume, volume, 1, 0, 1f);
}
}
return false;
}

@Override
protected void onStop() {
if (soundPool != null) {
// To release all the resources of soundPool
soundPool.release();
}
super.onStop();
}
}

If you have any query, ask me.

Sunday 15 September 2013

Introduction

Let me introduce this blog first. This is a blog for all the android developers. As the name describes, it is a method of the interface AndroidDevelopersPoint. Here is the source :

public interface AndroidDevelopersPoint{
       public Android getAndroidInMyStyle(Style yourStyle);
}

You can find here lots of android stuff like links of 
  • Cool libraries by top developers implemented by me
  • Android demo projects developed by me 
  • Various top rated answers given by me on stackoverflow and android.stackexchange
  • Various quality questions with answers asked by me on the same
  • Cool apps developed by me
  • Top google play apps in my collections  

Method description : 

It's a method for all the ADs (Android Developers) to provide their style and get the android in their style. You'll always find solutions to there problems here. It's a interface method so you can always provide implementation to it.