Intent hasExtra - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Intent hasExtra method.

This code example shows how to use the following methods:hasExtra
  } 
 
  // Handles send intents from multitude of Android applications 
  private boolean encodeContentsFromShareIntent(Intent intent) {
    // Check if this is a plain text encoding, or contact 
    if (intent.hasExtra(Intent.EXTRA_TEXT)) {
      return encodeContentsFromShareIntentPlainText(intent);
    } 
    // Attempt default sharing. 
    return encodeContentsFromShareIntentDefault(intent);
  } 
 
  private boolean encodeContentsFromShareIntentPlainText(Intent intent) {
    // Notice: Google Maps shares both URL and details in one text, bummer! 
    contents = intent.getStringExtra(Intent.EXTRA_TEXT);
    // We only support non-empty and non-blank texts. 
    // Trim text to avoid URL breaking. 
    if (contents == null) {
      return false; 
    } 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getIntExtra, hasExtra
  static private final String GEO_NAME = "place-name";
  static private final String GEO_NEAR = "place-near";
	 
	static public BoundingBoxE6 getBoundingBox(final Intent intent)
  { 
	  if(intent.hasExtra(EXTRA_NORTH)	&&
	     intent.hasExtra(EXTRA_EAST) &&
	     intent.hasExtra(EXTRA_SOUTH) &&
	     intent.hasExtra(EXTRA_WEST))
	  { 
	    return new BoundingBoxE6( 
	          intent.getIntExtra(EXTRA_NORTH, 0),
    			  intent.getIntExtra(EXTRA_EAST, 0),
    			  intent.getIntExtra(EXTRA_SOUTH, 0),
    			  intent.getIntExtra(EXTRA_WEST, 0));
    } // if ... 
 
	  return null; 
  } // getBoundingBox 
 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getStringExtra, hasExtra
                    .putExtra(EXTRA_WRITE_PRIVACY, ensureDefaultAudience(audience));
        return validateKatanaActivityIntent(context, intent);
    } 
 
    public static boolean isErrorResult(Intent resultIntent) {
        return resultIntent.hasExtra(STATUS_ERROR_TYPE);
    } 
 
    public static Exception getErrorFromResult(Intent resultIntent) {
        if (!isErrorResult(resultIntent)) {
            return null; 
        } 
 
        String type = resultIntent.getStringExtra(STATUS_ERROR_TYPE);
        String description = resultIntent.getStringExtra(STATUS_ERROR_DESCRIPTION);
 
        if (type.equalsIgnoreCase(ERROR_USER_CANCELED)) {
            return new FacebookOperationCanceledException(description);
        } 
        /* TODO parse error values and create appropriate exception class */ 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getStringExtra, hasExtra
	} 
 
	@Kroll.method 
	public String getStringExtra(String name)
	{ 
		if (!intent.hasExtra(name)) {
			return null; 
		} 
 
		String result = intent.getStringExtra(name);
		if (result == null) {
			// One more try as parcelable extra, such as when it's a Uri. 
			// We can't really support getParcelableExtra(name) by itself, 
			// since the type of object coming out of it is unknown and 
			// might not make its way successfully over to Javascript. 
			// By getting it as a string, we at least allow people to grab 
			// Uris (Intent.STREAM) stored as parcelable extras, which is a 
			// very common use case. 
			Object parcelable = intent.getParcelableExtra(name);
			if (parcelable != null) {
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:hasExtra, putExtra
import android.preference.PreferenceActivity; 
 
public class InputMethodAndSubtypeEnablerActivity extends PreferenceActivity {
    @Override 
    public Intent getIntent() {
        final Intent modIntent = new Intent(super.getIntent());
        if (!modIntent.hasExtra(EXTRA_SHOW_FRAGMENT)) {
            modIntent.putExtra(EXTRA_SHOW_FRAGMENT, InputMethodAndSubtypeEnabler.class.getName());
            modIntent.putExtra(EXTRA_NO_HEADERS, true);
        } 
        return modIntent;
    } 
} 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:hasExtra, putExtra
    private static final String EXTRA_WIFI_SHOW_ACTION_BAR = "wifi_show_action_bar";
    private static final String EXTRA_WIFI_SHOW_MENUS = "wifi_show_menus";
 
    @Override 
    public Intent getIntent() {
        Intent modIntent = new Intent(super.getIntent());
        if (!modIntent.hasExtra(EXTRA_SHOW_FRAGMENT)) {
            modIntent.putExtra(EXTRA_SHOW_FRAGMENT, WifiSettings.class.getName());
        } 
        modIntent.putExtra(EXTRA_NO_HEADERS, true);
        return modIntent;
    } 
 
    /** 
     * Almost dead copy of 
     * {@link PreferenceActivity#startWithFragment(String, Bundle, Fragment, int)}, except 
     * this has additional codes for button bar handling. 
     */ 
    @Override 
    public void startWithFragment(String fragmentName, Bundle args,
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getComponent, hasExtra
            return mContext.getPackageName();
        } 
 
        @Override 
        public void startActivity(Intent intent) {
            ComponentName component = intent.getComponent();
            assertEquals(SubActivity.class.getCanonicalName(), component.getClassName());
            assertTrue(intent.hasExtra("hoge"));
            assertEquals("hogehoge", intent.getStringExtra("hoge"));
        } 
    } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getAction, hasExtra
        intentTakePhoto.putExtras(intent.getExtras());
        return intentTakePhoto;
    } 
     
    public static boolean isTakePhotoIntent(Intent intent) {
    	String action = intent.getAction();
		return (action != null
					&& (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
						|| MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA.equals(action))
					&& intent.hasExtra(MediaStore.EXTRA_OUTPUT));
		 
    } 
     
    public static Intent buildPickPhotoIntent() {
		Intent pickPhotoIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
		return pickPhotoIntent;
    } 
     
    public static Intent buildMotdIntent(Context context, String href) {
    	// Determine if it's a market intent, or just a regular URL 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getData, hasExtra
        intent.putExtra(Intent.EXTRA_SUBJECT, title);
        context.startActivity(intent);
    } 
 
    public boolean isValidIntent(Intent intent) {
        if (!intent.hasExtra(Intent.EXTRA_TEXT)) {
            return false; 
        } 
        if (intent.getData() == null) {
            return false; 
        } 
        return true; 
    } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getExtras, hasExtra
    @Override 
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == REQUEST_WIDGET) {
            if (data != null) {
                int appWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
                if (data.hasExtra(AppWidgetManager.EXTRA_APPWIDGET_ID)) {
                    appWidgetId = data.getExtras().getInt(AppWidgetManager.EXTRA_APPWIDGET_ID);
                } 
 
                if (resultCode == RESULT_OK) {
                    setAppWidget(appWidgetId);
                } else { 
                    mAppWidgetHost.deleteAppWidgetId(appWidgetId);
                    finish();
                } 
            } else { 
                finish();
            } 
        } else if (requestCode == REQUEST_CONFIGURE) {
            if (data != null) {

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Intent hasExtra Questions & Answers:

hasExtra Method Overview
Returns true if an extra value is associated with the given name.
See Code Examples for other Android Intent Methods: