Example usage for android.content Intent putExtras

List of usage examples for android.content Intent putExtras

Introduction

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

Prototype

public @NonNull Intent putExtras(@NonNull Bundle extras) 

Source Link

Document

Add a set of extended data to the intent.

Usage

From source file:org.getlantern.firetweet.util.Utils.java

public static void openStatus(final Context context, final ParcelableStatus status, Bundle activityOptions) {
    if (context == null || status == null)
        return;//from ww  w .ja  v  a  2  s. c o m
    final long account_id = status.account_id, status_id = status.id;
    final Bundle extras = new Bundle();
    extras.putParcelable(EXTRA_STATUS, status);
    final Uri.Builder builder = new Uri.Builder();
    builder.scheme(SCHEME_FIRETWEET);
    builder.authority(AUTHORITY_STATUS);
    builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(account_id));
    builder.appendQueryParameter(QUERY_PARAM_STATUS_ID, String.valueOf(status_id));
    final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());
    intent.setExtrasClassLoader(context.getClassLoader());
    intent.putExtras(extras);
    if (context instanceof Activity) {
        ActivityCompat.startActivity((Activity) context, intent, activityOptions);
    } else {
        context.startActivity(intent);
    }
}

From source file:org.getlantern.firetweet.util.Utils.java

public static void openUserProfile(final Context context, final ParcelableUser user,
        final Bundle activityOptions) {
    if (context == null || user == null)
        return;/* w  w w.j  a  va 2  s. c o m*/
    final Bundle extras = new Bundle();
    extras.putParcelable(EXTRA_USER, user);
    final Uri.Builder builder = new Uri.Builder();
    builder.scheme(SCHEME_FIRETWEET);
    builder.authority(AUTHORITY_USER);
    builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(user.account_id));
    if (user.id > 0) {
        builder.appendQueryParameter(QUERY_PARAM_USER_ID, String.valueOf(user.id));
    }
    if (user.screen_name != null) {
        builder.appendQueryParameter(QUERY_PARAM_SCREEN_NAME, user.screen_name);
    }
    final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());
    intent.setExtrasClassLoader(context.getClassLoader());
    intent.putExtras(extras);
    if (context instanceof Activity) {
        ActivityCompat.startActivity((Activity) context, intent, activityOptions);
    } else {
        context.startActivity(intent);
    }
}

From source file:com.aujur.ebookreader.activity.ReadingFragment.java

@Override
public void performSearch(String query) {

    LOG.debug("Starting search for: " + query);

    final ProgressDialog searchProgress = new ProgressDialog(context);
    searchProgress.setOwnerActivity(getActivity());
    searchProgress.setCancelable(true);/*w w  w  . j  a  v a2 s.  co  m*/
    searchProgress.setMax(100);
    searchProgress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);

    final SearchTextTask task = new SearchTextTask(bookView.getBook()) {

        int i = 0;

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

            searchProgress.setMessage(getString(R.string.search_wait));
            searchProgress.show();

            // Hide on-screen keyboard if it is showing
            InputMethodManager imm = (InputMethodManager) context
                    .getSystemService(Activity.INPUT_METHOD_SERVICE);
            imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

        }

        @Override
        protected void onProgressUpdate(SearchResult... values) {

            if (!isAdded()) {
                return;
            }

            super.onProgressUpdate(values);

            LOG.debug("Found match at index=" + values[0].getIndex() + ", offset=" + values[0].getStart()
                    + " with context " + values[0].getDisplay());
            SearchResult res = values[0];

            if (res.getDisplay() != null) {
                i++;
                String update = String.format(getString(R.string.search_hits), i);
                searchProgress.setMessage(update);
            }

            searchProgress.setProgress(bookView.getPercentageFor(res.getIndex(), res.getStart()));
        }

        @Override
        protected void onCancelled() {
            if (isAdded()) {
                Toast.makeText(context, R.string.search_cancelled, Toast.LENGTH_LONG).show();
            }
        }

        protected void onPostExecute(java.util.List<SearchResult> result) {

            searchProgress.dismiss();

            if (!isCancelled() && isAdded()) {
                if (result.size() > 0) {
                    searchResults = result;
                    searchResultWraper.setSearchResult(searchResults);

                    // showSearchResultDialog(result);
                    Intent intent = new Intent(getActivity(), ReadingOptionsActivity.class);
                    Bundle bundle = new Bundle();
                    bundle.putInt("SELECTED_TAB", 4);
                    intent.putExtras(bundle);
                    startActivity(intent);

                } else {
                    Toast.makeText(context, R.string.search_no_matches, Toast.LENGTH_LONG).show();
                }
            }
        };
    };

    searchProgress.setOnCancelListener(new DialogInterface.OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            task.cancel(true);
        }
    });

    task.execute(query);
}

