Exemplo n.º 1
0
 @Override
 public void surfaceCreated(SurfaceHolder holder) {
   Thread thread = null;
   thread = new Thread(this);
   flag = true;
   thread.start();
 }
Exemplo n.º 2
0
 private void downloadImageThread() {
   Thread thread = new Thread(null, runInBackground, "Background");
   thread.start();
   try {
     thread.join();
   } catch (InterruptedException e) {
     e.printStackTrace();
   }
 }
Exemplo n.º 3
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.classes);

    setcc();

    Log.e("n", " CC Activity Started");
    try {
      Class<?> strictModeClass =
          Class.forName(
              "android.os.StrictMode", true, Thread.currentThread().getContextClassLoader());

      Class<?> threadPolicyClass =
          Class.forName(
              "android.os.StrictMode$ThreadPolicy",
              true,
              Thread.currentThread().getContextClassLoader());

      Class<?> threadPolicyBuilderClass =
          Class.forName(
              "android.os.StrictMode$ThreadPolicy$Builder",
              true,
              Thread.currentThread().getContextClassLoader());

      Method setThreadPolicyMethod =
          strictModeClass.getMethod("setThreadPolicy", threadPolicyClass);

      Method detectAllMethod = threadPolicyBuilderClass.getMethod("detectAll");
      Method penaltyMethod = threadPolicyBuilderClass.getMethod("penaltyLog");
      Method buildMethod = threadPolicyBuilderClass.getMethod("build");

      Constructor<?> threadPolicyBuilderConstructor = threadPolicyBuilderClass.getConstructor();
      Object threadPolicyBuilderObject = threadPolicyBuilderConstructor.newInstance();

      Object obj = detectAllMethod.invoke(threadPolicyBuilderObject);

      obj = penaltyMethod.invoke(obj);
      Object threadPolicyObject = buildMethod.invoke(obj);
      setThreadPolicyMethod.invoke(strictModeClass, threadPolicyObject);

    } catch (Exception ex) {
      Log.w("n", "Strict not enabled....");
    }

    final Button button = (Button) findViewById(R.id.ccbutton1);
    button.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            setcc();
          }
        });
  }
Exemplo n.º 4
0
  private void restartMap() {
    breakMapThread = true;
    postInvalidate();
    if (mapThread != null)
      try {
        mapThread.join(1500);
      } catch (InterruptedException ie) {

      }
    mapThread = new Thread(this);
    mapThread.start();
  }
 public void wait_ble(int i) {
   try {
     Thread.sleep(i);
   } catch (Exception e) {
     // ignore
   }
 }
Exemplo n.º 6
0
 private void sleep(int time) {
   try {
     Thread.sleep(time);
   } catch (InterruptedException e) {
     e.printStackTrace();
   }
 }
Exemplo n.º 7
0
 public void setOverlay(MapOverlay overlay) {
   useOverlay = overlay;
   if (!mapThreadRunning) {
     mapThread = new Thread(this);
     mapThread.start();
   }
 }
Exemplo n.º 8
0
  void requestAccountList() {
    prog =
        ProgressDialog.show(
            this,
            null,
            getString(R.string.account_list_progress),
            false,
            true,
            new DialogInterface.OnCancelListener() {
              public void onCancel(DialogInterface dialog) {
                cancel();
              }
            });

    queryThread = new Thread(this, "Requestor Thread");
    queryThread.setDaemon(true);
    queryThread.start();
  }
Exemplo n.º 9
0
  @Override
  public void run() {
    while (flag) {
      myDraw();
      try {
        Thread.sleep(50);
      } catch (InterruptedException e) {

      }
    }
  }
Exemplo n.º 10
0
 private void RunDisConnectionInThread() {
   Thread thread =
       new Thread(
           new Runnable() {
             public void run() {
               int pid = getPIDof("pppd");
               String killPPPD = "";
               if (pid != -1) {
                 killPPPD = "kill " + pid;
               }
               String output =
                   Commands2script(
                       new String[] {
                         killPPPD, "sleep 1", mRFCOMM + " release " + myDigit,
                       });
               outputInfo(output);
             }
           });
   thread.start();
 }
