Java Code Examples for android.content.Intent.removeExtra()

The following are Jave code examples for showing how to use removeExtra() of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: iosched-reader   File: BaseActivity.java   View Source Code Vote up 7 votes
/**
 * Converts a fragment arguments bundle into an intent.
 */
public static Intent fragmentArgumentsToIntent(Bundle arguments) {
    Intent intent = new Intent();
    if (arguments == null) {
        return intent;
    }

    final Uri data = arguments.getParcelable("_uri");
    if (data != null) {
        intent.setData(data);
    }

    intent.putExtras(arguments);
    intent.removeExtra("_uri");
    return intent;
}
 
Example 2
Project: container   File: BroadcastIntent.java   View Source Code Vote up 7 votes
private Intent handleInstallShortcutIntent(Intent intent) {
    Intent shortcut = intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
    if (shortcut != null) {
        ComponentName component = shortcut.resolveActivity(VirtualCore.getPM());
        if (component != null) {
            String pkg = component.getPackageName();
            Intent newShortcutIntent = new Intent();
            newShortcutIntent.setClassName(getHostPkg(), Constants.SHORTCUT_PROXY_ACTIVITY_NAME);
            newShortcutIntent.addCategory(Intent.CATEGORY_DEFAULT);
            newShortcutIntent.putExtra("_VA_|_intent_", shortcut);
            newShortcutIntent.putExtra("_VA_|_uri_", shortcut.toUri(0));
            newShortcutIntent.putExtra("_VA_|_user_id_", VUserHandle.myUserId());
            intent.removeExtra(Intent.EXTRA_SHORTCUT_INTENT);
            intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, newShortcutIntent);

            Intent.ShortcutIconResource icon = intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
            if (icon != null && !TextUtils.equals(icon.packageName, getHostPkg())) {
                try {
                    Resources resources = VirtualCore.get().getResources(pkg);
                    if (resources != null) {
                        int resId = resources.getIdentifier(icon.resourceName, "drawable", pkg);
                        if (resId > 0) {
                            Drawable iconDrawable = resources.getDrawable(resId);
                            Bitmap newIcon = BitmapUtils.drawableToBitmap(iconDrawable);
                            if (newIcon != null) {
                                intent.removeExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
                                intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, newIcon);
                            }
                        }
                    }
                } catch (Throwable e) {
                    e.printStackTrace();
                }
            }
        }
    }
    return intent;
}
 
Example 3
Project: LaunchEnr   File: PinItemDragListener.java   View Source Code Vote up 6 votes
private void postCleanup() {
    if (mLauncher != null) {
        // Remove any drag params from the launcher intent since the drag operation is complete.
        Intent newIntent = new Intent(mLauncher.getIntent());
        newIntent.removeExtra(EXTRA_PIN_ITEM_DRAG_LISTENER);
        mLauncher.setIntent(newIntent);
    }

    new Handler(Looper.getMainLooper()).post(new Runnable() {
        @Override
        public void run() {
            removeListener();
        }
    });
}
 
Example 4
Project: PeSanKita-android   File: ConversationActivity.java   View Source Code Vote up 6 votes
@Override
public void startActivity(Intent intent) {
  if (intent.getStringExtra(Browser.EXTRA_APPLICATION_ID) != null) {
    intent.removeExtra(Browser.EXTRA_APPLICATION_ID);
  }

  try {
    super.startActivity(intent);
  } catch (ActivityNotFoundException e) {
    Log.w(TAG, e);
    Toast.makeText(this, R.string.ConversationActivity_there_is_no_app_available_to_handle_this_link_on_your_device, Toast.LENGTH_LONG).show();
  }
}
 
Example 5
Project: AndroidBackendlessChat   File: ChatSDKBaseActivity.java   View Source Code Vote up 6 votes
@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    if (intent != null && intent.getExtras() != null)
    {
        if (DEBUG) Timber.d("From login");
        fromLoginActivity = intent.getExtras().getBoolean(FROM_LOGIN, false);
        // So we wont encounter this flag again.
        intent.removeExtra(FROM_LOGIN);
    }
}
 
Example 6
Project: ActivityBuilder   File: RefManager.java   View Source Code Vote up 6 votes
/**
 * 如果 oldIntent 绑定了 RefMap,那么将其解绑并重新绑定到 newIntent
 */
