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:it.geosolutions.android.map.fragment.FeatureInfoLayerListFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onViewCreated(view, savedInstanceState);
    //init progress bar and loading text
    startLoadingGUI();//w  w w  . ja v  a 2  s.c o  m
    //set the click listener for the items
    getListView().setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent i = new Intent(view.getContext(), GetFeatureInfoAttributeActivity.class);
            i.putExtras(getActivity().getIntent().getExtras());
            i.removeExtra("layers");
            // add a list with only one layer
            ArrayList<String> subList = new ArrayList<String>();
            FeatureInfoQueryResult item = (FeatureInfoQueryResult) parent.getAdapter().getItem(position);
            subList.add(item.getLayerName());
            i.putExtra("layers", subList);
            i.putExtra("start", 0);
            i.putExtra("limit", 1);
            //don't allow picking the position 
            String action = getActivity().getIntent().getAction();
            i.setAction(action);
            getActivity().startActivityForResult(i, GetFeatureInfoAttributeActivity.GET_ITEM);
        }
    });
}

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

private void startInvite() {
    Context ctx = getActivity();//from ww w . ja  v a  2s.c  o  m
    Intent shareIntent = SystemUtils.externalIntent(Intent.ACTION_SEND);
    shareIntent.setType(TextComponent.MIME_TYPE);
    shareIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.text_invite_message));

    List<ResolveInfo> resInfo = ctx.getPackageManager().queryIntentActivities(shareIntent, 0);
    // having size=1 means that we are the only handlers
    if (resInfo != null && resInfo.size() > 1) {
        List<Intent> targets = new ArrayList<>();

        for (ResolveInfo resolveInfo : resInfo) {
            String packageName = resolveInfo.activityInfo.packageName;

            if (!ctx.getPackageName().equals(packageName)) {
                // copy intent and add resolved info
                Intent targetShareIntent = new Intent(shareIntent);
                targetShareIntent.setPackage(packageName)
                        .setComponent(new ComponentName(packageName, resolveInfo.activityInfo.name))
                        .putExtra("org.kontalk.invite.label",
                                resolveInfo.activityInfo.loadLabel(ctx.getPackageManager()));

                targets.add(targetShareIntent);
            }
        }

        if (targets.size() > 0) {
            // initial intents are added before the main intent, so we remove the last one here
            Intent chooser = Intent.createChooser(targets.remove(targets.size() - 1),
                    getString(R.string.menu_invite));
            if (targets.size() > 0) {
                Collections.sort(targets, new DisplayNameComparator());
                // remove custom extras
                for (Intent intent : targets)
                    intent.removeExtra("org.kontalk.invite.label");

                Parcelable[] extraIntents = targets.toArray(new Parcelable[targets.size()]);
                chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, extraIntents);
            }

            startActivity(chooser);
            return;
        }
    }

    // no activity to handle invitation
    Toast.makeText(ctx, R.string.warn_invite_no_app, Toast.LENGTH_SHORT).show();
}

From source file:com.deliciousdroid.activity.FragmentBaseActivity.java

@Override
@TargetApi(14)/*  ww  w  .  j  a  v  a2  s  .  c om*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mContext = this;
    mAccountManager = AccountManager.get(this);
    settings = PreferenceManager.getDefaultSharedPreferences(this);

    loadSettings();
    init();

    if (android.os.Build.VERSION.SDK_INT >= 14) {
        getActionBar().setHomeButtonEnabled(true);
    }

    Intent intent = getIntent();

    if (Intent.ACTION_SEARCH.equals(intent.getAction()) && !intent.hasExtra("MainSearchResults")) {
        if (intent.hasExtra(SearchManager.QUERY)) {
            Intent i = new Intent(this, MainSearchResults.class);
            i.putExtras(intent.getExtras());
            startActivity(i);
            finish();
        } else {
            onSearchRequested();
        }
    } else if (Constants.ACTION_SEARCH_SUGGESTION.equals(intent.getAction())) {
        Uri data = intent.getData();
        String path = null;
        String tagname = null;

        if (data != null) {
            path = data.getPath();
            tagname = data.getQueryParameter("tagname");
        }

        if (data.getScheme() == null || !data.getScheme().equals("content")) {
            Intent i = new Intent(Intent.ACTION_VIEW, data);
            startActivity(i);
            finish();
        } else if (path.contains("bookmarks") && TextUtils.isDigitsOnly(data.getLastPathSegment())
                && intent.hasExtra(SearchManager.USER_QUERY)) {
            Intent viewBookmark = new Intent(this, ViewBookmark.class);
            viewBookmark.setAction(Intent.ACTION_VIEW);
            viewBookmark.setData(data);
            viewBookmark.removeExtra(SearchManager.USER_QUERY);
            Log.d("View Bookmark Uri", data.toString());
            startActivity(viewBookmark);
            finish();
        } else if (tagname != null) {
            Intent viewTags = new Intent(this, BrowseBookmarks.class);
            viewTags.setData(data);

            Log.d("View Tags Uri", data.toString());
            startActivity(viewTags);
            finish();
        }
    }
}

From source file:jamesmorrisstudios.com.randremind.activities.MainActivity.java

private void clearForOpen(Intent intent) {
    clearBackStack();//from  www  .  j a v  a2 s.  com
    if (intent != null) {
        intent.removeExtra("REMINDER");
        intent.removeExtra("NAME");
    }
}

From source file:com.yek.keyboard.ui.settings.MainSettingsActivity.java

private void handleAppShortcuts(Intent intent) {
    if (intent != null && Intent.ACTION_VIEW.equals(intent.getAction())
            && intent.hasExtra(EXTRA_KEY_APP_SHORTCUT_ID)) {
        final String shortcutId = intent.getStringExtra(EXTRA_KEY_APP_SHORTCUT_ID);
        intent.removeExtra(EXTRA_KEY_APP_SHORTCUT_ID);

        switch (shortcutId) {
        case "keyboards":
            //  onNavigateToKeyboardAddonSettings(null);
            break;
        case "themes":
            // onNavigateToKeyboardThemeSettings(null);
            break;
        case "gestures":
            //  onNavigateToGestureSettings(null);
            break;
        case "quick_keys":
            // onNavigateToQuickTextSettings(null);
            break;
        case "ui_tweaks":
            //onNavigateToUserInterfaceSettings(null);
            break;
        default://w  w w . j a  v  a2 s  .  c  o  m
            throw new IllegalArgumentException("Unknown app-shortcut " + shortcutId);
        }
    }
}

From source file:com.todoroo.astrid.activity.TaskEditFragment.java

/**
 * Helper to remove task edit specific info from activity intent
 * @param intent/*  w  w w .  java 2  s. co  m*/
 */
