public class SmotionCall
extends java.lang.Object
import com.samsung.android.sdk.SsdkUnsupportedException; import com.samsung.android.sdk.motion.Smotion; import com.samsung.android.sdk.motion.SmotionCall; import com.samsung.android.sdk.motion.SmotionCall.ChangeListener; import com.samsung.android.sdk.motion.SmotionCall.Info; import android.app.Activity; import android.os.Bundle; import android.os.Looper; public class MainActivity extends Activity { private Smotion mSmotion; private SmotionCall mSmotionCall; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mSmotion = new Smotion(); try { mSmotion.initialize(getApplicationContext()); } catch (SsdkUnsupportedException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (mSmotion.isFeatureEnabled(Smotion.TYPE_CALL)) { mSmotionCall = new SmotionCall(Looper.getMainLooper(), mSmotion); } } @Override protected void onResume() { // TODO Auto-generated method stub super.onResume(); mSmotionCall.start(mChangeListener); } @Override protected void onDestroy() { // TODO Auto-generated method stub super.onDestroy(); mSmotionCall.stop(); } private ChangeListener mChangeListener = new ChangeListener() { @Override public void onChanged(Info info) { // TODO Auto-generated method stub long timestamp = info.getTimeStamp(); int callPosition = info.getCallPosition(); } }; }
Modifier and Type | Class and Description |
---|---|
static interface |
SmotionCall.ChangeListener
This listener interface receives call motion events.
|
static class |
SmotionCall.Info
This class contains the call motion event information and provides
methods to access it.
|
Modifier and Type | Field and Description |
---|---|
static int |
POSITION_LEFT
User is holding the device next to the left ear.
|
static int |
POSITION_RIGHT
User is holding the device next to the right ear.
|
Constructor and Description |
---|
SmotionCall(android.os.Looper looper,
Smotion motion)
Creates a SmotionCall instance with the specified looper and Smotion
instances.
|
Modifier and Type | Method and Description |
---|---|
void |
start(SmotionCall.ChangeListener listener)
Add the specified ChangeListener instance.
|
void |
stop()
Remove the ChangeListener instance.
|
public static final int POSITION_LEFT
public static final int POSITION_RIGHT
public SmotionCall(android.os.Looper looper, Smotion motion) throws java.lang.NullPointerException, java.lang.IllegalArgumentException
looper
- The looper of the main thread in your application.motion
- The Smotion instance.java.lang.NullPointerException
- Thrown if the looper or Smotion object
passed is null.java.lang.IllegalArgumentException
- Thrown if the Context passed is null.
This can happen if you did not initialize the Motion package
before creating the SmotionCall instance.java.lang.IllegalStateException
- Thrown if the device does not support
SmotionCall.public void start(SmotionCall.ChangeListener listener)
listener
- The ChangeListener instance.java.lang.IllegalStateException
- Thrown if a listener is already registered
or the device does not support SmotionCall.java.lang.IllegalArgumentException
- Thrown if the listener passed is null.public void stop()
java.lang.IllegalStateException
- Thrown when stop() is called before calling
the start() method.