public void rebindRefMap(Intent oldIntent, Intent newIntent) {
  if (hasRefMap(oldIntent)) {
    Map<String, Object> refMap = getRefMap(oldIntent);

    sGlobalRefMap.remove(getKeyOfMap(oldIntent));
    oldIntent.removeExtra(KEY_OF_MAP);

    int keyOfMap = newIntent.hashCode();
    newIntent.putExtra(KEY_OF_MAP, keyOfMap);
    sGlobalRefMap.put(keyOfMap, refMap);
  }
}
 
Example 7
Project: BlackList   File: MainActivity.java   View Source Code Vote up 6 votes
void switchFragment(@IdRes int itemId) {
    Intent intent = getIntent();
    // passing intent's extra to the fragment
    Bundle extras = intent.getExtras();
    Bundle arguments = (extras != null ? new Bundle(extras) : new Bundle());
    switch (itemId) {
        case R.id.nav_journal:
            arguments.putString(TITLE, getString(R.string.Journal));
            switchFragment(journalFragment, arguments);
            break;
        case R.id.nav_black_list:
            arguments.putString(TITLE, getString(R.string.Black_list));
            arguments.putInt(CONTACT_TYPE, Contact.TYPE_BLACK_LIST);
            switchFragment(blackListFragment, arguments);
            break;
        case R.id.nav_white_list:
            arguments.putString(TITLE, getString(R.string.White_list));
            arguments.putInt(CONTACT_TYPE, Contact.TYPE_WHITE_LIST);
            switchFragment(whiteListFragment, arguments);
            break;
        case R.id.nav_sms:
            arguments.putString(TITLE, getString(R.string.Messaging));
            switchFragment(smsFragment, arguments);
            break;
        case R.id.nav_settings:
            arguments.putString(TITLE, getString(R.string.Settings));
            switchFragment(settingsFragment, arguments);
            break;
        default:
            arguments.putString(TITLE, getString(R.string.Information));
            switchFragment(informationFragment, arguments);
            break;
    }

    // remove used extras
    intent.removeExtra(LIST_POSITION);
}
 
Example 8
Project: container   File: BroadcastIntent.java   View Source Code Vote up 6 votes
private void handleUninstallShortcutIntent(Intent intent) {
    Intent shortcut = intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
    if (shortcut != null) {
        ComponentName componentName = shortcut.resolveActivity(getPM());
        if (componentName != null) {
            Intent newShortcutIntent = new Intent();
            newShortcutIntent.putExtra("_VA_|_uri_", shortcut);
            newShortcutIntent.setClassName(getHostPkg(), Constants.SHORTCUT_PROXY_ACTIVITY_NAME);
            newShortcutIntent.removeExtra(Intent.EXTRA_SHORTCUT_INTENT);
            intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, newShortcutIntent);
        }
    }
}
 
Example 9
Project: chromium-for-android-56-debug-video   File: InstantAppsHandler.java   View Source Code Vote up 6 votes
/**
 * In the case where Chrome is called through the fallback mechanism from Instant Apps,
 * record the amount of time the whole trip took and which UI took the user back to Chrome,
 * if any.
 * @param intent The current intent.
 */
private void maybeRecordFallbackStats(Intent intent) {
    Long startTime = IntentUtils.safeGetLongExtra(intent, INSTANT_APP_START_TIME_EXTRA, 0);
    if (startTime > 0) {
        sFallbackIntentTimes.record(SystemClock.elapsedRealtime() - startTime);
        intent.removeExtra(INSTANT_APP_START_TIME_EXTRA);
    }
    int callSource = IntentUtils.safeGetIntExtra(intent, BROWSER_LAUNCH_REASON, 0);
    if (callSource > 0 && callSource < SOURCE_BOUNDARY) {
        sFallbackCallSource.record(callSource);
        intent.removeExtra(BROWSER_LAUNCH_REASON);
    } else if (callSource >= SOURCE_BOUNDARY) {
        Log.e(TAG, "Unexpected call source constant for Instant Apps: " + callSource);
    }
}
 
Example 10
Project: chromium-for-android-56-debug-video   File: IntentUtils.java   View Source Code Vote up 6 votes
/**
 * Just like {@link Intent#removeExtra(String)} but doesn't throw exceptions.
 */
public static void safeRemoveExtra(Intent intent, String name) {
    try {
        intent.removeExtra(name);
    } catch (Throwable t) {
        // Catches un-parceling exceptions.
        Log.e(TAG, "removeExtra failed on intent " + intent);
    }
}
 