From source file:uk.bowdlerize.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    switch (item.getItemId()) {
    case R.id.action_add: {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        // Get the layout inflater
        LayoutInflater inflater = getLayoutInflater();
        View dialogView = inflater.inflate(R.layout.dialog_add_url, null);

        final EditText urlET = (EditText) dialogView.findViewById(R.id.urlET);

        builder.setView(dialogView)/*from  w  w w. ja  va 2  s .  co  m*/
                .setPositiveButton(R.string.action_add, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        Bundle extras = new Bundle();
                        Intent receiveURLIntent = new Intent(MainActivity.this, CensorCensusService.class);

                        extras.putString("url", urlET.getText().toString());
                        extras.putString("hash", MD5(urlET.getText().toString()));
                        extras.putInt("urgency", 0);
                        extras.putBoolean("local", true);

                        //Add our extra info
                        if (getSharedPreferences(MainActivity.class.getSimpleName(), Context.MODE_PRIVATE)
                                .getBoolean("sendISPMeta", true)) {
                            WifiManager wifiMgr = (WifiManager) getSystemService(Context.WIFI_SERVICE);
                            WifiInfo wifiInfo = wifiMgr.getConnectionInfo();
                            TelephonyManager telephonyManager = ((TelephonyManager) getSystemService(
                                    Context.TELEPHONY_SERVICE));

                            if (wifiMgr.isWifiEnabled() && null != wifiInfo.getSSID()) {
                                LocalCache lc = null;
                                Pair<Boolean, String> seenBefore = null;
                                try {
                                    lc = new LocalCache(MainActivity.this);
                                    lc.open();
                                    seenBefore = lc.findSSID(wifiInfo.getSSID().replaceAll("\"", ""));
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }

                                if (null != lc)
                                    lc.close();

                                if (seenBefore.first) {
                                    extras.putString("isp", seenBefore.second);
                                } else {
                                    extras.putString("isp", "unknown");
                                }

                                try {
                                    extras.putString("sim", telephonyManager.getSimOperatorName());
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            } else {
                                try {
                                    extras.putString("isp", telephonyManager.getNetworkOperatorName());
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }

                                try {
                                    extras.putString("sim", telephonyManager.getSimOperatorName());
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                        }

                        receiveURLIntent.putExtras(extras);
                        startService(receiveURLIntent);
                        dialog.cancel();
                    }
                }).setNegativeButton(R.string.action_cancel, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });
        builder.show();
        return true;
    }
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.aujur.ebookreader.activity.ReadingFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.reading_menu, menu);

    this.searchMenuItem = menu.findItem(R.id.search_text);

    if (this.searchMenuItem != null) {
        final com.actionbarsherlock.widget.SearchView searchView = (com.actionbarsherlock.widget.SearchView) searchMenuItem
                .getActionView();/*w  w w .  j  a  va  2 s.c o  m*/

        if (searchView != null) {

            searchView.setSubmitButtonEnabled(true);
            searchView.setIconifiedByDefault(false);

            searchView
                    .setOnQueryTextListener(new com.actionbarsherlock.widget.SearchView.OnQueryTextListener() {

                        // This is a work-around, since we get the
                        // onQuerySubmit() event twice
                        // when the user hits enter
                        private String lastQuery = "";

                        @Override
                        public boolean onQueryTextSubmit(String query) {

                            /**
                             * hides and then unhides search tab to make
                             * sure keyboard disappears when query is
                             * submitted
                             */
                            if (searchView != null) {
                                searchView.setVisibility(View.INVISIBLE);
                                searchView.setVisibility(View.VISIBLE);

                            }

                            if (query.equals(lastQuery) && searchResults != null) {

                                // showSearchResultDialog(searchResults);
                                searchResultWraper.setSearchResult(searchResults);

                                Intent intent = new Intent(getActivity(), ReadingOptionsActivity.class);
                                Bundle bundle = new Bundle();
                                bundle.putInt("SELECTED_TAB", 4);
                                intent.putExtras(bundle);
                                startActivity(intent);

                                // searchView.onActionViewCollapsed();
                                // searchView.setQuery("", false);
                                // searchView.clearFocus();

                            } else if (!query.equals(lastQuery)) {
                                searchResults = null;
                                lastQuery = query;

                                // searchView.onActionViewCollapsed();
                                // searchView.setQuery("", false);
                                // searchView.clearFocus();

                                performSearch(query);
                            }

                            return false;
                        }

                        @Override
                        public boolean onQueryTextChange(String newText) {
                            return false;
                        }
                    });

            searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
                @Override
                public void onFocusChange(View v, boolean hasFocus) {

                    if (!hasFocus) {
                        if (searchMenuItem != null) {
                            searchMenuItem.collapseActionView();
                        }
                        if (searchView != null) {
                            searchView.setQuery("", false);

                        }
                    }

                }
            });

            searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {

                @Override
                public void onFocusChange(View v, boolean hasFocus) {

                    if (!hasFocus) {
                        if (searchMenuItem != null) {
                            searchMenuItem.collapseActionView();
                        } // end if
                        if (searchView != null) {
                            searchView.setQuery("", false);

                        } // end if
                    } // end if

                }
            });

        }
    }
}

