Example usage for android.content Intent removeExtra

List of usage examples for android.content Intent removeExtra

Introduction

In this page you can find the example usage for android.content Intent removeExtra.

Prototype

public void removeExtra(String name) 

Source Link

Document

Remove extended data from the intent.

Usage

From source file:fr.tvbarthel.apps.simpleweatherforcast.MainActivity.java

private void loadDailyForecast(final String jsonDailyForecast) {
    mProgressBar.setVisibility(View.VISIBLE);
    if (jsonDailyForecast != null) {
        new DailyForecastJsonParser() {
            @Override/*from www.j  a v  a 2 s. c o m*/
            protected void onPostExecute(ArrayList<DailyForecastModel> dailyForecastModels) {
                super.onPostExecute(dailyForecastModels);
                mLoadedWeather = jsonDailyForecast;
                mProgressBar.setVisibility(View.INVISIBLE);
                mSectionsPagerAdapter.updateModels(dailyForecastModels);

                final Intent intent = getIntent();
                if (intent != null && intent.hasExtra(EXTRA_PAGE_POSITION)) {
                    final int position = intent.getIntExtra(EXTRA_PAGE_POSITION, 0);
                    mViewPager.setCurrentItem(position);
                    intent.removeExtra(EXTRA_PAGE_POSITION);
                } else {
                    invalidatePageTransformer();
                }
            }
        }.execute(jsonDailyForecast);
    }
}

From source file:com.xabber.android.ui.activity.ChatActivity.java

@Override
protected void onResume() {
    super.onResume();
    LogManager.i(LOG_TAG, "onResume");

    isVisible = true;//from   w  w  w. ja va 2  s.c o  m

    Application.getInstance().addUIListener(OnContactChangedListener.class, this);
    Application.getInstance().addUIListener(OnAccountChangedListener.class, this);
    Application.getInstance().addUIListener(OnBlockedListChangedListener.class, this);

    selectPage();

    Intent intent = getIntent();

    if (hasAttention(intent)) {
        AttentionManager.getInstance().removeAccountNotifications(account, user);
    }

    if (Intent.ACTION_SEND.equals(intent.getAction())) {
        extraText = intent.getStringExtra(Intent.EXTRA_TEXT);

        if (extraText != null) {
            intent.removeExtra(Intent.EXTRA_TEXT);
            exitOnSend = true;
        }
    }
}

From source file:com.xabber.android.ui.ChatViewer.java

@Override
protected void onResume() {
    super.onResume();
    isVisible = true;/*from  w  w  w.  j  av  a  2 s.c  o  m*/

    Application.getInstance().addUIListener(OnChatChangedListener.class, this);
    Application.getInstance().addUIListener(OnContactChangedListener.class, this);
    Application.getInstance().addUIListener(OnAccountChangedListener.class, this);

    chatViewerAdapter.updateChats();
    chatScrollIndicatorAdapter.update(chatViewerAdapter.getActiveChats());
    selectPage();

    Intent intent = getIntent();

    if (hasAttention(intent)) {
        AttentionManager.getInstance().removeAccountNotifications(selectedChat);
    }

    if (Intent.ACTION_SEND.equals(intent.getAction())) {
        extraText = intent.getStringExtra(Intent.EXTRA_TEXT);

        if (extraText != null) {
            intent.removeExtra(Intent.EXTRA_TEXT);
            exitOnSend = true;
        }
    }
}

From source file:com.xabber.android.ui.activity.ChatViewer.java

@Override
protected void onResume() {
    super.onResume();
    isVisible = true;/*from  w w  w  .  j a va  2s.c  om*/

    Application.getInstance().addUIListener(OnChatChangedListener.class, this);
    Application.getInstance().addUIListener(OnContactChangedListener.class, this);
    Application.getInstance().addUIListener(OnAccountChangedListener.class, this);
    Application.getInstance().addUIListener(OnBlockedListChangedListener.class, this);

    chatViewerAdapter.updateChats();
    chatScrollIndicatorAdapter.update(chatViewerAdapter.getActiveChats());
    selectPage();

    Intent intent = getIntent();

    if (hasAttention(intent)) {
        AttentionManager.getInstance().removeAccountNotifications(selectedChat);
    }

    if (Intent.ACTION_SEND.equals(intent.getAction())) {
        extraText = intent.getStringExtra(Intent.EXTRA_TEXT);

        if (extraText != null) {
            intent.removeExtra(Intent.EXTRA_TEXT);
            exitOnSend = true;
        }
    }
}

From source file:org.microg.gms.gcm.McsService.java