Exemplo n.º 11
0
 @Override
 protected Void doInBackground(Integer... params) {
   //
   try {
     Thread.sleep(params[0]);
   } catch (InterruptedException e) {
     //
     e.printStackTrace();
   }
   return null;
 }
Exemplo n.º 12
0
  /** 线程运行的方法,当线程start后执行 */
  @Override
  public void run() {

    while (flag) {
      mDraw(); // 调用自定义的绘图方法
      mGameLogic(); // 调用自定义的逻辑方法
      try {
        Thread.sleep(50); // 让线程休息50毫秒
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
Exemplo n.º 13
0
 public void handleMessage(Message msg) {
   mValue++;
   mText.setText(Integer.toString(mValue));
   try {
     Thread.sleep(50);
   } catch (InterruptedException e) {;
   }
   if (mValue < 100 && mQuit == false) {
     mProgress.setProgress(mValue);
     mHandler.sendEmptyMessage(0);
   } else {
     dismissDialog(0);
   }
 }
Exemplo n.º 14
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "onCreate");
    super.onCreate(savedInstanceState);
    Thread.currentThread().setUncaughtExceptionHandler(this);
    setContentView(R.layout.main);

    inputView = (EditText) findViewById(R.id.input_view);
    inputView.setOnEditorActionListener(this);

    listAdapter = new ArrayAdapter<String>(this, R.layout.row);
    listAdapter.setNotifyOnChange(true);

    resultsView = (ListView) this.findViewById(R.id.results_view);
    resultsView.setAdapter(listAdapter);
    resultsView.setOnItemClickListener(this);
  }
Exemplo n.º 15
0
 @SuppressWarnings("unused")
 @Override
 public void onDestroy() {
   super.onDestroy();
   // Stop the Bluetooth chat services
   if (D) Log.e(TAG, "--- ON DESTROY ---");
   if (false) {
     RunDisConnectionInThread();
     try {
       Thread.sleep(2000);
     } catch (InterruptedException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
   mStatusTimer.cancel();
   finish();
 }
Exemplo n.º 16
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.contactslist);
    contactsList = new ArrayList<String>();
    getcontactsList = new ArrayList<String>();

    final ListView listView = getListView();
    listView.setItemsCanFocus(false);
    listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    okbtn = (Button) findViewById(R.id.contacts_done_button);
    cancelbtn = (Button) findViewById(R.id.contact_back_button);
    okbtn.setOnClickListener(this);
    cancelbtn.setOnClickListener(this);

    getcontacts = new Thread(new GetContacts());
    getcontacts.start();
    proDialog = ProgressDialog.show(ContactsListMultiple.this, "loading", "loading", true, true);
  }
Exemplo n.º 17
0
  @Override
  protected Void doInBackground(Void... v) {
    while (toContinue) {
      try {
        Thread.sleep(interval);
      } catch (InterruptedException e) {
        break;
      }

      HashMap<String, String> currentStatus = getGPIOStatus();
      boolean same = isSame(currentStatus, GPIOStatus);
      Log.i("INFO", String.valueOf(same));
      if (same) continue;

      GPIOStatus = currentStatus;
      publishProgress();
    }
    return null;
  }
Exemplo n.º 18
0
  @Override
  public void onCreate(Bundle bundle) {
    super.onCreate(bundle);

    Thread.setDefaultUncaughtExceptionHandler(
        new org.geometerplus.zlibrary.ui.android.library.UncaughtExceptionHandler(this));
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);

    final SearchManager manager = (SearchManager) getSystemService(SEARCH_SERVICE);
    manager.setOnCancelListener(null);

    final TabHost host = getTabHost();
    LayoutInflater.from(this).inflate(R.layout.bookmarks, host.getTabContentView(), true);

    myBook = SerializerUtil.deserializeBook(getIntent().getStringExtra(FBReader.BOOK_KEY));
  }