Example 11
Project: Android-Scrapper   File: MainPresenterImpl.java   View Source Code Vote up 6 votes
@Override
public void initializeMainLayout(Intent argument) {
    if (argument != null && argument.hasExtra(MainActivity.POSITION_ARGUMENT_KEY)) {
        mInitialPosition = argument.getIntExtra(MainActivity.POSITION_ARGUMENT_KEY, NavigationUtils.POSITION_DASHBOARD);

        if (mInitialPosition == NavigationUtils.POSITION_DASHBOARD) {
            mFragment = new DashFragment();
        } else if (mInitialPosition == NavigationUtils.POSITION_GRID) {
            mFragment = new GridPagerFragment();
        } else if (mInitialPosition == NavigationUtils.POSITION_LEAGUE) {
            mFragment = new LeagueFragment();
        } else if (mInitialPosition == NavigationUtils.POSITION_SETTING) {
            Intent intent = new Intent(mMainView.getActivity(), SettingsActivity.class);
            mMainView.getActivity().startActivity(intent);
        }
        argument.removeExtra(MainActivity.POSITION_ARGUMENT_KEY);
    }

    if (mFragment == null) {
        mInitialPosition = NavigationUtils.POSITION_DASHBOARD;

        mFragment = new DashFragment();
    }

    ((AppCompatActivity) mMainView.getActivity()).getSupportFragmentManager().beginTransaction()
            .add(mMainView.getMainLayoutId(), mFragment)
            .commitAllowingStateLoss();
}
 
Example 12
Project: gamesboard   File: GameListActivity.java   View Source Code Vote up 6 votes
private void showDialogIf(Intent intent) {
	if (intent.hasExtra("id")) {
		id = intent.getExtras().getString("id");
		intent.removeExtra("id");
		Bundle args = new Bundle();
		args.putString("id", id);
		JoinGameDialogFragment fragment = new JoinGameDialogFragment();
		fragment.setArguments(args);
		fragment.show(getSupportFragmentManager(), "dialog");
	}
}
 
Example 13
Project: gamesboard   File: ContactListActivity.java   View Source Code Vote up 6 votes
private void showDialogIf(Intent intent) {
	if (intent.hasExtra("id")) {
		id = intent.getExtras().getString("id");
		intent.removeExtra("id");
           showDialog();
	}
}
 
Example 14
Project: A.scribe   File: MainActivity.java   View Source Code Vote up 6 votes
private void readIntent() {
    Intent intent = getIntent();
    long dateNoteCreated = intent.getLongExtra(INTENT_EXTRA_DATE_NOTE_CREATED, NOTE_INVALID_ID);
    if (dateNoteCreated != NOTE_INVALID_ID) {
        intent.removeExtra(INTENT_EXTRA_DATE_NOTE_CREATED);
        getPresenter().openNote(dateNoteCreated);
    }
}
 
Example 15
Project: VirtualHook   File: MethodProxies.java   View Source Code Vote up 6 votes
private void handleUninstallShortcutIntent(Intent intent) {
    Intent shortcut = intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
    if (shortcut != null) {
        ComponentName componentName = shortcut.resolveActivity(getPM());
        if (componentName != null) {
            Intent newShortcutIntent = new Intent();
            newShortcutIntent.putExtra("_VA_|_uri_", shortcut);
            newShortcutIntent.setClassName(getHostPkg(), Constants.SHORTCUT_PROXY_ACTIVITY_NAME);
            newShortcutIntent.removeExtra(Intent.EXTRA_SHORTCUT_INTENT);
            intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, newShortcutIntent);
        }
    }
}
 
Example 16
Project: springreplugin   File: PluginMgr.java   View Source Code Vote up 6 votes
static final void cleanIntentPluginParams(Intent intent) {
    // 防止 intent 攻击
    try {
        intent.removeExtra(IPluginManager.KEY_COMPATIBLE);
        intent.removeExtra(IPluginManager.KEY_PLUGIN);
        intent.removeExtra(IPluginManager.KEY_ACTIVITY);
    } catch (Exception e) {
        // ignore
    }
}
 