private void handleSendMessage(Intent intent) {
    String messageId = intent.getStringExtra(EXTRA_MESSAGE_ID);
    String collapseKey = intent.getStringExtra(EXTRA_COLLAPSE_KEY);

    Messenger messenger = intent.getParcelableExtra(EXTRA_MESSENGER);
    intent.removeExtra(EXTRA_MESSENGER);

    Parcelable app = intent.getParcelableExtra(EXTRA_APP);
    String packageName = null;// www .j a  va  2 s  .c  om
    if (app instanceof PendingIntent) {
        packageName = PackageUtils.packageFromPendingIntent((PendingIntent) app);
    }
    if (packageName == null) {
        Log.w(TAG, "Failed to send message, missing package name");
        return;
    }
    intent.removeExtra(EXTRA_APP);

    int ttl;
    try {
        ttl = Integer.parseInt(intent.getStringExtra(EXTRA_TTL));
        if (ttl < 0 || ttl > maxTtl) {
            ttl = maxTtl;
        }
    } catch (NumberFormatException e) {
        // TODO: error TtlUnsupported
        Log.w(TAG, e);
        return;
    }

    String to = intent.getStringExtra(EXTRA_SEND_TO);
    if (to == null) {
        // TODO: error missing_to
        Log.w(TAG, "missing to");
        return;
    }

    String from = intent.getStringExtra(EXTRA_SEND_FROM);
    if (from != null) {
        intent.removeExtra(EXTRA_SEND_FROM);
    } else {
        from = intent.getStringExtra(EXTRA_FROM);
    }
    if (from == null) {
        GcmDatabase.Registration reg = database.getRegistration(packageName,
                PackageUtils.firstSignatureDigest(this, packageName));
        if (reg != null)
            from = reg.registerId;
    }
    if (from == null) {
        Log.e(TAG, "Can't send message, missing from!");
        return;
    }

    String registrationId = intent.getStringExtra(EXTRA_REGISTRATION_ID);
    intent.removeExtra(EXTRA_REGISTRATION_ID);

    List<AppData> appData = new ArrayList<>();
    Bundle extras = intent.getExtras();
    for (String key : extras.keySet()) {
        if (!key.startsWith("google.")) {
            Object val = extras.get(key);
            if (val instanceof String) {
                appData.add(new AppData(key, (String) val));
            }
        }
    }

    byte[] rawDataArray = intent.getByteArrayExtra("rawData");
    ByteString rawData = rawDataArray != null ? ByteString.of(rawDataArray) : null;

    try {
        DataMessageStanza msg = new DataMessageStanza.Builder().sent(System.currentTimeMillis() / 1000L)
                .id(messageId).token(collapseKey).from(from).reg_id(registrationId).to(to).category(packageName)
                .raw_data(rawData).app_data(appData).build();

        send(MCS_DATA_MESSAGE_STANZA_TAG, msg);
        database.noteAppMessage(packageName, msg.getSerializedSize());
    } catch (Exception e) {
        Log.w(TAG, e);
    }
}

From source file:com.androzic.MainActivity.java

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    Log.e(TAG, "onNewIntent()");
    if (intent.hasExtra(LAUNCH_ACTIVITY)) {
        Serializable object = intent.getExtras().getSerializable(LAUNCH_ACTIVITY);
        if (Class.class.isInstance(object)) {
            Intent launch = new Intent(this, (Class<?>) object);
            launch.putExtras(intent);//from   www.  j a v  a  2 s  .  c  o  m
            launch.removeExtra(LAUNCH_ACTIVITY);
            startActivity(launch);
        }
    } else if (intent.hasExtra(SHOW_FRAGMENT)) {
        Serializable object = intent.getExtras().getSerializable(SHOW_FRAGMENT);
        if (Class.class.isInstance(object)) {
            @SuppressWarnings("rawtypes")
            String name = ((Class) object).getName();
            Fragment f = Fragment.instantiate(this, name);
            intent.removeExtra(SHOW_FRAGMENT);
            f.setArguments(intent.getExtras());
            if (DialogFragment.class.isInstance(f))
                ((DialogFragment) f).show(getSupportFragmentManager(), "show");
            else
                addFragment(f, name);
        }
    } else if (intent.hasExtra("lat") && intent.hasExtra("lon")) {
        application.ensureVisible(intent.getExtras().getDouble("lat"), intent.getExtras().getDouble("lon"));
        selectItem(0);
    }
}

From source file:orbin.deskclock.timer.TimerFragment.java

