List of usage examples for android.os RemoteException printStackTrace
public void printStackTrace()
From source file:org.gateshipone.odyssey.views.NowPlayingView.java
/** * Menu click listener. This method gets called when the user selects an item of the popup menu (right top corner). * * @param item MenuItem that was clicked. * @return Returns true if the item was handled by this method. False otherwise. *///from w w w . j a va 2s. c o m @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.view_nowplaying_action_shuffleplaylist: try { mServiceConnection.getPBS().shufflePlaylist(); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } return true; case R.id.view_nowplaying_action_clearplaylist: try { mServiceConnection.getPBS().clearPlaylist(); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } return true; case R.id.view_nowplaying_action_saveplaylist: // open dialog in order to save the current playlist as a playlist in the mediastore ChoosePlaylistDialog choosePlaylistDialog = new ChoosePlaylistDialog(); choosePlaylistDialog.show(((AppCompatActivity) getContext()).getSupportFragmentManager(), "ChoosePlaylistDialog"); return true; case R.id.view_nowplaying_action_createbookmark: // open dialog in order to save the current playlist as a bookmark in the odyssey db ChooseBookmarkDialog chooseBookmarkDialog = new ChooseBookmarkDialog(); chooseBookmarkDialog.show(((AppCompatActivity) getContext()).getSupportFragmentManager(), "ChooseBookmarkDialog"); return true; case R.id.view_nowplaying_action_startequalizer: // start the audio equalizer Activity activity = (Activity) getContext(); if (activity != null) { Intent startEqualizerIntent = new Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL); try { activity.startActivityForResult(startEqualizerIntent, 0); } catch (ActivityNotFoundException e) { ErrorDialog equalizerNotFoundDlg = ErrorDialog.newInstance( R.string.dialog_equalizer_not_found_title, R.string.dialog_equalizer_not_found_message); equalizerNotFoundDlg.show(((AppCompatActivity) getContext()).getSupportFragmentManager(), "EqualizerNotFoundDialog"); } } return true; default: return false; } }
From source file:cx.ring.service.LocalService.java
public void sendTextMessage(String account, SipUri to, String txt) { try {/* www . jav a 2 s . c o m*/ mService.sendAccountTextMessage(account, to.getRawUriString(), txt); TextMessage message = new TextMessage(false, txt, to, null, account); message.read(); historyManager.insertNewTextMessage(message); textMessageSent(message); } catch (RemoteException e) { e.printStackTrace(); } }
From source file:cx.ring.service.LocalService.java
public void sendTextMessage(Conference conf, String txt) { try {/* w w w. j a v a2 s . c o m*/ mService.sendTextMessage(conf.getId(), txt); SipCall call = conf.getParticipants().get(0); TextMessage message = new TextMessage(false, txt, call.getNumberUri(), conf.getId(), call.getAccount()); message.read(); historyManager.insertNewTextMessage(message); textMessageSent(message); } catch (RemoteException e) { e.printStackTrace(); } }
From source file:org.torproject.android.OrbotMainActivity.java
private synchronized void handleIntents() { if (getIntent() == null) return;//from w w w. jav a 2 s. c o m // Get intent, action and MIME type Intent intent = getIntent(); String action = intent.getAction(); Log.d(TAG, "handleIntents " + action); //String type = intent.getType(); if (action == null) return; if (action.equals(INTENT_ACTION_REQUEST_HIDDEN_SERVICE)) { final int hiddenServicePortRequest = getIntent().getIntExtra("hs_port", -1); DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: try { enableHiddenServicePort(hiddenServicePortRequest); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } break; case DialogInterface.BUTTON_NEGATIVE: //No button clicked finish(); break; } } }; String requestMsg = getString(R.string.hidden_service_request, hiddenServicePortRequest); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(requestMsg).setPositiveButton("Allow", dialogClickListener) .setNegativeButton("Deny", dialogClickListener).show(); return; //don't null the setIntent() as we need it later } else if (action.equals(INTENT_ACTION_REQUEST_START_TOR)) { autoStartFromIntent = true; startTor(); //never allow backgrounds start from this type of intent start //app devs who want background starts, can use the service intents /** if (Prefs.allowBackgroundStarts()) { Intent resultIntent; if (lastStatusIntent == null) { resultIntent = new Intent(intent); } else { resultIntent = lastStatusIntent; } resultIntent.putExtra(TorServiceConstants.EXTRA_STATUS, torStatus); setResult(RESULT_OK, resultIntent); finish(); }*/ } else if (action.equals(Intent.ACTION_VIEW)) { String urlString = intent.getDataString(); if (urlString != null) { if (urlString.toLowerCase().startsWith("bridge://")) { String newBridgeValue = urlString.substring(9); //remove the bridge protocol piece newBridgeValue = URLDecoder.decode(newBridgeValue); //decode the value here showAlert(getString(R.string.bridges_updated), getString(R.string.restart_orbot_to_use_this_bridge_) + newBridgeValue, false); setNewBridges(newBridgeValue); } } } updateStatus(null); setIntent(null); }
From source file:cx.ring.service.LocalService.java
private void updateConnectivityState() { ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI); Log.w(TAG, "ActiveNetworkInfo (Wifi): " + (ni == null ? "null" : ni.toString())); isWifiConn = ni != null && ni.isConnected(); ni = cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); Log.w(TAG, "ActiveNetworkInfo (mobile): " + (ni == null ? "null" : ni.toString())); isMobileConn = ni != null && ni.isConnected(); try {/*from w w w . j a va2s .c o m*/ getRemoteService().setAccountsActive(isConnected()); } catch (RemoteException e) { e.printStackTrace(); } // if account list loaded if (!ip2ip_account.isEmpty()) sendBroadcast(new Intent(ACTION_ACCOUNT_UPDATE)); }
From source file:com.android.trivialdrivesample.util.IabHelper.java
/** * Starts the setup process. This will start up the setup process asynchronously. * You will be notified through the listener when the setup process is complete. * This method is safe to call from a UI thread. * * @param listener The listener to notify when the setup process is complete. *//* w w w . jav a 2s . co m*/ public void startSetup(final OnIabSetupFinishedListener listener) { // If already set up, can't do it again. checkNotDisposed(); if (mSetupDone) throw new IllegalStateException("IAB helper is already set up."); // Connection to IAB service logDebug("Starting in-app billing setup."); mServiceConn = new ServiceConnection() { @Override public void onServiceDisconnected(ComponentName name) { logDebug("Billing service disconnected."); mService = null; } @Override public void onServiceConnected(ComponentName name, IBinder service) { if (mDisposed) return; logDebug("Billing service connected."); mService = IInAppBillingService.Stub.asInterface(service); String packageName = mContext.getPackageName(); try { logDebug("Checking for in-app billing 3 support."); // check for in-app billing v3 support int response = mService.isBillingSupported(3, packageName, ITEM_TYPE_INAPP); if (response != BILLING_RESPONSE_RESULT_OK) { if (listener != null) listener.onIabSetupFinished( new IabResult(response, "Error checking for billing v3 support.")); // if in-app purchases aren't supported, neither are subscriptions mSubscriptionsSupported = false; mSubscriptionUpdateSupported = false; return; } else { logDebug("In-app billing version 3 supported for " + packageName); } // Check for v5 subscriptions support. This is needed for // getBuyIntentToReplaceSku which allows for subscription update response = mService.isBillingSupported(5, packageName, ITEM_TYPE_SUBS); if (response == BILLING_RESPONSE_RESULT_OK) { logDebug("Subscription re-signup AVAILABLE."); mSubscriptionUpdateSupported = true; } else { logDebug("Subscription re-signup not available."); mSubscriptionUpdateSupported = false; } if (mSubscriptionUpdateSupported) { mSubscriptionsSupported = true; } else { // check for v3 subscriptions support response = mService.isBillingSupported(3, packageName, ITEM_TYPE_SUBS); if (response == BILLING_RESPONSE_RESULT_OK) { logDebug("Subscriptions AVAILABLE."); mSubscriptionsSupported = true; } else { logDebug("Subscriptions NOT AVAILABLE. Response: " + response); mSubscriptionsSupported = false; mSubscriptionUpdateSupported = false; } } mSetupDone = true; } catch (RemoteException e) { if (listener != null) { listener.onIabSetupFinished(new IabResult(IABHELPER_REMOTE_EXCEPTION, "RemoteException while setting up in-app billing.")); } e.printStackTrace(); return; } if (listener != null) { listener.onIabSetupFinished(new IabResult(BILLING_RESPONSE_RESULT_OK, "Setup successful.")); } } }; Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); serviceIntent.setPackage("com.android.vending"); List<ResolveInfo> intentServices = mContext.getPackageManager().queryIntentServices(serviceIntent, 0); if (intentServices != null && !intentServices.isEmpty()) { // service available to handle that Intent mContext.bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE); } else { // no service available to handle that Intent if (listener != null) { listener.onIabSetupFinished(new IabResult(BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE, "Billing service unavailable on device.")); } } }
From source file:com.dolphingame.googleplay.util.IabHelper.java
/** * Starts the setup process. This will start up the setup process asynchronously. * You will be notified through the listener when the setup process is complete. * This method is safe to call from a UI thread. * * @param listener The listener to notify when the setup process is complete. *///from ww w. jav a 2 s.c o m public void startSetup(final OnIabSetupFinishedListener listener) { // If already set up, can't do it again. checkNotDisposed(); if (mSetupDone) throw new IllegalStateException("IAB helper is already set up."); // Connection to IAB service logDebug("Starting in-app billing setup."); mServiceConn = new ServiceConnection() { @Override public void onServiceDisconnected(ComponentName name) { logDebug("Billing service disconnected."); mService = null; } @Override public void onServiceConnected(ComponentName name, IBinder service) { if (mDisposed) return; logDebug("Billing service connected."); mService = IInAppBillingService.Stub.asInterface(service); String packageName = mContext.getPackageName(); try { logDebug("Checking for in-app billing 3 support."); // check for in-app billing v3 support int response = mService.isBillingSupported(3, packageName, ITEM_TYPE_INAPP); if (response != BILLING_RESPONSE_RESULT_OK) { if (listener != null) listener.onIabSetupFinished( new IabResult(response, "Error checking for billing v3 support.")); // if in-app purchases aren't supported, neither are subscriptions mSubscriptionsSupported = false; mSubscriptionUpdateSupported = false; return; } else { logDebug("In-app billing version 3 supported for " + packageName); } // Check for v5 subscriptions support. This is needed for // getBuyIntentToReplaceSku which allows for subscription update response = mService.isBillingSupported(5, packageName, ITEM_TYPE_SUBS); if (response == BILLING_RESPONSE_RESULT_OK) { logDebug("Subscription re-signup AVAILABLE."); mSubscriptionUpdateSupported = true; } else { logDebug("Subscription re-signup not available."); mSubscriptionUpdateSupported = false; } if (mSubscriptionUpdateSupported) { mSubscriptionsSupported = true; } else { // check for v3 subscriptions support response = mService.isBillingSupported(3, packageName, ITEM_TYPE_SUBS); if (response == BILLING_RESPONSE_RESULT_OK) { logDebug("Subscriptions AVAILABLE."); mSubscriptionsSupported = true; } else { logDebug("Subscriptions NOT AVAILABLE. Response: " + response); mSubscriptionsSupported = false; mSubscriptionUpdateSupported = false; } } mSetupDone = true; } catch (RemoteException e) { if (listener != null) { listener.onIabSetupFinished(new IabResult(IABHELPER_REMOTE_EXCEPTION, "RemoteException while setting up in-app billing.")); } e.printStackTrace(); return; } if (listener != null) { listener.onIabSetupFinished(new IabResult(BILLING_RESPONSE_RESULT_OK, "Setup successful.")); } } }; Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); serviceIntent.setPackage("com.android.vending"); List<ResolveInfo> intentServices = mContext.getPackageManager().queryIntentServices(serviceIntent, 0); if (intentServices != null && !intentServices.isEmpty()) { // service available to handle that Intent mContext.bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE); } else { // no service available to handle that Intent mServiceConn = null; if (listener != null) { listener.onIabSetupFinished(new IabResult(BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE, "Billing service unavailable on device.")); } } }
From source file:cx.ring.service.LocalService.java
public Conference placeCall(SipCall call) { Conference conf = null;/* ww w .j a v a 2s.c om*/ CallContact contact = call.getContact(); if (contact == null) contact = findContactByNumber(call.getNumberUri()); Conversation conv = startConversation(contact); try { SipUri number = call.getNumberUri(); if (number == null || number.isEmpty()) number = contact.getPhones().get(0).getNumber(); String callId = mService.placeCall(call.getAccount(), number.getUriString()); if (callId == null || callId.isEmpty()) { //CallActivity.this.terminateCall(); return null; } call.setCallID(callId); Account acc = getAccount(call.getAccount()); if (acc.isRing() || acc.getSrtpDetails().getDetailBoolean(AccountDetailSrtp.CONFIG_SRTP_ENABLE) || acc.getTlsDetails().getDetailBoolean(AccountDetailTls.CONFIG_TLS_ENABLE)) { Log.i(TAG, "placeCall() call is secure"); SecureSipCall secureCall = new SecureSipCall(call, acc.getSrtpDetails().getDetailString(AccountDetailSrtp.CONFIG_SRTP_KEY_EXCHANGE)); conf = new Conference(secureCall); } else { conf = new Conference(call); } conf.getParticipants().get(0).setContact(contact); conv.addConference(conf); } catch (RemoteException e) { e.printStackTrace(); } return conf; }
From source file:org.gateshipone.odyssey.views.NowPlayingView.java
/** * Updates all sub-views with the new pbs states * * @param info the new pbs states including the current track *//*w ww . j av a 2 s.co m*/ private void updateStatus(NowPlayingInformation info) { // If called without a nowplayinginformation, ask the PBS directly for the information. // After the establishing of the service connection it can be that a track is playing and we've not yet received the NowPlayingInformation if (info == null) { try { info = mServiceConnection.getPBS().getNowPlayingInformation(); } catch (RemoteException e) { e.printStackTrace(); // an error occured so create a default instance to clear the view info = new NowPlayingInformation(); } } // notify playlist has changed mPlaylistView.playlistChanged(info); // get current track TrackModel currentTrack = info.getCurrentTrack(); // set tracktitle, album, artist and albumcover mTrackTitle.setText(currentTrack.getTrackName()); // Check if the album title changed. If true, start the cover generator thread. if (!currentTrack.getTrackAlbumKey().equals(mLastAlbumKey)) { // get tint color int tintColor = ThemeUtils.getThemeColor(getContext(), R.attr.odyssey_color_text_background_primary); Drawable drawable = getResources().getDrawable(R.drawable.cover_placeholder, null); drawable = DrawableCompat.wrap(drawable); DrawableCompat.setTint(drawable, tintColor); // Show the placeholder image until the cover fetch process finishes mCoverImage.setImageDrawable(drawable); tintColor = ThemeUtils.getThemeColor(getContext(), R.attr.odyssey_color_text_accent); drawable = getResources().getDrawable(R.drawable.cover_placeholder_96dp, null); drawable = DrawableCompat.wrap(drawable); DrawableCompat.setTint(drawable, tintColor); // The same for the small header image mTopCoverImage.setImageDrawable(drawable); // Start the cover loader mCoverLoader.getImage(currentTrack); } // Save the name of the album for rechecking later mLastAlbumKey = currentTrack.getTrackAlbumKey(); // Set the artist of the track String trackInformation = ""; if (!currentTrack.getTrackArtistName().isEmpty() && !currentTrack.getTrackAlbumName().isEmpty()) { trackInformation = getResources().getString(R.string.track_title_template, currentTrack.getTrackArtistName(), currentTrack.getTrackAlbumName()); } else if (!currentTrack.getTrackArtistName().isEmpty()) { trackInformation = currentTrack.getTrackArtistName(); } else if (!currentTrack.getTrackAlbumName().isEmpty()) { trackInformation = currentTrack.getTrackAlbumName(); } mTrackSubtitle.setText(trackInformation); // Calculate the margin to avoid cut off textviews RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mHeaderTextLayout .getLayoutParams(); layoutParams.setMarginEnd((int) (mTopPlaylistButton.getWidth() * (1.0 - mDragOffset))); mHeaderTextLayout.setLayoutParams(layoutParams); // Set the track duration mDuration.setText(FormatHelper.formatTracktimeFromMS(getContext(), currentTrack.getTrackDuration())); // set up seekbar (set maximum value, track total duration) mPositionSeekbar.setMax((int) currentTrack.getTrackDuration()); // update seekbar and elapsedview updateTrackPosition(); // save the state mPlaybackServiceState = info.getPlayState(); // update buttons // update play buttons switch (mPlaybackServiceState) { case PLAYING: mTopPlayPauseButton.setImageResource(R.drawable.ic_pause_48dp); mBottomPlayPauseButton.setImageResource(R.drawable.ic_pause_circle_fill_48dp); // start refresh task if view is visible if (mDragOffset == 0.0f) { startRefreshTask(); } break; case PAUSE: case RESUMED: case STOPPED: mTopPlayPauseButton.setImageResource(R.drawable.ic_play_arrow_48dp); mBottomPlayPauseButton.setImageResource(R.drawable.ic_play_circle_fill_48dp); // stop refresh task stopRefreshTask(); break; } // update repeat button switch (info.getRepeat()) { case REPEAT_OFF: mBottomRepeatButton.setImageResource(R.drawable.ic_repeat_24dp); mBottomRepeatButton.setImageTintList(ColorStateList .valueOf(ThemeUtils.getThemeColor(getContext(), R.attr.odyssey_color_text_accent))); break; case REPEAT_ALL: mBottomRepeatButton.setImageResource(R.drawable.ic_repeat_24dp); mBottomRepeatButton.setImageTintList( ColorStateList.valueOf(ThemeUtils.getThemeColor(getContext(), android.R.attr.colorAccent))); break; case REPEAT_TRACK: mBottomRepeatButton.setImageResource(R.drawable.ic_repeat_one_24dp); mBottomRepeatButton.setImageTintList( ColorStateList.valueOf(ThemeUtils.getThemeColor(getContext(), android.R.attr.colorAccent))); break; } // update random button switch (info.getRandom()) { case RANDOM_OFF: mBottomRandomButton.setImageTintList(ColorStateList .valueOf(ThemeUtils.getThemeColor(getContext(), R.attr.odyssey_color_text_accent))); break; case RANDOM_ON: mBottomRandomButton.setImageTintList( ColorStateList.valueOf(ThemeUtils.getThemeColor(getContext(), android.R.attr.colorAccent))); break; } }
From source file:com.yangtsaosoftware.pebblemessenger.services.PebbleCenter.java
@Override public void onCreate() { super.onCreate(); Handler pebbleCenterHandler = new PebbleCenterHandler(); mPebbleCenterHandler = new Messenger(pebbleCenterHandler); Constants.log(TAG_NAME, "Create PebbleCenter Messenger."); loadPref();/*from ww w . j a v a2 s.c o m*/ _contex = this; // busyBegin=new Time(); // waitQueue=new ArrayDeque<PebbleMessage>(); sendQueue = new ArrayDeque<PebbleDictionary>(); bindService(new Intent(this, MessageProcessingService.class), connToMessageProcessing, Context.BIND_AUTO_CREATE); Thread prepareThread = new PrepareThread(); prepareThread.start(); Thread sendMsgThread = new SendMsgThread(); sendMsgThread.start(); isPebbleEnable = PebbleKit.isWatchConnected(_contex); PebbleKit.registerReceivedDataHandler(_contex, new PebbleKit.PebbleDataReceiver(Constants.PEBBLE_UUID) { @Override public void receiveData(Context context, int transactionId, PebbleDictionary data) { PebbleKit.sendAckToPebble(_contex, transactionId); // appStatue++; Constants.log(TAG_NAME, "Received data form pebble"); switch (data.getUnsignedIntegerAsLong(ID_COMMAND).intValue()) { case REQUEST_TRANSID_CALL_TABLE: { Constants.log(TAG_NAME, "Request call table."); clean_SendQue(); Message msg = Message.obtain(); msg.what = MessageProcessingService.MSG_GET_CALL_TABLE; try { rMessageProcessingHandler.send(msg); } catch (RemoteException e) { e.printStackTrace(); } } break; case REQUEST_TRANSID_MESSAGE_TABLE: { Constants.log(TAG_NAME, "Request message table."); clean_SendQue(); Message msg = Message.obtain(); msg.what = MessageProcessingService.MSG_GET_MESSAGE_TABLE; try { rMessageProcessingHandler.send(msg); } catch (RemoteException e) { e.printStackTrace(); } } break; case REQUEST_TRANSID_CALL: { clean_SendQue(); Message msg = Message.obtain(); msg.what = MessageProcessingService.MSG_GET_CALL; Bundle b = new Bundle(); b.putString(MessageDbHandler.COL_CALL_ID, data.getString(ID_EXTRA_DATA)); Constants.log(TAG_NAME, "Request call id:" + data.getString(ID_EXTRA_DATA)); msg.setData(b); try { rMessageProcessingHandler.send(msg); } catch (RemoteException e) { e.printStackTrace(); } } break; case REQUEST_TRANSID_MESSAGE: clean_SendQue(); Message msg = Message.obtain(); msg.what = MessageProcessingService.MSG_GET_MESSAGE; Bundle b = new Bundle(); b.putString(MessageDbHandler.COL_MESSAGE_ID, data.getString(ID_EXTRA_DATA)); Constants.log(TAG_NAME, "Request message id:" + data.getString(ID_EXTRA_DATA)); msg.setData(b); try { rMessageProcessingHandler.send(msg); } catch (RemoteException e) { e.printStackTrace(); } break; case REQUEST_TRANSID_PICKUP_PHONE: TelephonyManager telMag = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); Constants.log("Receivephone", "Receive phone:" + data.getString(ID_EXTRA_DATA2)); if (telMag.getCallState() == TelephonyManager.CALL_STATE_RINGING) { switch (data.getUnsignedIntegerAsLong(ID_EXTRA_DATA).intValue()) { case REQUEST_EXTRA_SPEAKER_ON: answerCall(true); break; case REQUEST_EXTRA_SPEAKER_OFF: answerCall(false); break; } } else { switch (data.getUnsignedIntegerAsLong(ID_EXTRA_DATA).intValue()) { case REQUEST_EXTRA_SPEAKER_ON: dialNumber(data.getString(ID_EXTRA_DATA2), true); break; case REQUEST_EXTRA_SPEAKER_OFF: dialNumber(data.getString(ID_EXTRA_DATA2), false); break; } } // pebbleBusy = false; break; case REQUEST_TRANSID_HANGOFF_PHONE: endCall(); // pebbleBusy=false; break; case REQUEST_TRANSID_HANGOFF_SMS1: Constants.log(TAG_NAME, "Request hangoff and send sms1"); endCall(); doSendSMSTo(data.getString(ID_EXTRA_DATA), sms1); // pebbleBusy=false; break; case REQUEST_TRANSID_HANGOFF_SMS2: Constants.log(TAG_NAME, "Request hangoff and send sms2"); endCall(); doSendSMSTo(data.getString(ID_EXTRA_DATA), sms2); // pebbleBusy=false; break; case REQUEST_TRANSID_CLOSE_APP: Constants.log(TAG_NAME, "Request close app command."); sendMsgThreadHandler.sendEmptyMessage(SEND_CLOSE_APP); // need_delay=true; break; case REQUEST_TRANSID_NEXTPAGE: Constants.log(TAG_NAME, "Request send next page."); sendMsgThreadHandler.sendEmptyMessage(SEND_NEXT_PAGE); break; case REQUEST_TRANSID_READ_NOTIFY: { Constants.log(TAG_NAME, "Request read msg"); Message read_msg = Message.obtain(); read_msg.what = MessageProcessingService.MSG_READ; Bundle bd = new Bundle(); bd.putString(MessageDbHandler.COL_MESSAGE_ID, data.getUnsignedIntegerAsLong(ID_EXTRA_DATA).toString()); read_msg.setData(bd); try { rMessageProcessingHandler.send(read_msg); } catch (RemoteException e) { e.printStackTrace(); } } break; case REQUEST_TRANSID_IM_FREE: Constants.log(TAG_NAME, "Request pebble app is free to receive data."); // need_delay = data.getUnsignedInteger(ID_EXTRA_DATA).intValue() == REQUEST_EXTRA_DELAY_ON ; // clean_SendQue(); break; case REQUEST_TRANSID_VERSION: { send_test_get_return = true; String result = data.getString(ID_EXTRA_DATA); Constants.log("PmpVersion", result); StringTokenizer tokens = new StringTokenizer(result, "."); Intent inner_intent = new Intent(SetupFragment.class.getName()); inner_intent.putExtra(Constants.BROADCAST_VERSION, new byte[] { Byte.parseByte(tokens.nextToken()), Byte.parseByte(tokens.nextToken()), Byte.parseByte(tokens.nextToken()) }); LocalBroadcastManager.getInstance(context).sendBroadcast(inner_intent); sendMsgThreadHandler.sendEmptyMessage(SEND_CLOSE_APP); break; } } } }); PebbleKit.registerReceivedAckHandler(_contex, new PebbleKit.PebbleAckReceiver(Constants.PEBBLE_UUID) { @Override public void receiveAck(Context context, int transactionId) { Constants.log(TAG_NAME, "Get a receiveAck:" + String.valueOf(transactionId)); switch (transactionId) { case TRANS_ID_COMMON: Constants.log(TAG_NAME, "Send continue..."); // pebbleBusy=true; sendMsgThreadHandler.sendEmptyMessage(SEND_CONTINUE); break; case TRANS_ID_END: send_full_page = true; break; case TRANS_ID_EMPTY: // pebbleBusy=true; sendMsgThreadHandler.sendEmptyMessage(SEND_CONTINUE); break; case TRANS_ID_TEST: { break; } } } }); PebbleKit.registerReceivedNackHandler(_contex, new PebbleKit.PebbleNackReceiver(Constants.PEBBLE_UUID) { @Override public void receiveNack(Context context, int transactionId) { Constants.log(TAG_NAME, "Get a receivedNack:" + String.valueOf(transactionId)); if (PebbleKit.isWatchConnected(_contex)) { switch (transactionId) { case TRANS_ID_COMMON: sendMsgThreadHandler.sendEmptyMessage(SEND_CONTINUE); break; case TRANS_ID_END: send_full_page = true; break; case TRANS_ID_EMPTY: // appStatue=0; sendMsgThreadHandler.sendEmptyMessage(SEND_OPEN_APP); break; case TRANS_ID_TEST: { Intent inner_intent = new Intent(SetupFragment.class.getName()); inner_intent.putExtra(Constants.BROADCAST_VERSION, new byte[] { 0, 0, 0 }); LocalBroadcastManager.getInstance(context).sendBroadcast(inner_intent); } } } else { sendMsgThreadHandler.sendEmptyMessage(SEND_CLOSE_APP); } } }); PebbleKit.registerPebbleConnectedReceiver(_contex, new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { isPebbleEnable = true; } }); PebbleKit.registerPebbleDisconnectedReceiver(_contex, new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { isPebbleEnable = false; sendMsgThreadHandler.sendEmptyMessage(SEND_CLOSE_APP); } }); BroadcastReceiver br = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { int command = intent.getIntExtra(Constants.BROADCAST_COMMAND, Constants.BROADCAST_PREFER_CHANGED); switch (command) { case Constants.BROADCAST_PREFER_CHANGED: loadPref(); break; case Constants.BROADCAST_CALL_IDLE: if (callEnable) { sendMsgThreadHandler.sendEmptyMessage(SEND_CALL_END); } break; case Constants.BROADCAST_CALL_HOOK: if (callEnable) { sendMsgThreadHandler.sendEmptyMessage(SEND_CALL_HOOK); } break; case Constants.BROADCAST_PEBBLE_TEST: if (isPebbleEnable) { prepareThreadHandler.sendEmptyMessage(PREPARE_TEST); } break; } } }; IntentFilter intentFilter = new IntentFilter(PebbleCenter.class.getName()); LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(br, intentFilter); }