I have a design question on Android.
I have a class which used to register Accelerometer sensor in Andriod. I am passing the SensorEventListener as parameter in the defined function so that user will get the functionality to work on live sensor data or to store it using POJO class.
What will be the effect if I implement a Singleton Design Pattern on that class? Is there any blockage from devlepment side?
Sample Code :
public class Accel
{
private static Accel accelObj;
private Accel(Context context)
{
}
public static synchronized Accel getInstance(Context context)
{
if (accelObj == null)
accelObj = new Accel(context);
return accelObj;
}
public registerListener(SensorEventListener listener)
{
// To Do
}
}
This class I want to use for application development. Is there any drawback other then slower due to synchronized method for application development?
0 comments:
Post a Comment