@Override
public void onStart() {
    super.onStart();

    // Initialize the page indicators.
    updatePageIndicators();//from   ww  w  . j a  v  a  2  s .co  m

    boolean createTimer = false;
    int showTimerId = -1;

    // Examine the intent of the parent activity to determine which view to display.
    final Intent intent = getActivity().getIntent();
    if (intent != null) {
        // These extras are single-use; remove them after honoring them.
        createTimer = intent.getBooleanExtra(EXTRA_TIMER_SETUP, false);
        intent.removeExtra(EXTRA_TIMER_SETUP);

        showTimerId = intent.getIntExtra(HandleDeskClockApiCalls.EXTRA_TIMER_ID, -1);
        intent.removeExtra(HandleDeskClockApiCalls.EXTRA_TIMER_ID);
    }

    // Choose the view to display in this fragment.
    if (showTimerId != -1) {
        // A specific timer must be shown; show the list of timers.
        showTimersView(FAB_AND_BUTTONS_IMMEDIATE);
    } else if (!hasTimers() || createTimer || mTimerSetupState != null) {
        // No timers exist, a timer is being created, or the last view was timer setup;
        // show the timer setup view.
        showCreateTimerView(FAB_AND_BUTTONS_IMMEDIATE);

        if (mTimerSetupState != null) {
            mCreateTimerView.setState(mTimerSetupState);
            mTimerSetupState = null;
        }
    } else {
        // Otherwise, default to showing the list of timers.
        showTimersView(FAB_AND_BUTTONS_IMMEDIATE);
    }

    // If the intent did not specify a timer to show, show the last timer that expired.
    if (showTimerId == -1) {
        final Timer timer = DataModel.getDataModel().getMostRecentExpiredTimer();
        showTimerId = timer == null ? -1 : timer.getId();
    }

    // If a specific timer should be displayed, display the corresponding timer tab.
    if (showTimerId != -1) {
        final Timer timer = DataModel.getDataModel().getTimer(showTimerId);
        if (timer != null) {
            final int index = DataModel.getDataModel().getTimers().indexOf(timer);
            mViewPager.setCurrentItem(index);
        }
    }
}

From source file:hobby.wei.c.framework.AbsActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    //??????//from   w w w . j  av a 2  s . c  o m
    if (data != null) {
        if (data.getBooleanExtra(Const.EXTRA_BACK_CONTINUOUS, false)) {
            backContinuous(resultCode,
                    data == null ? null : new Intent().putExtras(data).setData(data.getData()));
        } else {
            String name = data.getStringExtra(Const.EXTRA_BACK_TO_NAME);
            if (name != null) {
                if (name.equals(getClass().getName())) {
                    data.removeExtra(Const.EXTRA_BACK_TO_NAME);
                    return;
                }
                backToInner(resultCode, name,
                        data == null ? null : new Intent().putExtras(data).setData(data.getData()));
            } else {
                int count = data.getIntExtra(Const.EXTRA_BACK_TO_COUNT, -1);
                if (--count <= 0) {
                    data.removeExtra(Const.EXTRA_BACK_TO_COUNT);
                    return;
                }
                backTo(resultCode, count,
                        data == null ? null : new Intent().putExtras(data).setData(data.getData()));
            }
        }
    }
}

From source file:org.kontalk.ui.ConversationsActivity.java

@Override
protected void onResumeFragments() {
    super.onResumeFragments();

    Intent intent = getIntent();
    if (intent != null) {
        Intent sendIntent = getIntent().getParcelableExtra(EXTRA_SEND_INTENT);
        if (sendIntent != null) {
            // handle the share intent sent from ComposeMessage
            processSendIntent(sendIntent);
            // clear the intent
            intent.removeExtra(EXTRA_SEND_INTENT);
        }// w w w  . j  a v a  2 s. c om
    }
}

From source file:com.wizardsofm.deskclock.timer.TimerFragment.java

@Override
public void onStart() {
    super.onStart();

    // Initialize the page indicators.
    updatePageIndicators();// w ww  . j ava  2s . c om

    boolean createTimer = false;
    int showTimerId = -1;

    // Examine the intent of the parent activity to determine which view to display.
    final Intent intent = getActivity().getIntent();
    if (intent != null) {
        // These extras are single-use; remove them after honoring them.
        createTimer = intent.getBooleanExtra(EXTRA_TIMER_SETUP, false);
        intent.removeExtra(EXTRA_TIMER_SETUP);

        showTimerId = intent.getIntExtra(HandleDeskClockApiCalls.EXTRA_TIMER_ID, -1);
        intent.removeExtra(HandleDeskClockApiCalls.EXTRA_TIMER_ID);
    }

    // Choose the view to display in this fragment.
    if (showTimerId != -1) {
        // A specific timer must be shown; show the list of timers.
        showTimersView(UpdateType.FAB_AND_BUTTONS_IMMEDIATE);
    } else if (!hasTimers() || createTimer || mTimerSetupState != null) {
        // No timers exist, a timer is being created, or the last view was timer setup;
        // show the timer setup view.
        showCreateTimerView(UpdateType.FAB_AND_BUTTONS_IMMEDIATE);

        if (mTimerSetupState != null) {
            mCreateTimerView.setState(mTimerSetupState);
            mTimerSetupState = null;
        }
    } else {
        // Otherwise, default to showing the list of timers.
        showTimersView(UpdateType.FAB_AND_BUTTONS_IMMEDIATE);
    }

    // If the intent did not specify a timer to show, show the last timer that expired.
    if (showTimerId == -1) {
        final Timer timer = DataModel.getDataModel().getMostRecentExpiredTimer();
        showTimerId = timer == null ? -1 : timer.getId();
    }

    // If a specific timer should be displayed, display the corresponding timer tab.
    if (showTimerId != -1) {
        final Timer timer = DataModel.getDataModel().getTimer(showTimerId);
        if (timer != null) {
            final int index = DataModel.getDataModel().getTimers().indexOf(timer);
            mViewPager.setCurrentItem(index);
        }
    }
}