From source file:com.hichinaschool.flashcards.anki.DeckPicker.java

/** Called when the activity is first created. */
@Override//from ww  w. j  ava2 s  .  co  m
protected void onCreate(Bundle savedInstanceState) throws SQLException {
    // Log.i(AnkiDroidApp.TAG, "DeckPicker - onCreate");
    Intent intent = getIntent();
    if (!isTaskRoot()) {
        // Log.i(AnkiDroidApp.TAG, "DeckPicker - onCreate: Detected multiple instance of this activity, closing it and return to root activity");
        Intent reloadIntent = new Intent(DeckPicker.this, DeckPicker.class);
        reloadIntent.setAction(Intent.ACTION_MAIN);
        if (intent != null && intent.getExtras() != null) {
            reloadIntent.putExtras(intent.getExtras());
        }
        if (intent != null && intent.getData() != null) {
            reloadIntent.setData(intent.getData());
        }
        reloadIntent.addCategory(Intent.CATEGORY_LAUNCHER);
        reloadIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        finish();
        startActivityIfNeeded(reloadIntent, 0);
    }
    if (intent.getData() != null) {
        mImportPath = getIntent().getData().getEncodedPath();
    }

    // need to start this here in order to avoid showing deckpicker before splashscreen
    if (AnkiDroidApp.colIsOpen()) {
        setTitle(getResources().getString(R.string.app_name));
    } else {
        setTitle("");
        mOpenCollectionHandler.onPreExecute();
    }

    Themes.applyTheme(this);
    super.onCreate(savedInstanceState);

    // mStartedByBigWidget = intent.getIntExtra(EXTRA_START, EXTRA_START_NOTHING);

    SharedPreferences preferences = restorePreferences();

    // activate broadcast messages if first start of a day
    if (mLastTimeOpened < UIUtils.getDayStart()) {
        preferences.edit().putBoolean("showBroadcastMessageToday", true).commit();
    }
    preferences.edit().putLong("lastTimeOpened", System.currentTimeMillis()).commit();

    // if (intent != null && intent.hasExtra(EXTRA_DECK_ID)) {
    // openStudyOptions(intent.getLongExtra(EXTRA_DECK_ID, 1));
    // }

    //   BroadcastMessages.checkForNewMessages(this);

    View mainView = getLayoutInflater().inflate(R.layout.deck_picker, null);
    setContentView(mainView);

    // check, if tablet layout
    View studyoptionsFrame = findViewById(R.id.studyoptions_fragment);
    mFragmented = studyoptionsFrame != null && studyoptionsFrame.getVisibility() == View.VISIBLE;

    Themes.setContentStyle(mFragmented ? mainView : mainView.findViewById(R.id.deckpicker_view),
            Themes.CALLER_DECKPICKER);

    registerExternalStorageListener();

    if (!mFragmented) {
        //            mAddButton = (ImageButton) findViewById(R.id.deckpicker_add);
        //            mAddButton.setOnClickListener(new OnClickListener() {
        //                @Override
        //                public void onClick(View v) {
        //                    addNote();
        //                }
        //            });
        //
        //            mCardsButton = (ImageButton) findViewById(R.id.deckpicker_card_browser);
        //            mCardsButton.setOnClickListener(new OnClickListener() {
        //                @Override
        //                public void onClick(View v) {
        //                    openCardBrowser();
        //                }
        //            });
        //
        //            mStatsButton = (ImageButton) findViewById(R.id.statistics_all_button);
        //            mStatsButton.setOnClickListener(new OnClickListener() {
        //                @Override
        //                public void onClick(View v) {
        //                    showDialog(DIALOG_SELECT_STATISTICS_TYPE);
        //                }
        //            });
        //
        //            mSyncButton = (ImageButton) findViewById(R.id.sync_all_button);
        //            mSyncButton.setOnClickListener(new OnClickListener() {
        //                @Override
        //                public void onClick(View v) {
        //                    sync();
        //                }
        //            });
    }

    mInvalidateMenu = false;
    mDeckList = new ArrayList<HashMap<String, String>>();
    mDeckListView = (ListView) findViewById(R.id.files);
    //   mDeckListAdapter = new SimpleAdapter(this, mDeckList, R.layout.deck_item, new String[] { "name", "new", "lrn",
    //      "rev", // "complMat", "complAll",
    //      "sep", "dyn" }, new int[] { R.id.DeckPickerName, R.id.deckpicker_new, R.id.deckpicker_lrn,
    //      R.id.deckpicker_rev, // R.id.deckpicker_bar_mat, R.id.deckpicker_bar_all,
    //      R.id.deckpicker_deck, R.id.DeckPickerName });

    mDeckListAdapter = new SimpleAdapter(this, mDeckList, R.layout.deck_item,
            new String[] { "name", "new", "lrn", "rev", "sep", "dyn", "url" },
            new int[] { R.id.DeckPickerName, R.id.deckpicker_new, R.id.deckpicker_lrn, R.id.deckpicker_rev,
                    R.id.deckpicker_deck, R.id.DeckPickerName, R.id.deckpicker_url });

    mDeckListAdapter.setViewBinder(new SimpleAdapter.ViewBinder() {
        @Override
        public boolean setViewValue(final View view, final Object data, String text) {
            if (view.getId() == R.id.deckpicker_url) {
                // If "url" field has text, it means the deck must be downloaded
                // so we put the downloadButton visible and add its listener
                if (!text.equals("")) {

                    final View parentView = (View) view.getParent();
                    Button downloadButton = (Button) parentView.findViewById(R.id.deckpicker_button);

                    downloadButton.setVisibility(View.VISIBLE);
                    parentView.findViewById(R.id.deckpicker_new).setVisibility(View.GONE);
                    parentView.findViewById(R.id.deckpicker_rev).setVisibility(View.GONE);
                    parentView.findViewById(R.id.deckpicker_lrn).setVisibility(View.GONE);

                    downloadButton.setOnClickListener(new OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            //   ListView lv = (ListView) parentView.getParent().getParent();
                            //                        int i;
                            //                        for (i = 0; i < mDeckList.size(); i++) {
                            //                           if (mDeckListView.getItemAtPosition(i).equals(view)){
                            //                              mDeckLastItemSelected = i;
                            //                           }
                            //                        }

                            // Gets url from the selected deck and download it
                            TextView txt = (TextView) ((View) view.getParent())
                                    .findViewById(R.id.deckpicker_url);
                            String url = txt.getText().toString();
                            Connection.downloadSharedDeck(mDownloadDeckListener,
                                    new Connection.Payload(new Object[] { url }));
                        }
                    });
                } else {
                    Button downloadButton = (Button) ((View) view.getParent())
                            .findViewById(R.id.deckpicker_button);
                    downloadButton.setVisibility(View.GONE);
                    ((View) view.getParent()).findViewById(R.id.deckpicker_new).setVisibility(View.VISIBLE);
                    ((View) view.getParent()).findViewById(R.id.deckpicker_rev).setVisibility(View.VISIBLE);
                    ((View) view.getParent()).findViewById(R.id.deckpicker_lrn).setVisibility(View.VISIBLE);
                }
            }
            if (view.getId() == R.id.deckpicker_deck) {
                if (text.equals("top")) {
                    view.setBackgroundResource(R.drawable.white_deckpicker_top);
                    return true;
                } else if (text.equals("bot")) {
                    view.setBackgroundResource(R.drawable.white_deckpicker_bottom);
                    return true;
                } else if (text.equals("ful")) {
                    view.setBackgroundResource(R.drawable.white_deckpicker_full);
                    return true;
                } else if (text.equals("cen")) {
                    view.setBackgroundResource(R.drawable.white_deckpicker_center);
                    return true;
                }
            } else if (view.getId() == R.id.DeckPickerName) {
                if (text.equals("d0")) {
                    ((TextView) view).setTextColor(getResources().getColor(R.color.non_dyn_deck));
                    return true;
                } else if (text.equals("d1")) {
                    ((TextView) view).setTextColor(getResources().getColor(R.color.dyn_deck));
                    return true;
                }
            }
            // } else if (view.getId() == R.id.deckpicker_bar_mat || view.getId() == R.id.deckpicker_bar_all) {
            // if (text.length() > 0 && !text.equals("-1.0")) {
            // View parent = (View)view.getParent().getParent();
            // if (text.equals("-2")) {
            // parent.setVisibility(View.GONE);
            // } else {
            // Utils.updateProgressBars(view, (int) UIUtils.getDensityAdjustedValue(DeckPicker.this, 3.4f),
            // (int) (Double.parseDouble(text) * ((View)view.getParent().getParent().getParent()).getHeight()));
            // if (parent.getVisibility() == View.INVISIBLE) {
            // parent.setVisibility(View.VISIBLE);
            // parent.setAnimation(ViewAnimation.fade(ViewAnimation.FADE_IN, 500, 0));
            // }
            // }
            // }
            // return true;
            // } else if (view.getVisibility() == View.INVISIBLE) {
            // if (!text.equals("-1")) {
            // view.setVisibility(View.VISIBLE);
            // view.setAnimation(ViewAnimation.fade(ViewAnimation.FADE_IN, 500, 0));
            // return false;
            // }
            // } else if (text.equals("-1")){
            // view.setVisibility(View.INVISIBLE);
            // return false;
            return false;
        }
    });
    mDeckListView.setOnItemClickListener(mDeckSelHandler);
    mDeckListView.setAdapter(mDeckListAdapter);

    if (mFragmented) {
        mDeckListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    }

    registerForContextMenu(mDeckListView);

    showStartupScreensAndDialogs(preferences, 0);

    if (mSwipeEnabled) {
        gestureDetector = new GestureDetector(new MyGestureDetector());
        mDeckListView.setOnTouchListener(new View.OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
                if (gestureDetector.onTouchEvent(event)) {
                    return true;
                }
                return false;
            }
        });
    }
}

From source file:com.android.app.MediaPlaybackActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Intent intent;
    try {/* w w  w  .  j av  a  2  s  .  c o m*/
        switch (item.getItemId()) {
        case GOTO_START:
            intent = new Intent();
            intent.setClass(this, MusicBrowserActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
            finish();
            break;
        case USE_AS_RINGTONE: {
            // Set the system setting to make this the current ringtone
            if (mService != null) {
                MusicUtils.setRingtone(this, mService.getAudioId());
            }
            return true;
        }
        case PARTY_SHUFFLE:
            MusicUtils.togglePartyShuffle();
            setShuffleButtonImage();
            break;

        case NEW_PLAYLIST: {
            intent = new Intent();
            intent.setClass(this, CreatePlaylist.class);
            startActivityForResult(intent, NEW_PLAYLIST);
            return true;
        }

        case PLAYLIST_SELECTED: {
            long[] list = new long[1];
            list[0] = MusicUtils.getCurrentAudioId();
            long playlist = item.getIntent().getLongExtra("playlist", 0);
            MusicUtils.addToPlaylist(this, list, playlist);
            return true;
        }

        case DELETE_ITEM: {
            if (mService != null) {
                long[] list = new long[1];
                list[0] = MusicUtils.getCurrentAudioId();
                Bundle b = new Bundle();
                String f;
                if (android.os.Environment.isExternalStorageRemovable()) {
                    f = getString(R.string.delete_song_desc, mService.getTrackName());
                } else {
                    f = getString(R.string.delete_song_desc_nosdcard, mService.getTrackName());
                }
                b.putString("description", f);
                b.putLongArray("items", list);
                intent = new Intent();
                intent.setClass(this, DeleteItems.class);
                intent.putExtras(b);
                startActivityForResult(intent, -1);
            }
            return true;
        }

        case EFFECTS_PANEL: {
            Intent i = new Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL);
            i.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, mService.getAudioSessionId());
            startActivityForResult(i, EFFECTS_PANEL);
            return true;
        }
        }
    } catch (RemoteException ex) {
    }
    return super.onOptionsItemSelected(item);
}

From source file:edu.cens.loci.ui.PlaceListActivity.java

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {

    Intent intent;
    Bundle extras;/*from   ww w  .  j a v a 2 s  .  c o m*/

    switch (mMode) {
    case MODE_VIEW:
        //Log.i(TAG, "onListItemClick : position=" + position + ", id=" + id);
        if ((mFilterState & FILTER_STATE_SUGGESTED) != 0) {
            if (position == 0) {
                intent = new Intent(Constants.Intents.UI.ACTION_VIEW_SUGGESTED_GPS_PLACES);
                Toast.makeText(this, "Not supported yet", Toast.LENGTH_SHORT).show();
                return;
            } else {
                intent = new Intent(Intent.ACTION_VIEW, getSelectedUri(position - 1));
            }
        } else {
            intent = new Intent(Intent.ACTION_VIEW, getSelectedUri(position));
        }
        startActivity(intent);
        break;
    case MODE_INSERT:
        extras = getIntent().getExtras();
        if (position == 0) {
            intent = new Intent(Intent.ACTION_INSERT, Places.CONTENT_URI);
            if (extras.containsKey(UI.LIST_ORDER_EXTRA_WIFI_KEY)
                    && extras.containsKey(UI.LIST_ORDER_EXTRA_WIFI_TIME_KEY)) {
                String wifiJson = getIntent().getExtras().getString(UI.LIST_ORDER_EXTRA_WIFI_KEY);
                String timestamp = getIntent().getExtras().getString(UI.LIST_ORDER_EXTRA_WIFI_TIME_KEY);
                intent.putExtra(Insert.WIFI_FINTERPRINT, wifiJson);
                intent.putExtra(Insert.TIME, timestamp);
            }
            //intent = new Intent(Intent.ACTION_EDIT, getSelectedUri(position));
        } else {
            intent = new Intent(Intent.ACTION_EDIT, getSelectedUri(position - 1));
            if (extras.containsKey(UI.LIST_ORDER_EXTRA_WIFI_KEY)
                    && extras.containsKey(UI.LIST_ORDER_EXTRA_WIFI_TIME_KEY)) {
                String wifiJson = getIntent().getExtras().getString(UI.LIST_ORDER_EXTRA_WIFI_KEY);
                String timestamp = getIntent().getExtras().getString(UI.LIST_ORDER_EXTRA_WIFI_TIME_KEY);
                intent.putExtra(Insert.WIFI_FINTERPRINT, wifiJson);
                intent.putExtra(Insert.TIME, timestamp);
            }
        }
        //extras = getIntent().getExtras();
        //if (extras != null) 
        //   intent.putExtras(extras);

        startActivityForResult(intent, SUBACTIVITY_NEW_PLACE);
        break;
    case MODE_REGISTER_SUGGESTED:
        extras = getIntent().getExtras();
        if (position == 0) {
            intent = new Intent(Intents.UI.ACTION_CREATE_FROM_SUGGESTED_PLACE, getIntent().getData());
        } else {
            //intent = new Intent(Intents.UI.ACTION_ADDTO_FROM_SUGESTED_PLACE, getIntent().getData());
            //extras.putLong(Intents.UI.SELECTED_PLACE_ID_EXTRA_KEY, getSelectedPlaceId(position-1));
            intent = new Intent(Intents.UI.ACTION_ADDTO_FROM_SUGESTED_PLACE, getSelectedUri(position - 1));
            extras.putLong(Intents.UI.SELECTED_PLACE_ID_EXTRA_KEY, ContentUris.parseId(getIntent().getData()));
        }
        if (extras != null)
            intent.putExtras(extras);

        startActivityForResult(intent, SUBACTIVITY_NEW_PLACE);
        break;
    case MODE_PICK:
        final Uri uri = getSelectedUri(position);
        intent = new Intent();
        setResult(RESULT_OK, intent.setData(uri));
        finish();
        break;
    }

}