Example 17
Project: TPlayer   File: MethodProxies.java   View Source Code Vote up 6 votes
private Intent handleInstallShortcutIntent(Intent intent) {
    Intent shortcut = intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
    if (shortcut != null) {
        ComponentName component = shortcut.resolveActivity(VirtualCore.getPM());
        if (component != null) {
            String pkg = component.getPackageName();
            Intent newShortcutIntent = new Intent();
            newShortcutIntent.setClassName(getHostPkg(), Constants.SHORTCUT_PROXY_ACTIVITY_NAME);
            newShortcutIntent.addCategory(Intent.CATEGORY_DEFAULT);
            newShortcutIntent.putExtra("_VA_|_intent_", shortcut);
            newShortcutIntent.putExtra("_VA_|_uri_", shortcut.toUri(0));
            newShortcutIntent.putExtra("_VA_|_user_id_", VUserHandle.myUserId());
            intent.removeExtra(Intent.EXTRA_SHORTCUT_INTENT);
            intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, newShortcutIntent);

            Intent.ShortcutIconResource icon = intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
            if (icon != null && !TextUtils.equals(icon.packageName, getHostPkg())) {
                try {
                    Resources resources = VirtualCore.get().getResources(pkg);
                    int resId = resources.getIdentifier(icon.resourceName, "drawable", pkg);
                    if (resId > 0) {
                        //noinspection deprecation
                        Drawable iconDrawable = resources.getDrawable(resId);
                        Bitmap newIcon = BitmapUtils.drawableToBitmap(iconDrawable);
                        if (newIcon != null) {
                            intent.removeExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
                            intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, newIcon);
                        }
                    }
                } catch (Throwable e) {
                    e.printStackTrace();
                }
            }
        }
    }
    return intent;
}
 
Example 18
Project: TPlayer   File: MethodProxies.java   View Source Code Vote up 6 votes
private void handleUninstallShortcutIntent(Intent intent) {
    Intent shortcut = intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
    if (shortcut != null) {
        ComponentName componentName = shortcut.resolveActivity(getPM());
        if (componentName != null) {
            Intent newShortcutIntent = new Intent();
            newShortcutIntent.putExtra("_VA_|_uri_", shortcut.toUri(0));
            newShortcutIntent.setClassName(getHostPkg(), Constants.SHORTCUT_PROXY_ACTIVITY_NAME);
            newShortcutIntent.removeExtra(Intent.EXTRA_SHORTCUT_INTENT);
            intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, newShortcutIntent);
        }
    }
}
 
Example 19
Project: Cable-Android   File: ConversationActivity.java   View Source Code Vote up 6 votes
@Override
public void startActivity(Intent intent) {
  if (intent.getStringExtra(Browser.EXTRA_APPLICATION_ID) != null) {
    intent.removeExtra(Browser.EXTRA_APPLICATION_ID);
  }

  try {
    super.startActivity(intent);
  } catch (ActivityNotFoundException e) {
    Log.w(TAG, e);
    Toast.makeText(this, R.string.ConversationActivity_there_is_no_app_available_to_handle_this_link_on_your_device, Toast.LENGTH_LONG).show();
  }
}
 
Example 20
Project: kolibri-android   File: KolibriNavigationActivity.java   View Source Code Vote up 5 votes
@Override
public void onBackPressed() {

  if (drawer.isDrawerOpen(GravityCompat.START)) {
    drawer.closeDrawer(GravityCompat.START);
    return;
  }

  final MenuItem selectedItem = getSelectedMenuItem();
  final MenuItem defaultItem = getDefaultItem();

  if (webView.canGoBack()) {

    // Go back from deeplink
    final Intent intent = webView.getIntent();

    if (intent.hasExtra(Kolibri.EXTRA_DEEPLINK)) {

      MenuItem category = findMenuItem(intent.getStringExtra(Kolibri.EXTRA_ID));

      if (category != null) {
        navigationView.setCheckedItem(category.getItemId());
      }

      intent.removeExtra(Kolibri.EXTRA_DEEPLINK);
      notifyComponenets(intent);
      return;
    } else {

      final String selectedItemUrl = selectedItem.getIntent()
          .getData().getQueryParameter("url");
      final String currentUrl = webView.getOriginalUrl();

      //If the url we are going back from
      //came from a menu item click, we clear the history
      //and go back home
      if (currentUrl.equals(selectedItemUrl)) {
        final String url = defaultItem.getIntent().getData().getQueryParameter("url");

        //If there is url on default item, then we load this url and clear that history
        //so that the next time the user presses back they are redirected out
        //of the app
        if (url != null) {
          webView.setClearHistory(true);
          webView.loadUrl(url);
          setActionBarTitle(defaultItem.getTitle().toString());
          navigationView.setCheckedItem(defaultItem.getItemId());
          return;
        }
      } else {
        webView.goBack();
        return;
      }
    }
  }

  super.onBackPressed();
}