Java Code Examples for android.os.Message

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project alljoyn_java, under directory /samples/android/contacts/ContactsClient/src/org/alljoyn/bus/samples/contacts_client/.

Source file: ContactsClient.java

  19 
vote

private void logStatus(String msg,Status status){
  String log=String.format("%s: %s",msg,status);
  if (status == Status.OK) {
    Log.i(TAG,log);
  }
 else {
    Message toastMsg=mHandler.obtainMessage(MESSAGE_POST_TOAST,log);
    mHandler.sendMessage(toastMsg);
    Log.e(TAG,log);
  }
}
 

Example 2

From project adg-android, under directory /src/com/analysedesgeeks/android/.

Source file: AbstractPodcastActivity.java

  18 
vote

protected void queueNextRefresh(final long delay){
  if (!paused) {
    final Message msg=mHandler.obtainMessage(REFRESH);
    mHandler.removeMessages(REFRESH);
    mHandler.sendMessageDelayed(msg,delay);
  }
}
 

Example 3

From project android-async-http, under directory /src/com/loopj/android/http/.

Source file: AsyncHttpResponseHandler.java

  18 
vote

protected Message obtainMessage(int responseMessage,Object response){
  Message msg=null;
  if (handler != null) {
    msg=this.handler.obtainMessage(responseMessage,response);
  }
 else {
    msg=new Message();
    msg.what=responseMessage;
    msg.obj=response;
  }
  return msg;
}
 

Example 4

From project android-joedayz, under directory /Proyectos/FBConnectTest/src/com/facebook/android/.

Source file: Facebook.java

  18 
vote

private void refreshToken(){
  Bundle requestData=new Bundle();
  requestData.putString(TOKEN,mAccessToken);
  Message request=Message.obtain();
  request.setData(requestData);
  request.replyTo=messageReceiver;
  try {
    messageSender.send(request);
  }
 catch (  RemoteException e) {
    serviceListener.onError(new Error("Service connection error"));
  }
}
 

Example 5

From project android-ocr, under directory /android/src/edu/sfsu/cs/orange/ocr/camera/.

Source file: PreviewCallback.java

  18 
vote

@Override public void onPreviewFrame(byte[] data,Camera camera){
  Point cameraResolution=configManager.getCameraResolution();
  Handler thePreviewHandler=previewHandler;
  if (cameraResolution != null && thePreviewHandler != null) {
    Message message=thePreviewHandler.obtainMessage(previewMessage,cameraResolution.x,cameraResolution.y,data);
    message.sendToTarget();
    previewHandler=null;
  }
 else {
    Log.d(TAG,"Got preview callback, but no handler or resolution available");
  }
}
 

Example 6

From project android-tether, under directory /facebook/src/com/facebook/android/.

Source file: Facebook.java

  18 
vote

private void refreshToken(){
  Bundle requestData=new Bundle();
  requestData.putString(TOKEN,mAccessToken);
  Message request=Message.obtain();
  request.setData(requestData);
  request.replyTo=messageReceiver;
  try {
    messageSender.send(request);
  }
 catch (  RemoteException e) {
    serviceListener.onError(new Error("Service connection error"));
  }
}
 

Example 7

From project android-voip-service, under directory /src/main/java/net/chrislehmann/sipservice/service/.

Source file: SipService.java

  18 
vote

@Override public int onStartCommand(Intent intent,int flags,int startId){
  Ln.d("Got start command");
  Message message=new Message();
  message.obj=intent;
  messageLoop.mHandler.sendMessage(message);
  return START_STICKY;
}
 

Example 8

From project android-xbmcremote, under directory /src/org/xbmc/android/remote/business/.

Source file: NowPlayingPollerThread.java

  18 
vote

private void sendSingleMessage(Handler handler,int what,ICurrentlyPlaying curr){
  Message msg=Message.obtain(handler);
  msg.what=what;
  Bundle bundle=msg.getData();
  bundle.putSerializable(BUNDLE_CURRENTLY_PLAYING,curr);
  bundle.putInt(BUNDLE_LAST_PLAYLIST,mPlayList);
  bundle.putInt(BUNDLE_LAST_PLAYPOSITION,mPosition);
  msg.setTarget(handler);
  handler.sendMessage(msg);
}
 

Example 9

From project AndroidDevWeekendDub-BookLibrary, under directory /src/org/curiouscreature/android/shelves/activity/.

Source file: ShelvesActivity.java

  18 
vote

private void postUpdateBookCovers(){
  Handler handler=mScrollHandler;
  Message message=handler.obtainMessage(MESSAGE_UPDATE_BOOK_COVERS,ShelvesActivity.this);
  handler.removeMessages(MESSAGE_UPDATE_BOOK_COVERS);
  mPendingCoversUpdate=true;
  handler.sendMessage(message);
}
 

Example 10

From project android_aosp_packages_apps_Settings, under directory /src/com/android/settings/.

Source file: BandMode.java

  18 
vote

public void onItemClick(AdapterView parent,View v,int position,long id){
  getWindow().setFeatureInt(Window.FEATURE_INDETERMINATE_PROGRESS,Window.PROGRESS_VISIBILITY_ON);
  mTargetBand=(BandListItem)parent.getAdapter().getItem(position);
  if (DBG)   log("Select band : " + mTargetBand.toString());
  Message msg=mHandler.obtainMessage(EVENT_BAND_SELECTION_DONE);
  mPhone.setBandMode(mTargetBand.getBand(),msg);
}
 

Example 11

From project android_packages_apps_FileManager, under directory /src/org/openintents/filemanager/.

Source file: DirectoryScanner.java

  18 
vote

private void updateProgress(int progress,int maxProgress){
  if ((progress % PROGRESS_STEPS) == 0) {
    long curTime=SystemClock.uptimeMillis();
    if (curTime - operationStartTime < 1000L) {
      return;
    }
    Message msg=handler.obtainMessage(FileManagerActivity.MESSAGE_SET_PROGRESS);
    msg.arg1=progress;
    msg.arg2=maxProgress;
    msg.sendToTarget();
  }
}
 

Example 12

From project android_packages_apps_Gallery, under directory /src/com/android/camera/.

Source file: ImageGetter.java

  18 
vote

public void postDelayedGetterCallback(Runnable callback,long delay){
  if (callback == null) {
    throw new NullPointerException();
  }
  Message message=Message.obtain();
  message.what=IMAGE_GETTER_CALLBACK;
  message.obj=callback;
  sendMessageDelayed(message,delay);
}
 

Example 13

From project android_packages_apps_Gallery2, under directory /src/com/android/gallery3d/ui/.

Source file: PhotoView.java

  18 
vote

private void deleteAfterAnimation(int duration){
  MediaItem item=mModel.getMediaItem(mTouchBoxIndex);
  if (item == null)   return;
  mListener.onCommitDeleteImage();
  mUndoIndexHint=mModel.getCurrentIndex() + mTouchBoxIndex;
  mHolding|=HOLD_DELETE;
  Message m=mHandler.obtainMessage(MSG_DELETE_ANIMATION_DONE);
  m.obj=item.getPath();
  m.arg1=mTouchBoxIndex;
  mHandler.sendMessageDelayed(m,duration);
}
 

Example 14

From project android_packages_apps_Gallery3D, under directory /src/com/cooliris/media/.

Source file: Gallery.java

  18 
vote

private void sendInitialMessage(){
  mNumRetries=0;
  Message checkStorage=new Message();
  checkStorage.what=CHECK_STORAGE;
  handler.sendMessage(checkStorage);
}
 

Example 15

From project AmDroid, under directory /AmDroid/src/main/java/com/jaeckel/amenoid/cwac/task/.

Source file: AsyncTaskEx.java

  17 
vote