Exemplo n.º 19
0
  /** 当SurfaceView创建的时候调用 */
  @Override
  public void surfaceCreated(SurfaceHolder holder) {

    // 获得屏幕的宽和高
    screenW = this.getWidth();
    screenH = this.getHeight();

    qEndX = screenW - 10; // 设置贝塞尔曲线的终点横坐标为屏幕宽度减10
    qEndY = qStartY; // 设置贝塞尔曲线的终点纵坐标和起点纵坐标一样

    // 设置贝塞尔曲线的控制点坐标为终点坐标与起点坐标对应的差值的一半,注意这里不是曲线的中点
    qControlX = (qEndX - qStartX) / 2;
    qCOntrolY = (qEndY - qStartY) / 2;

    mThread = new Thread(this); // 创建线程对象
    flag = true; // 设置线程标识为true
    xReturn = false; // 设置图形坐标不返回
    cReturn = false; // 设置贝塞尔曲线控制点坐标不返回
    mThread.start(); // 启动线程
  }
Exemplo n.º 20
0
    @Override
    protected String doInBackground(String... arg0) {
      // TODO Auto-generated method stub
      String data = null;
      FileInputStream fis = null;

      for (int i = 0; i < 25; i++) {
        // referencing progressupdate method
        publishProgress(4);
        try {
          Thread.sleep(100);
        } catch (InterruptedException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }

      dial.dismiss();
      try {
        fis = openFileInput(FILENAME);
        byte[] arr = new byte[fis.available()]; // getting number of bytes in fis
        while (fis.read(arr) != -1) ; // reading the bytes in fis
        {
          data = new String(arr);
        }
      } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } finally {
        try {
          fis.close();
        } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
      return data;
    }
Exemplo n.º 21
0
  /**
   * Creates new call to given <tt>destination</tt> using selected <tt>provider</tt>.
   *
   * @param context the android context
   * @param destination target callee name.
   * @param provider the provider that will be used to make a call.
   */
  public static void createCall(
      final Context context, final String destination, final ProtocolProviderService provider) {
    if (createCallThread != null) {
      logger.warn("Another call is already being created");
      return;
    } else if (CallManager.getActiveCallsCount() > 0) {
      logger.warn("Another call is in progress");
      return;
    }

    final long dialogId =
        ProgressDialogFragment.showProgressDialog(
            JitsiApplication.getResString(R.string.service_gui_OUTGOING_CALL),
            JitsiApplication.getResString(R.string.service_gui_OUTGOING_CALL_MSG, destination));

    createCallThread =
        new Thread("Create call thread") {
          public void run() {
            try {
              CallManager.createCall(provider, destination);
            } catch (Throwable t) {
              logger.error("Error creating the call: " + t.getMessage(), t);
              AndroidUtils.showAlertDialog(
                  context, context.getString(R.string.service_gui_ERROR), t.getMessage());
            } finally {
              if (DialogActivity.waitForDialogOpened(dialogId)) {
                DialogActivity.closeDialog(JitsiApplication.getGlobalContext(), dialogId);
              } else {
                logger.error("Failed to wait for the dialog: " + dialogId);
              }
              createCallThread = null;
            }
          }
        };

    createCallThread.start();
  }
Exemplo n.º 22
0
  @Override
  public void onCreate(Bundle bundle) {
    super.onCreate(bundle);

    Thread.setDefaultUncaughtExceptionHandler(
        new org.geometerplus.zlibrary.ui.android.library.UncaughtExceptionHandler(this));

    // requestWindowFeature(Window.FEATURE_NO_TITLE);
    setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);

    final TabHost host = getTabHost();
    LayoutInflater.from(this).inflate(R.layout.bookmarks, host.getTabContentView(), true);

    AllBooksBookmarks = Bookmark.bookmarks();
    Collections.sort(AllBooksBookmarks, new Bookmark.ByTimeComparator());
    final FBReader fbreader = (FBReader) FBReader.Instance();

    if (fbreader.Model != null) {
      final long bookId = fbreader.Model.Book.getId();
      for (Bookmark bookmark : AllBooksBookmarks) {
        if (bookmark.getBookId() == bookId) {
          myThisBookBookmarks.add(bookmark);
        }
      }

      myThisBookView = createTab("thisBook", R.id.this_book);
      new BookmarksAdapter(myThisBookView, myThisBookBookmarks, true);
    } else {
      findViewById(R.id.this_book).setVisibility(View.GONE);
    }

    myAllBooksView = createTab("allBooks", R.id.all_books);
    new BookmarksAdapter(myAllBooksView, AllBooksBookmarks, false);

    findViewById(R.id.search_results).setVisibility(View.GONE);
  }
