Tabnine Logo
android.os
Code IndexAdd Tabnine to your IDE (free)

How to use android.os

Best Java code snippets using android.os (Showing top 20 results out of 22,473)

origin: stackoverflow.com

 @Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
 super.onRestoreInstanceState(savedInstanceState);
 // Restore UI state from the savedInstanceState.
 // This bundle has also been passed to onCreate.
 boolean myBoolean = savedInstanceState.getBoolean("MyBoolean");
 double myDouble = savedInstanceState.getDouble("myDouble");
 int myInt = savedInstanceState.getInt("MyInt");
 String myString = savedInstanceState.getString("MyString");
}
origin: stackoverflow.com

 @Override
public void onSaveInstanceState(Bundle savedInstanceState) {
 super.onSaveInstanceState(savedInstanceState);
 // Save UI state changes to the savedInstanceState.
 // This bundle will be passed to onCreate if the process is
 // killed and restarted.
 savedInstanceState.putBoolean("MyBoolean", true);
 savedInstanceState.putDouble("myDouble", 1.9);
 savedInstanceState.putInt("MyInt", 1);
 savedInstanceState.putString("MyString", "Welcome back to Android");
 // etc.
}
origin: stackoverflow.com

 Bundle extras = getIntent().getExtras();
if (extras != null) {
  String value = extras.getString("key");
  //The key argument here must match that used in the other activity
}
origin: bumptech/glide

private Api() {
 HandlerThread bgThread = new HandlerThread("api_thread");
 bgThread.start();
 bgHandler = new Handler(bgThread.getLooper());
 mainHandler = new Handler(Looper.getMainLooper());
 // Do nothing.
}
origin: stackoverflow.com

 public static MyFragment newInstance(int someInt) {
  MyFragment myFragment = new MyFragment();

  Bundle args = new Bundle();
  args.putInt("someInt", someInt);
  myFragment.setArguments(args);

  return myFragment;
}
origin: bumptech/glide

@SuppressWarnings("WeakerAccess")
public BitmapPreFillRunner(
  BitmapPool bitmapPool, MemoryCache memoryCache, PreFillQueue allocationOrder) {
 this(
   bitmapPool,
   memoryCache,
   allocationOrder,
   DEFAULT_CLOCK,
   new Handler(Looper.getMainLooper()));
}
origin: stackoverflow.com

 // initialize the progress dialog like in the first example

// this is how you fire the downloader
mProgressDialog.show();
Intent intent = new Intent(this, DownloadService.class);
intent.putExtra("url", "url of the file to download");
intent.putExtra("receiver", new DownloadReceiver(new Handler()));
startService(intent);
origin: square/retrofit

 @Override public void execute(Runnable r) {
  handler.post(r);
 }
}
origin: stackoverflow.com

 private class DownloadReceiver extends ResultReceiver{
  public DownloadReceiver(Handler handler) {
    super(handler);
  }

  @Override
  protected void onReceiveResult(int resultCode, Bundle resultData) {
    super.onReceiveResult(resultCode, resultData);
    if (resultCode == DownloadService.UPDATE_PROGRESS) {
      int progress = resultData.getInt("progress");
      mProgressDialog.setProgress(progress);
      if (progress == 100) {
        mProgressDialog.dismiss();
      }
    }
  }
}
origin: stackoverflow.com

 @Override
protected void onSaveInstanceState(Bundle outState) {
  outState.putString("WORKAROUND_FOR_BUG_19917_KEY", "WORKAROUND_FOR_BUG_19917_VALUE");
  super.onSaveInstanceState(outState);
}
origin: greenrobot/EventBus

Object getAndroidMainLooperOrNull() {
  try {
    return Looper.getMainLooper();
  } catch (RuntimeException e) {
    // Not really a functional Android (e.g. "Stub!" maven dependencies)
    return null;
  }
}
origin: greenrobot/EventBus

@Override
public boolean isMainThread() {
  return looper == Looper.myLooper();
}
origin: stackoverflow.com

 // Get instance of Vibrator from current Context
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

// Start without a delay
// Vibrate for 100 milliseconds
// Sleep for 1000 milliseconds
long[] pattern = {0, 100, 1000};

// The '0' here means to repeat indefinitely
// '0' is actually the index at which the pattern keeps repeating from (the start)
// To repeat the pattern from any other point, you could increase the index, e.g. '1'
v.vibrate(pattern, 0);
origin: square/leakcanary

private void waitForIdle(final Retryable retryable, final int failedAttempts) {
 // This needs to be called from the main thread.
 Looper.myQueue().addIdleHandler(new MessageQueue.IdleHandler() {
  @Override public boolean queueIdle() {
   postToBackgroundWithDelay(retryable, failedAttempts);
   return false;
  }
 });
}
origin: stackoverflow.com

 // Get instance of Vibrator from current Context
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

// Output yes if can vibrate, no otherwise
if (v.hasVibrator()) {
  Log.v("Can Vibrate", "YES");
} else {
  Log.v("Can Vibrate", "NO");
}
origin: square/leakcanary

public AndroidWatchExecutor(long initialDelayMillis) {
 mainHandler = new Handler(Looper.getMainLooper());
 HandlerThread handlerThread = new HandlerThread(LEAK_CANARY_THREAD_NAME);
 handlerThread.start();
 backgroundHandler = new Handler(handlerThread.getLooper());
 this.initialDelayMillis = initialDelayMillis;
 maxBackoffFactor = Long.MAX_VALUE / initialDelayMillis;
}
origin: square/leakcanary

LoadLeaks(DisplayLeakActivity activity, LeakDirectoryProvider leakDirectoryProvider) {
 this.activityOrNull = activity;
 this.leakDirectoryProvider = leakDirectoryProvider;
 mainHandler = new Handler(Looper.getMainLooper());
}
origin: stackoverflow.com

 handler = new Handler();

final Runnable r = new Runnable() {
  public void run() {
    tv.append("Hello World");
    handler.postDelayed(this, 1000);
  }
};

handler.postDelayed(r, 1000);
origin: stackoverflow.com

 // Get instance of Vibrator from current Context
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

// Start without a delay
// Each element then alternates between vibrate, sleep, vibrate, sleep...
long[] pattern = {0, 100, 1000, 300, 200, 100, 500, 200, 100};

// The '-1' here means to vibrate once, as '-1' is out of bounds in the pattern array
v.vibrate(pattern, -1);
origin: stackoverflow.com

 // Get instance of Vibrator from current Context
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

// Vibrate for 400 milliseconds
v.vibrate(400);
android.os

Most used classes

  • Handler
  • Bundle
  • Environment
  • Parcel
  • Looper
  • Message,
  • AsyncTask,
  • Process,
  • HandlerThread,
  • PowerManager,
  • Vibrator,
  • PowerManager$WakeLock,
  • ParcelFileDescriptor,
  • StrictMode,
  • StatFs,
  • RemoteException,
  • Parcelable$Creator,
  • StrictMode$ThreadPolicy$Builder,
  • StrictMode$VmPolicy$Builder
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now