/** 
 * Creates a new asynchronous task. This constructor must be invoked on the UI thread.
 */
public AsyncTaskEx(){
  mWorker=new WorkerRunnable<Params,Result>(){
    public Result call() throws Exception {
      Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
      return doInBackground(mParams);
    }
  }
;
  mFuture=new FutureTask<Result>(mWorker){
    @Override protected void done(){
      Message message;
      Result result=null;
      try {
        result=get();
      }
 catch (      InterruptedException e) {
        com.jaeckel.amenoid.util.Log.w(LOG_TAG,e);
      }
catch (      ExecutionException e) {
        throw new RuntimeException("An error occured while executing doInBackground()",e.getCause());
      }
catch (      CancellationException e) {
        message=sHandler.obtainMessage(MESSAGE_POST_CANCEL,new AsyncTaskExResult<Result>(AsyncTaskEx.this,(Result[])null));
        message.sendToTarget();
        return;
      }
catch (      Throwable t) {
        throw new RuntimeException("An error occured while executing " + "doInBackground()",t);
      }
      message=sHandler.obtainMessage(MESSAGE_POST_RESULT,new AsyncTaskExResult<Result>(AsyncTaskEx.this,result));
      message.sendToTarget();
    }
  }
;
}
 

Example 16

From project android-client, under directory /xwiki-android-components/src/org/xwiki/android/components/login/.

Source file: LoginActivity.java

  17 
vote

private void login(int loginStatus){
  if (loginStatus == 200) {
    Log.d("Login","successful");
    getIntent().putExtra(INTENT_EXTRA_GET_USERNAME,username);
    getIntent().putExtra(INTENT_EXTRA_GET_PASSWORD,password);
    getIntent().putExtra(INTENT_EXTRA_GET_URL,url);
    setResult(Activity.RESULT_OK,getIntent());
    finish();
  }
 else   if (loginStatus == 401) {
    Log.d("Login","wrong username or password");
    Message ms=new Message();
    ms.arg1=0;
    Bundle data=new Bundle();
    data.putString("msg","Authentication failed \n check username password");
    ms.setData(data);
    handler.sendMessage(ms);
  }
 else   if (loginStatus == HttpConnector.RESP_CODE_CLIENT_CON_TIMEOUT) {
    Message ms=Message.obtain();
    Bundle data=new Bundle();
    data.putString("msg","Cannot establish Connection with server. \n Client Connection Timed out");
    ms.setData(data);
    ms.arg1=HttpConnector.RESP_CODE_CLIENT_CON_TIMEOUT;
    handler.sendMessage(ms);
  }
 else {
    Log.d("Login","unable to connect");
    Message ms=new Message();
    Bundle data=new Bundle();
    data.putString("msg","Unable to connect \n Resp Code: " + loginStatus);
    ms.setData(data);
    ms.arg1=1;
    handler.sendMessage(ms);
  }
}
 

Example 17

From project Android-File-Manager, under directory /src/com/nexes/manager/.

Source file: ApplicationBackup.java

  17 
vote

public void run(){
  BufferedInputStream mBuffIn;
  BufferedOutputStream mBuffOut;
  Message msg;
  int len=mDataSource.size();
  int read=0;
  for (int i=0; i < len; i++) {
    ApplicationInfo info=mDataSource.get(i);
    String source_dir=info.sourceDir;
    String out_file=source_dir.substring(source_dir.lastIndexOf("/") + 1,source_dir.length());
    try {
      mBuffIn=new BufferedInputStream(new FileInputStream(source_dir));
      mBuffOut=new BufferedOutputStream(new FileOutputStream(BACKUP_LOC + out_file));
      while ((read=mBuffIn.read(mData,0,BUFFER)) != -1)       mBuffOut.write(mData,0,read);
      mBuffOut.flush();
      mBuffIn.close();
      mBuffOut.close();
      msg=new Message();
      msg.what=SET_PROGRESS;
      msg.obj=i + " out of " + len+ " apps backed up";
      mHandler.sendMessage(msg);
    }
 catch (    FileNotFoundException e) {
      e.printStackTrace();
    }
catch (    IOException e) {
      e.printStackTrace();
    }
  }
  mHandler.sendEmptyMessage(FINISH_PROGRESS);
}
 

