Пример #1
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       replaceByScenesView();
       return true;
     case R.id.menu_lightcontrol:
       replaceByLightControlView();
       return true;
     case R.id.menu_disconnect:
       LedApplication.getServerconnection().CloseConnection();
       return true;
     case R.id.menu_voicecmd:
       Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
       intent.putExtra(
           RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
       intent.putExtra(RecognizerIntent.EXTRA_PROMPT, R.string.voicecmd);
       startActivityForResult(intent, 'r');
       return true;
   }
   return super.onOptionsItemSelected(item);
 }
Пример #2
0
 @Override
 protected void onUserLeaveHint() {
   super.onUserLeaveHint();
   LedApplication.getConnectionObserver().stop();
   LedApplication.getServerconnection().CloseConnection();
 }