public static void removeExtrasFromIntent(Intent intent) {
    if (intent != null) {
        intent.removeExtra(TaskListActivity.OPEN_TASK);
        intent.removeExtra(TOKEN_PICTURE_IN_PROGRESS);
    }
}

From source file:org.selfkleptomaniac.mod.titwilio.TwilioandroidModule.java

@Override
public void onResume(Activity activity) {
    Log.d(TAG, "on Resume");
    if (this.args != null) {
        createPhone(this.args);

        Intent intent = activity.getIntent();
        Device device = intent.getParcelableExtra(Device.EXTRA_DEVICE);
        Connection connection = intent.getParcelableExtra(Device.EXTRA_CONNECTION);
        if (connection != null) {
            Log.d(TAG, "resume & connection");
            intent.removeExtra(Device.EXTRA_DEVICE);
            intent.removeExtra(Device.EXTRA_CONNECTION);
            phone.handleIncomingConnection(device, connection);
        } else {/*w w  w.  jav  a  2 s .co  m*/
            Log.d(TAG, "we have no way to handle incoming connection");
        }
    }
    super.onResume(activity);
}

From source file:osu.appclub.corvallisbus.MainActivity.java

@Override
protected void onResume() {
    super.onResume();
    isActivityRunning = true;//  w  ww  .j a  v  a2  s . c o m
    for (ActivityRunningMonitor.Listener listener : new ArrayList<>(activityRunningListeners)) {
        listener.onResume();
    }

    Intent intent = getIntent();
    int stopID = intent.getIntExtra(EXTRA_STOP_ID, -1);
    if (stopID != -1) {
        intent.removeExtra(EXTRA_STOP_ID);
        enqueueBusStop(stopID);
    }
}

From source file:com.tassadar.multirommgr.MainActivity.java

@Override
public void onFragmentViewCreated() {
    if (++m_fragmentViewsCreated == m_fragments.length) {
        // postDelayed because SwipeRefresher view ignores
        // setRefreshing call otherwise
        m_srLayout.postDelayed(new Runnable() {
            @Override/*from  w  w  w .  ja v  a 2 s  .c o m*/
            public void run() {
                Intent i = getIntent();
                if (i == null || !i.getBooleanExtra("force_refresh", false)) {
                    startRefresh(true);
                } else {
                    i.removeExtra("force_refresh");
                    refresh();
                }
            }
        }, 1);
    }
}

From source file:eu.inmite.apps.smsjizdenka.activity.MainActivity.java

private void handleIntent(Intent intent) {
    //React to notification when you really want to buy another ticket in a short time.
    if (intent.hasExtra(EXTRA_REALLY_BUY_CITY_ID)) {
        long cityId = intent.getLongExtra(EXTRA_REALLY_BUY_CITY_ID, -1);
        // delete extras so no intent can be catched again
        intent.removeExtra(EXTRA_REALLY_BUY_CITY_ID);
        getIntent().removeExtra(EXTRA_REALLY_BUY_CITY_ID);
        BuyTicketConfirmationDialogFragment.newInstance(cityId).show(getSupportFragmentManager(),
                BuyTicketConfirmationDialogFragment.TAG);
    }/*from   w  ww.  j  ava  2s  . c om*/
    // pubtran integration
    if (intent.hasExtra(EXTRA_AREA)) {
        City city = CityManager.get(c).getCityByPubtranCity(c, intent.getStringExtra(EXTRA_AREA));
        if (city != null) {
            int minutes = intent.getIntExtra(EXTRA_MINUTES, 0);
            //SL.get(AnalyticsService.class).trackEvent("pubtran", "on-start", "city", city.city, "minutes", String.valueOf(minutes));
            Intent i = new Intent(c, CityTicketsActivity.class);
            i.putExtra(CityTicketsActivity.EXTRA_CITY, city.city);
            i.putExtra(CityTicketsActivity.EXTRA_MINUTES, intent.getIntExtra(EXTRA_MINUTES, 0));
            startActivity(i);
        }
    }
    // message from inmite
    if (intent.hasExtra(EXTRA_MESSAGE) && !Preferences.getBoolean(c, Preferences.MESSAGE_READ, false)) {
        MessageDialogFragment.newInstance(intent.getStringExtra(EXTRA_MESSAGE))
                .show(getSupportFragmentManager(), MessageDialogFragment.TAG);
        Preferences.set(c, Preferences.MESSAGE_READ, true);
    }
}