Example 18

From project Android-File-Manager-Tablet, under directory /src/com/nexes/manager/tablet/.

Source file: BluetoothActivity.java

  17 
vote

public ClientSocketThread(String device,Handler handle){
  mMACAddres=device.substring(device.lastIndexOf('\n') + 1,device.lastIndexOf(":")).toUpperCase();
  mHandle=handle;
  try {
    mRemoteDevice=mBluetoothAdapter.getRemoteDevice(mMACAddres);
    mSocket=mRemoteDevice.createRfcommSocketToServiceRecord(UUID.fromString(DEV_UUID));
  }
 catch (  IllegalArgumentException e) {
    mSocket=null;
    Message msg=new Message();
    msg.obj=e.getMessage();
    mHandle.sendEmptyMessage(DIALOG_CANCEL);
  }
catch (  IOException e) {
    Message msg=new Message();
    msg.obj=e.getMessage();
    mHandle.sendEmptyMessage(DIALOG_CANCEL);
  }
}
 

Example 19

From project android-thaiime, under directory /common/src/com/android/common/.

Source file: NetworkConnectivityListener.java

  17 
vote

@Override public void onReceive(Context context,Intent intent){
  String action=intent.getAction();
  if (!action.equals(ConnectivityManager.CONNECTIVITY_ACTION) || mListening == false) {
    Log.w(TAG,"onReceived() called with " + mState.toString() + " and "+ intent);
    return;
  }
  boolean noConnectivity=intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY,false);
  if (noConnectivity) {
    mState=State.NOT_CONNECTED;
  }
 else {
    mState=State.CONNECTED;
  }
  mNetworkInfo=(NetworkInfo)intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
  mOtherNetworkInfo=(NetworkInfo)intent.getParcelableExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO);
  mReason=intent.getStringExtra(ConnectivityManager.EXTRA_REASON);
  mIsFailover=intent.getBooleanExtra(ConnectivityManager.EXTRA_IS_FAILOVER,false);
  if (DBG) {
    Log.d(TAG,"onReceive(): mNetworkInfo=" + mNetworkInfo + " mOtherNetworkInfo = "+ (mOtherNetworkInfo == null ? "[none]" : mOtherNetworkInfo + " noConn=" + noConnectivity)+ " mState="+ mState.toString());
  }
  Iterator<Handler> it=mHandlers.keySet().iterator();
  while (it.hasNext()) {
    Handler target=it.next();
    Message message=Message.obtain(target,mHandlers.get(target));
    target.sendMessage(message);
  }
}
 

Example 20

From project android_frameworks_ex, under directory /common/java/com/android/common/.

Source file: NetworkConnectivityListener.java

  17 
vote

@Override public void onReceive(Context context,Intent intent){
  String action=intent.getAction();
  if (!action.equals(ConnectivityManager.CONNECTIVITY_ACTION) || mListening == false) {
    Log.w(TAG,"onReceived() called with " + mState.toString() + " and "+ intent);
    return;
  }
  boolean noConnectivity=intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY,false);
  if (noConnectivity) {
    mState=State.NOT_CONNECTED;
  }
 else {
    mState=State.CONNECTED;
  }
  mNetworkInfo=(NetworkInfo)intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
  mOtherNetworkInfo=(NetworkInfo)intent.getParcelableExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO);
  mReason=intent.getStringExtra(ConnectivityManager.EXTRA_REASON);
  mIsFailover=intent.getBooleanExtra(ConnectivityManager.EXTRA_IS_FAILOVER,false);
  if (DBG) {
    Log.d(TAG,"onReceive(): mNetworkInfo=" + mNetworkInfo + " mOtherNetworkInfo = "+ (mOtherNetworkInfo == null ? "[none]" : mOtherNetworkInfo + " noConn=" + noConnectivity)+ " mState="+ mState.toString());
  }
  Iterator<Handler> it=mHandlers.keySet().iterator();
  while (it.hasNext()) {
    Handler target=it.next();
    Message message=Message.obtain(target,mHandlers.get(target));
    target.sendMessage(message);
  }
}
 