From source file:com.max2idea.android.limbo.main.LimboActivity.java

public void browse(String fileType) {
    // Check if SD card is mounted
    // Log.v(TAG, "Browsing: " + fileType);
    String state = Environment.getExternalStorageState();
    if (!Environment.MEDIA_MOUNTED.equals(state)) {
        Toast.makeText(getApplicationContext(), "Error: SD card is not mounted", Toast.LENGTH_LONG).show();
        return;/* w  ww .j  ava  2  s.com*/
    }

    String dir = null;
    // GET THE LAST ACCESSED DIR FROM THE REG
    String lastDir = LimboSettingsManager.getLastDir(this);
    try {
        Intent i = null;
        i = getFileManIntent();
        Bundle b = new Bundle();
        b.putString("lastDir", lastDir);
        b.putString("fileType", fileType);
        i.putExtras(b);
        // Log.v("**PASS** ", lastDir);
        startActivityForResult(i, Const.FILEMAN_REQUEST_CODE);

    } catch (Exception e) {
        // Log.v(TAG, "Error while starting Filemanager: " +
        // e.getMessage());
    }
}

From source file:com.anhuioss.crowdroid.activity.MoreFunctionActivity.java

@Override
public void onClick(View view) {
    // TODO Auto-generated method stub
    switch (view.getId()) {
    case R.id.head_back: {
        finish();//  w w  w  . jav a2s.  c om
        break;
    }
    case R.id.head_refresh: {
        Intent comment = new Intent(MoreFunctionActivity.this, HomeTimelineActivity.class);
        startActivity(comment);
        break;
    }
    case R.id.account_manage: {
        Intent intent = new Intent(MoreFunctionActivity.this, AccountManageActivity.class);
        startActivity(intent);
        break;
    }
    case R.id.themes_setting: {
        Intent intent = new Intent(MoreFunctionActivity.this, ThemeSettingActivity.class);
        startActivity(intent);
        break;
    }
    case R.id.skim: {
        Intent intent = new Intent(MoreFunctionActivity.this, BrowseModeActivity.class);
        startActivity(intent);
        break;
    }
    case R.id.weibo_setting: {
        Intent intent = new Intent(MoreFunctionActivity.this, WeiBoSettingActivity.class);
        startActivity(intent);
        break;
    }
    case R.id.setting: {
        Intent intent = new Intent(MoreFunctionActivity.this, PersonalSettingActivity.class);
        startActivity(intent);
        break;
    }
    case R.id.license: {
        LicenseDialog lic = new LicenseDialog(this);
        lic.show();
        break;
    }
    case R.id.about: {
        Uri uri = null;
        String language = this.getApplicationContext().getResources().getConfiguration().locale.getLanguage();
        if (language != null && language.equals("zh")) {
            uri = Uri.parse("http://www.anhuioss.com/cn/crowdroid");
        } else if (language != null && language.equals("ja")) {
            uri = Uri.parse("http://www.anhuioss.com/crowdroid");
        } else {
            uri = Uri.parse("http://www.anhuioss.com/en/crowdroid");
        }
        Intent i = new Intent(Intent.ACTION_VIEW, uri);
        startActivity(i);
        break;
    }
    case R.id.office_weibo: {
        Intent intent = new Intent(MoreFunctionActivity.this, ProfileActivity.class);
        Bundle bundle = new Bundle();
        if (statusData.getCurrentService().equals(IGeneral.SERVICE_NAME_CROWDROID_FOR_BUSINESS)) {
            bundle.putString("name", "nakao");
            bundle.putString("uid", "11");
        } else if (statusData.getCurrentService().equals(IGeneral.SERVICE_NAME_TWITTER)
                || statusData.getCurrentService().equals(IGeneral.SERVICE_NAME_TWITTER_PROXY)) {
            String language = this.getApplicationContext().getResources().getConfiguration().locale
                    .getLanguage();
            if (language != null && language.equals("zh")) {
                bundle.putString("name", "anhuioss_cn");
            } else if (language != null && language.equals("ja")) {
                bundle.putString("name", "AnhuiOSS");
            } else {
                bundle.putString("name", "AnhuiOSS_EN");

            }

        } else if (statusData.getCurrentService().equals(IGeneral.SERVICE_NAME_SINA)
                || statusData.getCurrentService().equals(IGeneral.SERVICE_NAME_TENCENT)
                || statusData.getCurrentService().equals(IGeneral.SERVICE_NAME_SOHU)) {
            bundle.putString("name", "???");
            bundle.putString("user_name", "anhuioss");
        } else {
            bundle.putString("name", "???");
            bundle.putString("user_name", "???");
            bundle.putString("uid", "324411430");

        }
        // bundle.putString("name", "");
        // bundle.putString("user_name", "");
        // bundle.putString("uid","");
        intent.putExtras(bundle);
        intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
        startActivity(intent);
        break;
    }
    case R.id.check_update: {
        new DownloadUpdateDialog(this).show();
        break;
    }
    case R.id.logout: {
        confirmLogoutDialog();
        break;
    }
    case R.id.feedback: {
        if (statusData.getCurrentService().equals(IGeneral.SERVICE_NAME_RENREN)) {
            Intent intent = new Intent(MoreFunctionActivity.this, CommentActivity.class);
            Bundle bundle = new Bundle();
            bundle.putString("message_id", "478083032");
            bundle.putString("message", "");
            bundle.putString("user_id", "324411430");
            bundle.putString("feed_type", "20");
            bundle.putString("feedback", "");
            intent.putExtras(bundle);
            intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
            startActivity(intent);
        } else {
            Intent intent = new Intent(MoreFunctionActivity.this, SendMessageActivity.class);
            Bundle bundle = new Bundle();
            bundle.putString("feedback", "FeedBack");
            intent.putExtras(bundle);
            intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
            startActivity(intent);
        }

        break;
    }
    default:
        break;
    }
}