Exemplo n.º 23
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    mAppContext = this;
    mMainHandler = new Handler();

    if (!sTryCatchAttached) {
      sTryCatchAttached = true;
      mMainHandler.post(
          new Runnable() {
            public void run() {
              try {
                Looper.loop();
              } catch (Exception e) {
                Log.e(LOG_FILE_NAME, "top level exception", e);
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                e.printStackTrace(pw);
                pw.flush();
                GeckoAppShell.reportJavaCrash(sw.toString());
              }
              // resetting this is kinda pointless, but oh well
              sTryCatchAttached = false;
            }
          });
    }

    SharedPreferences settings = getPreferences(Activity.MODE_PRIVATE);
    String localeCode = settings.getString(getPackageName() + ".locale", "");
    if (localeCode != null && localeCode.length() > 0) GeckoAppShell.setSelectedLocale(localeCode);

    Log.i(LOG_FILE_NAME, "create");
    super.onCreate(savedInstanceState);

    if (sGREDir == null) sGREDir = new File(this.getApplicationInfo().dataDir);

    getWindow()
        .setFlags(
            mFullscreen ? WindowManager.LayoutParams.FLAG_FULLSCREEN : 0,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    if (cameraView == null) {
      cameraView = new SurfaceView(this);
      cameraView.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    }

    if (surfaceView == null) surfaceView = new GeckoSurfaceView(this);
    else mainLayout.removeAllViews();

    mainLayout = new AbsoluteLayout(this);
    mainLayout.addView(
        surfaceView,
        new AbsoluteLayout.LayoutParams(
            AbsoluteLayout.LayoutParams.MATCH_PARENT, // level 8
            AbsoluteLayout.LayoutParams.MATCH_PARENT,
            0,
            0));

    setContentView(
        mainLayout,
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

    mConnectivityFilter = new IntentFilter();
    mConnectivityFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
    mConnectivityReceiver = new GeckoConnectivityReceiver();

    IntentFilter batteryFilter = new IntentFilter();
    batteryFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
    mBatteryReceiver = new GeckoBatteryManager();
    registerReceiver(mBatteryReceiver, batteryFilter);

    if (SmsManager.getInstance() != null) {
      SmsManager.getInstance().start();
    }

    GeckoNetworkManager.getInstance().init();

    if (!checkAndSetLaunchState(LaunchState.PreLaunch, LaunchState.Launching)) return;

    checkAndLaunchUpdate();
    mLibLoadThread =
        new Thread(
            new Runnable() {
              public void run() {
                // At some point while loading the gecko libs our default locale gets set
                // so just save it to locale here and reset it as default after the join
                Locale locale = Locale.getDefault();
                GeckoAppShell.loadGeckoLibs(getApplication().getPackageResourcePath());
                Locale.setDefault(locale);
                Resources res = getBaseContext().getResources();
                Configuration config = res.getConfiguration();
                config.locale = locale;
                res.updateConfiguration(config, res.getDisplayMetrics());
              }
            });
    mLibLoadThread.start();
  }
  public void OnResume(final SharedPreferences prefs) {
    super.OnResume();

    if (_seekBar != null) {
      if (prefs.getBoolean("PuzzleShowSeekBar", true)) {
        _seekBar.setVisibility(View.VISIBLE);

      } else {
        _seekBar.setVisibility(View.GONE);
      }
    }

    ChessImageView._colorScheme = prefs.getInt("ColorScheme", 0);

    _view.setFlippedBoard(prefs.getBoolean("flippedBoard", false));

    _iPos = prefs.getInt("puzzlePos", 0);

    getNumPuzzles();

    if (_num == 0) {

      _num = 500; // first puzzle set has fixed amount
      _progressDlg =
          ProgressDialog.show(
              _parent,
              _parent.getString(R.string.title_installing),
              _parent.getString(R.string.msg_wait),
              false,
              false);

      // if(iTmp > 0)
      //	_cr.delete(MyPuzzleProvider.CONTENT_URI_PUZZLES, "1=1", null);

      _thread =
          new Thread(
              new Runnable() {
                public void run() {

                  try {
                    InputStream is = _parent.getAssets().open("puzzles.pgn");

                    StringBuffer sb = new StringBuffer();
                    String s = "", data;
                    int pos1 = 0, pos2 = 0, len;
                    byte[] buffer = new byte[2048];

                    while ((len = is.read(buffer, 0, buffer.length)) != -1) {
                      data = new String(buffer, 0, len);
                      sb.append(data);
                      pos1 = sb.indexOf("[Event \"");
                      while (pos1 >= 0) {
                        pos2 = sb.indexOf("[Event \"", pos1 + 10);
                        if (pos2 == -1) break;
                        s = sb.substring(pos1, pos2);

                        processPGN(s);

                        sb.delete(0, pos2);

                        pos1 = sb.indexOf("[Event \"");
                      }
                      // break;

                      // Log.i("run", "left: " + sb);
                      // break;
                    }
                    processPGN(sb.toString());

                    Log.i("run", "Count " + _cnt);

                    Message msg = new Message();
                    msg.what = 1;
                    m_threadHandler.sendMessage(msg);

                    is.close();

                  } catch (Exception ex) {
                    Log.e("Install", ex.toString());
                  }
                }
              });
      _thread.start();

      return;
    }

    play();
  }
Exemplo n.º 25
0
  private void RunConnectionInThread(final String MAC) {
    Thread thread =
        new Thread(
            new Runnable() {
              public void run() {
                outputInfo("Executing sdptool...");
                String output = Commands2script(new String[] {"sdptool browse " + MAC});

                String channel = FindChannel(output);
                if (channel == null) {
                  outputInfo("DUN not found");
                  return;
                }
                outputInfo("Channel is " + channel + " executing rfcomm...");

                output =
                    Commands2script(
                        new String[] {
                          mRFCOMM + " bind " + myDigit + " " + MAC + " " + channel,
                          "sleep 1",
                          mRFCOMM,
                          "sleep 1",
                        });
                outputInfo(output);

                String chatFile = GenerateChatFile();
                output =
                    Commands2script(
                        new String[] {
                          mPPPD
                              + " /dev/rfcomm"
                              + myDigit
                              + " "
                              + "defaultroute "
                              + "usepeerdns "
                              + "noauth "
                              + "debug "
                              + "unit "
                              + myDigit
                              + " "
                              +
                              // "nodetach " +
                              "connect "
                              + "\""
                              + mChatName
                              + " -v -f "
                              + chatFile
                              + "\""
                        });

                boolean bEndWhile = true;
                boolean bSuccess = false;
                do {

                  long l = getPIDof("pppd");
                  if (l == -1) {
                    bEndWhile = false;
                  } else {
                    String IP = FindIP();
                    if (IP != null) {
                      bEndWhile = false;
                      bSuccess = true;
                      outputInfo("IP is: " + IP.substring(1));
                    }
                  }
                  try {
                    Thread.sleep(900);
                  } catch (InterruptedException e) {
                    e.printStackTrace();
                  }
                } while (bEndWhile);
                if (bSuccess) {
                  Commands2script(new String[] {"setprop net.dns1 8.8.8.8"});
                }
                File file = new File(chatFile);
                file.delete();
              }
            });
    thread.start();
  }
Exemplo n.º 26
0
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    Thread.setDefaultUncaughtExceptionHandler(new MyExceptionHandler(this));
    Colors.updateColors(this);
    startService(new Intent(this, JTalkService.class));
    service = JTalkService.getInstance();
    prefs = PreferenceManager.getDefaultSharedPreferences(this);
    setTheme(Colors.isLight ? R.style.AppThemeLight : R.style.AppThemeDark);

    setContentView(R.layout.roster);

    LinearLayout roster = (LinearLayout) findViewById(R.id.roster_linear);
    roster.setBackgroundColor(Colors.BACKGROUND);

    getActionBar().setHomeButtonEnabled(true);

    statusArray = getResources().getStringArray(R.array.statusArray);
    rosterAdapter = new RosterAdapter(this);
    simpleAdapter = new NoGroupsAdapter(this);
    searchAdapter = new SearchAdapter(this);

    int cols = 1;
    if (!prefs.getBoolean("ShowGroups", true) && !prefs.getBoolean("ShowMucGroup", false)) {
      try {
        cols = Integer.parseInt(prefs.getString("RosterColumns", "1"));
      } catch (Exception e) {
        cols = 1;
      }
    }
    gridView = (GridView) findViewById(R.id.users);
    gridView.setNumColumns(cols);
    gridView.setCacheColorHint(0x00000000);
    gridView.setOnItemClickListener(this);
    gridView.setOnItemLongClickListener(this);
    gridView.setAdapter(rosterAdapter);

    if (getIntent().getBooleanExtra("status", false)) {
      RosterDialogs.changeStatusDialog(this, null, null);
    }

    if (getIntent().getBooleanExtra("password", false)) {
      String account = getIntent().getStringExtra("account");
      RosterDialogs.passwordDialog(this, account);
    }

    if (getIntent().getBooleanExtra("subscribtion", false)) {
      String account = getIntent().getStringExtra("account");
      String jid = getIntent().getStringExtra("jid");
      RosterDialogs.subscribtionRequestDialog(this, account, jid);
    }

    File table = new File(Constants.PATH_SMILES + "/default/table.xml");
    if (!table.exists()) {
      new CreateDefaultSmiles().execute();
    } else {
      Cursor cursor =
          getContentResolver()
              .query(
                  JTalkProvider.ACCOUNT_URI,
                  null,
                  AccountDbHelper.ENABLED + " = '" + 1 + "'",
                  null,
                  null);
      if (cursor == null || cursor.getCount() < 1) startActivity(new Intent(this, Accounts.class));
    }

    if (prefs.getBoolean("BUG", false)) {
      new ErrorDialog(this).show();
    }

    String action = getIntent().getAction();
    if (action != null && action.equals(Intent.ACTION_VIEW)) {
      Uri data = getIntent().getData();
      if (data != null && data.getScheme().equals("xmpp")) {
        XMPPUri xmppUri;
        try {
          xmppUri = new XMPPUri(data);
        } catch (IllegalArgumentException e) {
          xmppUri = null;
        }

        List<String> accounts = new ArrayList<String>();
        for (XMPPConnection connection : service.getAllConnections()) {
          accounts.add(StringUtils.parseBareAddress(connection.getUser()));
        }

        if (xmppUri != null && !accounts.isEmpty()) {
          final String xmppJid = xmppUri.getJid();
          final String body = xmppUri.getBody();
          String queryType = xmppUri.getQueryType();

          final ArrayAdapter<String> adapter =
              new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, accounts);

          if (queryType.equals("roster")) {
            RosterDialogs.addDialog(this, xmppUri.getJid());
          } else if (queryType.equals("join")) {
            if (accounts.size() > 1) {
              AlertDialog.Builder builder = new AlertDialog.Builder(this);
              builder.setTitle(R.string.Accounts);
              builder.setAdapter(
                  adapter,
                  new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      String account = adapter.getItem(which);
                      MucDialogs.joinDialog(RosterActivity.this, account, xmppJid, null);
                    }
                  });
              builder.create().show();
            } else MucDialogs.joinDialog(RosterActivity.this, accounts.get(0), xmppJid, null);
          } else {
            service.setText(xmppJid, body);
            if (accounts.size() > 1) {
              service.setText(xmppJid, body);
              AlertDialog.Builder builder = new AlertDialog.Builder(this);
              builder.setTitle(R.string.Accounts);
              builder.setAdapter(
                  adapter,
                  new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                      String account = adapter.getItem(which);
                      Intent intent = new Intent(RosterActivity.this, Chat.class);
                      intent.putExtra("account", account);
                      intent.putExtra("jid", xmppJid);
                      startActivity(intent);
                    }
                  });
              builder.create().show();
            } else {
              Intent intent = new Intent(RosterActivity.this, Chat.class);
              intent.putExtra("account", accounts.get(0));
              intent.putExtra("jid", xmppJid);
              startActivity(intent);
            }
          }
        }
      }
    }
  }