Example 21

From project AlarmApp-Android, under directory /src/org/alarmapp/services/.

Source file: AudioPlayerService.java

  15 
vote

public void handleMessage(Message msg){
switch (msg.what) {
case KILLER:
    LogEx.verbose("*********** Alarm killer triggered ***********");
  stopSelf();
break;
}
}
 

Example 22

From project Amantech, under directory /Android/CloudAppStudioAndroid/src/com/cloudappstudio/utility/.

Source file: ImageLoaderView.java

  15 
vote

public boolean handleMessage(Message msg){
switch (msg.what) {
case COMPLETE:
    mImage.setImageDrawable(mDrawable);
  mImage.setVisibility(View.VISIBLE);
mSpinner.setVisibility(View.GONE);
break;
case FAILED:
default :
mImage.setScaleType(ScaleType.FIT_XY);
mImage.setImageDrawable(getResources().getDrawable(R.drawable.no_image_found));
mImage.setVisibility(View.VISIBLE);
mSpinner.setVisibility(View.GONE);
break;
}
return true;
}
 

Example 23

From project android-context, under directory /src/edu/fsu/cs/contextprovider/.

Source file: ContextService.java

  15 
vote

private void StoreSocial() throws Exception {
  try {
    entityManager=EntityManager.GetManager(this);
    SocialEntity social=new SocialEntity();
    social.Contact.setValue(SocialMonitor.getContact());
    social.Communication.setValue(SocialMonitor.getCommunication());
    social.Message.setValue(SocialMonitor.getMessage());
    social.LastIncoming.setValue(SocialMonitor.getLastInDate());
    social.LastOutgoing.setValue(SocialMonitor.getLastOutDate());
    int uid=entityManager.store(social);
    if (DEBUG) {
      buffer.write("" + System.currentTimeMillis() + ","+ SocialMonitor.getContact()+ ","+ SocialMonitor.getCommunication()+ ","+ SocialMonitor.getMessage()+ ","+ SocialMonitor.getLastInDate()+ ","+ SocialMonitor.getLastOutDate()+ "\n");
    }
  }
 catch (  Exception e) {
    throw e;
  }
}
 

Example 24

From project Android-Flashcards, under directory /src/com/secretsockssoftware/androidflashcards/.

Source file: DownloadableLessonList.java

  15 
vote

@Override public void handleMessage(Message msg){
  pd.dismiss();
switch (msg.what) {
case 0:
{
      availLessons=(ArrayList<AvailLesson>)(msg.obj);
      setListAdapter(new ArrayAdapter<AvailLesson>(me,android.R.layout.simple_list_item_1,availLessons));
      getListView().setTextFilterEnabled(true);
      return;
    }
case 1:
{
    AlertDialog alertDialog=new AlertDialog.Builder(me).create();
    alertDialog.setTitle("Error");
    alertDialog.setMessage("Sorry, but an error occured trying to download the list of available lessons:\n" + msg.obj);
    alertDialog.setButton(DialogInterface.BUTTON_POSITIVE,"OK",new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int which){
        finish();
        return;
      }
    }
);
    alertDialog.show();
  }
}
}
 

Example 25

From project android-flip, under directory /FlipView/FlipLibrary/src/com/aphidmobile/flip/.

Source file: FlipViewController.java

  15 
vote

@Override public boolean handleMessage(Message msg){
  if (msg.what == MSG_SURFACE_CREATED) {
    contentWidth=0;
    contentHeight=0;
    requestLayout();
    return true;
  }
  return false;
}
 

