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

How to use android.content

Best Java code snippets using android.content (Showing top 20 results out of 74,655)

origin: stackoverflow.com

 @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

  if (requestCode == 1) {
    if(resultCode == Activity.RESULT_OK){
      String result=data.getStringExtra("result");
    }
    if (resultCode == Activity.RESULT_CANCELED) {
      //Write your code if there's no result
    }
  }
}//onActivityResult
origin: stackoverflow.com

 Intent returnIntent = new Intent();
returnIntent.putExtra("result",result);
setResult(Activity.RESULT_OK,returnIntent);
finish();
origin: stackoverflow.com

 SharedPreferences preferences = getPreference(MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putInt("storedInt", storedPreference); // value to store
editor.commit();
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: stackoverflow.com

 Intent i = new Intent(getApplicationContext(), NewActivity.class);

i.putExtra("key","value");
startActivity(i);
origin: libgdx/libgdx

@Override
public void flush () {
  if (editor != null) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
        editor.apply();
    } else {
      editor.commit();
    }
    editor = null;
  }
}
origin: libgdx/libgdx

  private void edit () {
    if (editor == null) {
      editor = sharedPrefs.edit();
    }
  }
}
origin: stackoverflow.com

 SharedPreferences.Editor editor = preferences.edit();
editor.putInt("storedInt", storedPreference); // value to store
editor.commit();
origin: stackoverflow.com

 SharedPreferences preferences = getPreferences(MODE_PRIVATE);
int storedPreference = preferences.getInt("storedInt", 0);
origin: stackoverflow.com

 String url = "http://www.example.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
origin: stackoverflow.com

 @Override
protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) { 
  super.onActivityResult(requestCode, resultCode, imageReturnedIntent); 

  switch(requestCode) { 
  case SELECT_PHOTO:
    if(resultCode == RESULT_OK){  
      Uri selectedImage = imageReturnedIntent.getData();
      InputStream imageStream = getContentResolver().openInputStream(selectedImage);
      Bitmap yourSelectedImage = BitmapFactory.decodeStream(imageStream);
    }
  }
}
origin: stackoverflow.com

 prefs.registerOnSharedPreferenceChangeListener(
 new SharedPreferences.OnSharedPreferenceChangeListener() {
 public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
  // Implementation
 }
});
origin: stackoverflow.com

 Intent i = new Intent();
i.putExtra("name_of_extra", myParcelableObject);
origin: stackoverflow.com

 Intent returnIntent = new Intent();
setResult(Activity.RESULT_CANCELED, returnIntent);
finish();
origin: libgdx/libgdx

  private void edit () {
    if (editor == null) {
      editor = sharedPrefs.edit();
    }
  }
}
origin: stackoverflow.com

 @Override
protected void onCreate(Bundle savedInstanceState) {
  Intent intent = getIntent();
  String value = intent.getStringExtra("key"); //if it's a string you stored.
}
origin: stackoverflow.com

 protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
  super.onActivityResult(requestCode, resultCode, data);
  if (resultCode == RESULT_OK)
  {
    Uri imageUri = data.getData();
    Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), imageUri);
  }
}
origin: stackoverflow.com

 // Use instance field for listener
// It will not be gc'd as long as this instance is kept referenced
listener = new SharedPreferences.OnSharedPreferenceChangeListener() {
 public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
  // Implementation
 }
};

prefs.registerOnSharedPreferenceChangeListener(listener);
origin: stackoverflow.com

 Intent i = new Intent(this, SecondActivity.class);
startActivityForResult(i, 1);
origin: stackoverflow.com

 Intent data = new Intent();
 [...]
if (getParent() == null) {
  setResult(Activity.RESULT_OK, data);
} else {
  getParent().setResult(Activity.RESULT_OK, data);
}
finish();
android.content

Most used classes

  • Context
    http://developer.android.com/reference/android/content/Context.html
  • Intent
  • Resources
  • TypedArray
  • SharedPreferences
  • PackageManager,
  • ContentResolver,
  • IntentFilter,
  • AssetManager,
  • ContentValues,
  • ComponentName,
  • Resources$Theme,
  • DialogInterface,
  • PackageManager$NameNotFoundException,
  • ClipData,
  • ColorStateList,
  • ClipboardManager,
  • ContentUris,
  • UriMatcher
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