Beispiel #1
0
  public void vibrate(int duration) {

    Context ctx = AndroidMeApp.getContext();
    Vibrator vibrator = (Vibrator) ctx.getSystemService(Activity.VIBRATOR_SERVICE);

    vibrator.vibrate(duration);
  }
Beispiel #2
0
 /** http://developer.android.com/resources/articles/painless-threading.html */
 public void callSerially(Runnable runner) {
   if (AndroidMeActivity.DEFAULT_ACTIVITY == null) {
     AndroidMeApp.getIntance().invokeLater(runner);
   } else {
     AndroidMeActivity.DEFAULT_ACTIVITY.runOnUiThread(runner);
   }
 }
Beispiel #3
0
  public ContactEnumeration(ContactDao contactDao) {
    this.contactDao = contactDao;
    this.contentResolver = AndroidMeApp.getContext().getContentResolver();
    this.peopleCursor = this.contentResolver.query(People.CONTENT_URI, null, null, null, null);
    // JP		this.peopleCursor = this.contentResolver.query(ContactsContract.Contacts.CONTENT_URI,
    // null, null, null, null);

    this.count = this.peopleCursor.getCount();
    this.position = -1;
  }
 public void close() throws IOException {
   // TODO check if SmsManager needs to be released
   synchronized (this.receiveLock) {
     this.receiveLock.notify();
   }
   if (this.isListeningForMessages) {
     AndroidMeApp.getIntance().unregisterReceiver(this);
     this.isListeningForMessages = false;
   }
 }
Beispiel #5
0
  public void setCurrent(final Displayable newCurrent) {

    final Activity activity = AndroidMeActivity.DEFAULT_ACTIVITY;
    if (newCurrent == null) {
      // Set Application to background
      if (activity != null) {
        activity.moveTaskToBack(true);
      }
      return;
    }

    // Hide Keyboard, any time a new Displayable is set
    if (!(newCurrent instanceof TextBox) && current instanceof Canvas) {
      ((Canvas) current).hideSoftKeyboard();
    }

    if (activity == null) {
      hiddenDisplay = newCurrent;
      return;
    }
    hiddenDisplay = null;

    if (newCurrent != current) {
      AndroidMeApp.getIntance()
          .invokeAndWait(
              new Runnable() {
                public void run() {

                  // TextBox is special... we don't really have any UI
                  if (newCurrent instanceof TextBox) {
                    newCurrent.initDisplayable(null);
                    return;
                  }

                  Displayable old = current;
                  current = newCurrent;

                  if (old != null) {
                    old.setCurrentDisplay(null);
                  }

                  newCurrent.setCurrentDisplay(Display.this);
                  newCurrent.initDisplayable(Display.this.midlet);

                  View view = newCurrent.getView();
                  if (view != null) {
                    activity.setContentView(view);
                    view.requestFocus();

                    // YURA tiny optimization, so we do not need to draw any background bitmaps!
                    view.getRootView().setBackgroundDrawable(null);
                  } else {
                    throw new RuntimeException("view is null");
                  }
                }
              });

      // Wait for the view to be set...
      // YURA: remove this AndroidMeApp.getIntance().invokeAndWait(new Thread());
    }
  }
 private void setupMessageReceiver() {
   this.isListeningForMessages = true;
   IntentFilter filter = new IntentFilter(ACTION);
   AndroidMeApp.getIntance().registerReceiver(this, filter);
 }