Example 26

From project Android-MapForgeFragment, under directory /library-common/src/com/jakewharton/android/mapsforge_fragment/.

Source file: MapView.java

  15 
vote

private void setupZoomControls(){
  this.zoomControls=new ZoomControls(this.activity);
  this.zoomControls.setVisibility(View.GONE);
  this.zoomControls.setOnZoomInClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      zoom((byte)1,1);
    }
  }
);
  this.zoomControls.setOnZoomOutClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      zoom((byte)-1,1);
    }
  }
);
  this.zoomControlsHideHandler=new Handler(){
    @Override public void handleMessage(    Message msg){
      hideZoomZontrols();
    }
  }
;
  addView(this.zoomControls,new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT));
}
 

Example 27

From project android-shuffle, under directory /client/src/org/dodgybits/shuffle/android/core/activity/.

Source file: WelcomeActivity.java

  15 
vote

@Override protected void onCreate(Bundle icicle){
  super.onCreate(icicle);
  Log.d(cTag,"onCreate");
  setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT);
  requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
  setContentView(R.layout.welcome);
  mSampleDataButton.setOnClickListener(new View.OnClickListener(){
    public void onClick(    View v){
      disableButtons();
      startProgressAnimation();
      performCreateSampleData();
    }
  }
);
  mCleanSlateButton.setOnClickListener(new View.OnClickListener(){
    public void onClick(    View v){
      disableButtons();
      startProgressAnimation();
      performCleanSlate();
    }
  }
);
  mHandler=new Handler(){
    @Override public void handleMessage(    Message msg){
      updateFirstTimePref(false);
      getWindow().setFeatureInt(Window.FEATURE_INDETERMINATE_PROGRESS,Window.PROGRESS_VISIBILITY_OFF);
      startActivity(new Intent(WelcomeActivity.this,TopLevelActivity.class));
      finish();
    }
  }
;
}
 

Example 28

From project Android-Terminal-Emulator, under directory /libraries/emulatorview/src/jackpal/androidterm/emulatorview/.

Source file: TermSession.java

  15 
vote

@Override public void handleMessage(Message msg){
  if (!mIsRunning) {
    return;
  }
  if (msg.what == NEW_INPUT) {
    readFromProcess();
  }
}
 

Example 29

From project android-wheel, under directory /wheel/src/kankan/wheel/widget/.

Source file: WheelScroller.java

  15 
vote

public void handleMessage(Message msg){
  scroller.computeScrollOffset();
  int currY=scroller.getCurrY();
  int delta=lastScrollY - currY;
  lastScrollY=currY;
  if (delta != 0) {
    listener.onScroll(delta);
  }
  if (Math.abs(currY - scroller.getFinalY()) < MIN_DELTA_FOR_SCROLLING) {
    currY=scroller.getFinalY();
    scroller.forceFinished(true);
  }
  if (!scroller.isFinished()) {
    animationHandler.sendEmptyMessage(msg.what);
  }
 else   if (msg.what == MESSAGE_SCROLL) {
    justify();
  }
 else {
    finishScrolling();
  }
}
 

Example 30

From project android-wheel-datetime-picker, under directory /src/kankan/wheel/widget/.

Source file: WheelScroller.java

  15 
vote

public void handleMessage(Message msg){
  scroller.computeScrollOffset();
  int currY=scroller.getCurrY();
  int delta=lastScrollY - currY;
  lastScrollY=currY;
  if (delta != 0) {
    listener.onScroll(delta);
  }
  if (Math.abs(currY - scroller.getFinalY()) < MIN_DELTA_FOR_SCROLLING) {
    currY=scroller.getFinalY();
    scroller.forceFinished(true);
  }
  if (!scroller.isFinished()) {
    animationHandler.sendEmptyMessage(msg.what);
  }
 else   if (msg.what == MESSAGE_SCROLL) {
    justify();
  }
 else {
    finishScrolling();
  }
}
 

Example 31

From project android-wheel_1, under directory /wheel/src/kankan/wheel/widget/.

Source file: WheelScroller.java

  15 
vote

public void handleMessage(Message msg){
  scroller.computeScrollOffset();
  int currY=scroller.getCurrY();
  int delta=lastScrollY - currY;
  lastScrollY=currY;
  if (delta != 0) {
    listener.onScroll(delta);
  }
  if (Math.abs(currY - scroller.getFinalY()) < MIN_DELTA_FOR_SCROLLING) {
    currY=scroller.getFinalY();
    scroller.forceFinished(true);
  }
  if (!scroller.isFinished()) {
    animationHandler.sendEmptyMessage(msg.what);
  }
 else   if (msg.what == MESSAGE_SCROLL) {
    justify();
  }
 else {
    finishScrolling();
  }
}
 

Example 32

From project Android_1, under directory /CustomTabsHack/src/com/novoda/.

Source file: Container.java

  15 
vote

@Override public void handleMessage(Message msg){
switch (msg.what) {
case SWITCH_TAB:
    Log.i("handler","using the handler");
  host.setCurrentTab(msg.arg1);
break;
}
}
 

Example 33

From project android_ioio_combination_lock, under directory /src/kankan/wheel/widget/.

Source file: WheelScroller.java

  15 
vote

public void handleMessage(Message msg){
  scroller.computeScrollOffset();
  int currY=scroller.getCurrY();
  int delta=lastScrollY - currY;
  lastScrollY=currY;
  if (delta != 0) {
    listener.onScroll(delta);
  }
  if (Math.abs(currY - scroller.getFinalY()) < MIN_DELTA_FOR_SCROLLING) {
    currY=scroller.getFinalY();
    scroller.forceFinished(true);
  }
  if (!scroller.isFinished()) {
    animationHandler.sendEmptyMessage(msg.what);
  }
 else   if (msg.what == MESSAGE_SCROLL) {
    justify();
  }
 else {
    finishScrolling();
  }
}
 

Example 34

From project android_packages_apps_CellBroadcastReceiver, under directory /src/com/android/cellbroadcastreceiver/.

Source file: CellBroadcastAlertAudio.java

  15 
vote

@Override public void handleMessage(Message msg){
switch (msg.what) {
case ALERT_SOUND_FINISHED:
    if (DBG)     log("ALERT_SOUND_FINISHED");
  stop();
if (mMessageBody != null && mTtsEngineReady && mTtsLanguageSupported) {
  mHandler.sendMessageDelayed(mHandler.obtainMessage(ALERT_PAUSE_FINISHED),PAUSE_DURATION_BEFORE_SPEAKING_MSEC);
  mState=STATE_PAUSING;
}
 else {
  stopSelf();
  mState=STATE_IDLE;
}
break;
case ALERT_PAUSE_FINISHED:
if (DBG) log("ALERT_PAUSE_FINISHED");
if (mMessageBody != null && mTtsEngineReady && mTtsLanguageSupported) {
if (DBG) log("Speaking broadcast text: " + mMessageBody);
mTts.speak(mMessageBody,TextToSpeech.QUEUE_FLUSH,null);
mState=STATE_SPEAKING;
}
 else {
Log.w(TAG,"TTS engine not ready or language not supported");
stopSelf();
mState=STATE_IDLE;
}
break;
default :
Log.e(TAG,"Handler received unknown message, what=" + msg.what);
}
}
 

Example 35

From project android_packages_apps_cmparts, under directory /src/com/cyanogenmod/cmparts/activities/.

Source file: SoundActivity.java

  15 
vote

public void handleMessage(Message msg){
switch (msg.what) {
case 0:
    if (msg.obj != null) {
      ListPreference p=(ListPreference)findPreference(msg.obj.toString());
      p.setSummary(p.getEntry());
    }
  break;
}
}