List of usage examples for android.content Intent putExtras
public @NonNull Intent putExtras(@NonNull Bundle extras)
From source file:com.facebook.login.LoginManager.java
private Intent getFacebookActivityIntent(LoginClient.Request request) { Intent intent = new Intent(); intent.setClass(FacebookSdk.getApplicationContext(), FacebookActivity.class); intent.setAction(request.getLoginBehavior().toString()); // Let FacebookActivity populate extras appropriately LoginClient.Request authClientRequest = request; Bundle extras = new Bundle(); extras.putParcelable(LoginFragment.EXTRA_REQUEST, request); intent.putExtras(extras); return intent; }
From source file:com.andryr.musicplayer.PlaybackService.java
private void sendBroadcast(String action, Bundle data) { Log.d("action", action + "2"); Intent i = new Intent(action); if (data != null) { i.putExtras(data); }/*from ww w.j ava 2 s .c om*/ sendStickyBroadcast(i); refreshAppWidgets(); }
From source file:com.battlelancer.seriesguide.ui.OverviewFragment.java
private void onLoadEpisodeDetails(final Cursor episode) { final int seasonNumber = episode.getInt(EpisodeQuery.SEASON); final int episodeNumber = episode.getInt(EpisodeQuery.NUMBER); final String episodeTitle = episode.getString(EpisodeQuery.TITLE); // Description, DVD episode number, guest stars, absolute number ((TextView) getView().findViewById(R.id.TextViewEpisodeDescription)) .setText(episode.getString(EpisodeQuery.OVERVIEW)); boolean isShowingMeta; isShowingMeta = Utils.setLabelValueOrHide(getView().findViewById(R.id.labelDvd), (TextView) getView().findViewById(R.id.textViewEpisodeDVDnumber), episode.getDouble(EpisodeQuery.DVDNUMBER)); isShowingMeta |= Utils.setLabelValueOrHide(getView().findViewById(R.id.labelGuestStars), (TextView) getView().findViewById(R.id.TextViewEpisodeGuestStars), Utils.splitAndKitTVDBStrings(episode.getString(EpisodeQuery.GUESTSTARS))); // hide divider if no meta is visible getView().findViewById(R.id.dividerHorizontalOverviewEpisodeMeta) .setVisibility(isShowingMeta ? View.VISIBLE : View.GONE); // TVDb rating final String ratingText = episode.getString(EpisodeQuery.RATING); if (ratingText != null && ratingText.length() != 0) { ((TextView) getView().findViewById(R.id.textViewRatingsTvdbValue)).setText(ratingText); }//from w w w. ja v a2 s . com // IMDb button String imdbId = episode.getString(EpisodeQuery.IMDBID); if (TextUtils.isEmpty(imdbId) && mShowCursor != null) { // fall back to show IMDb id imdbId = mShowCursor.getString(ShowQuery.SHOW_IMDBID); } ServiceUtils.setUpImdbButton(imdbId, getView().findViewById(R.id.buttonShowInfoIMDB), TAG, getActivity()); // TVDb button final int episodeTvdbId = episode.getInt(EpisodeQuery._ID); final int seasonTvdbId = episode.getInt(EpisodeQuery.REF_SEASON_ID); ServiceUtils.setUpTvdbButton(getShowId(), seasonTvdbId, episodeTvdbId, getView().findViewById(R.id.buttonTVDB), TAG); // trakt button ServiceUtils.setUpTraktButton(getShowId(), seasonNumber, episodeNumber, getView().findViewById(R.id.buttonTrakt), TAG); // Web search button getView().findViewById(R.id.buttonWebSearch).setVisibility(View.GONE); // trakt shouts button getView().findViewById(R.id.buttonShouts).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mCurrentEpisodeCursor != null && mCurrentEpisodeCursor.moveToFirst()) { Intent i = new Intent(getActivity(), TraktShoutsActivity.class); i.putExtras(TraktShoutsActivity.createInitBundleEpisode(getShowId(), seasonNumber, episodeNumber, episodeTitle)); ActivityCompat.startActivity(getActivity(), i, ActivityOptionsCompat .makeScaleUpAnimation(v, 0, 0, v.getWidth(), v.getHeight()).toBundle()); fireTrackerEvent("Comments"); } } }); // trakt ratings onLoadTraktRatings(true); }
From source file:ee.ioc.phon.android.speak.RecognizerIntentActivity.java
/** * <p>Returns the transcription results (matches) to the caller, * or sends them to the pending intent, or performs a web search.</p> * * <p>If a pending intent was specified then use it. This is the case with * applications that use the standard search bar (e.g. Google Maps and YouTube).</p> * * <p>Otherwise. If there was no caller (i.e. we cannot return the results), or * the caller asked us explicitly to perform "web search", then do that, possibly * disambiguating the results or redoing the recognition. * This is the case when K6nele was launched from its launcher icon (i.e. no caller), * or from a browser app.// w w w . j a v a2 s .c om * (Note that trying to return the results to Google Chrome does not seem to work.)</p> * * <p>Otherwise. Just return the results to the caller.</p> * * <p>Note that we assume that the given list of matches contains at least one * element.</p> * * @param handler message handler * @param matches transcription results (one or more hypotheses) */ private void returnOrForwardMatches(final Handler handler, ArrayList<String> matches) { // Throw away matches that the user is not interested in int maxResults = mExtras.getInt(RecognizerIntent.EXTRA_MAX_RESULTS); if (maxResults > 0 && matches.size() > maxResults) { matches.subList(maxResults, matches.size()).clear(); } if (mExtraResultsPendingIntent == null) { if (getCallingActivity() == null || RecognizerIntent.ACTION_WEB_SEARCH.equals(getIntent().getAction()) || mExtras.getBoolean(RecognizerIntent.EXTRA_WEB_SEARCH_ONLY)) { handleResultsByWebSearch(this, handler, matches); return; } else { setResultIntent(handler, matches); } } else { Bundle bundle = mExtras.getBundle(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT_BUNDLE); if (bundle == null) { bundle = new Bundle(); } String match = matches.get(0); //mExtraResultsPendingIntentBundle.putString(SearchManager.QUERY, match); Intent intent = new Intent(); intent.putExtras(bundle); // This is for Google Maps, YouTube, ... intent.putExtra(SearchManager.QUERY, match); // This is for SwiftKey X, ... intent.putStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS, matches); String message = ""; if (matches.size() == 1) { message = match; } else { message = matches.toString(); } // Display a toast with the transcription. handler.sendMessage( createMessage(MSG_TOAST, String.format(getString(R.string.toastForwardedMatches), message))); try { mExtraResultsPendingIntent.send(this, Activity.RESULT_OK, intent); } catch (CanceledException e) { handler.sendMessage(createMessage(MSG_TOAST, e.getMessage())); } } finish(); }
From source file:com.chalmers.feedlr.service.DataService.java
/** * Populates application database ITEM table with the most recent tweets * from the user with the given userID within a specific feed. * //from w w w. j av a2 s.c om * This method is currently not in use. * * @param userID * the id for the user * @param feed * the feed that sent the request */ private void updateTweetsByUser(final String userID, final Feed feed) { runAsync(new Runnable() { @Override public void run() { long time = System.currentTimeMillis(); Intent intent = new Intent(); List<TwitterItem> userTweets = twitter.getUserTweets(userID); if (userTweets != null) { db.addListOfItems(userTweets); intent.setAction(FeedActivity.FEED_UPDATED); } else { intent.setAction(FeedActivity.FEED_PROBLEM_UPDATING); } // Broadcast update to activity Bundle b = new Bundle(); b.putString("feedTitle", feed.getTitle()); intent.putExtras(b); lbm.sendBroadcast(intent); Log.i(TwitterJSONParser.class.getName(), "Time in millis for complete Twitter user tweets request: " + (System.currentTimeMillis() - time)); } }); }
From source file:com.bonsai.wallet32.BaseWalletActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle presses on the action bar items Intent intent; switch (item.getItemId()) { case R.id.action_settings: intent = new Intent(this, SettingsActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(intent);/*from w w w .j av a 2s. c o m*/ return true; case R.id.action_view_seed: if (mApp.passcodeFreshlyEntered()) { intent = new Intent(this, ViewSeedActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); } else { intent = new Intent(this, PasscodeActivity.class); Bundle bundle = new Bundle(); bundle.putString("action", "viewseed"); intent.putExtras(bundle); } startActivity(intent); return true; case R.id.action_about: intent = new Intent(this, AboutActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(intent); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.github.barcodeeye.scan.CaptureActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.activity_capture); context2 = this; StringBuilder loginData = new StringBuilder(); try {/*www . j a v a 2s . co m*/ File f = new File(getCacheDir(), "LoginData.txt"); if (f.exists()) { BufferedReader br = new BufferedReader(new FileReader(f)); String line; while ((line = br.readLine()) != null) { loginData.append(line); } if (!loginData.toString().isEmpty()) { System.out.println("!!!!!!" + loginData.toString() + "!!!!!!!"); // Intent Creation and Initialization Intent intent = new Intent(context2, InformationPreviewActivity.class); //I have added the line: (flags) (for closing the first activity) intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // Create a Bundle and Put Bundle into it (SENDS PERSON) Bundle bundleObject = new Bundle(); bundleObject.putSerializable("key", loginData.toString()); // Put Bundle into Intent and call start Activity intent.putExtras(bundleObject); startActivity(intent); //I have added the line: (finish) (for closing the first activity) finish(); } } } catch (IOException e) { //You'll need to add proper error handling here } mImageManager = new ImageManager(this); mHasSurface = false; mInactivityTimer = new InactivityTimer(this); mBeepManager = new BeepManager(this); mAmbientLightManager = new AmbientLightManager(this); mViewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view); if (loginData.toString().isEmpty()) { Toast.makeText(getApplicationContext(), "Scan QR code for Login", Toast.LENGTH_LONG).show(); } PreferenceManager.setDefaultValues(this, R.xml.preferences, false); }
From source file:com.cesarsk.say_it.ui.fragments.SettingsFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); // Use an activity context to get the rewarded video instance. mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(getActivity()); mRewardedVideoAd.setRewardedVideoAdListener(this); loadRewardedVideoAd();// ww w .ja v a 2 s. c o m PackageInfo pInfo = null; try { pInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } String version = pInfo.versionName; final Preference app_version = getPreferenceManager().findPreference("app_version"); app_version.setSummary("Version: " + version + " (Click for Privacy Policy)"); final Context context = getActivity(); if (context instanceof Callback) { mCallback = (Callback) context; } else { throw new IllegalStateException("Owner must implement URLCallback interface"); } // add listeners for non-default actions Preference preference = findPreference(KEY_1); preference.setOnPreferenceClickListener(this); Preference open_source_licenses = findPreference(KEY_2); open_source_licenses.setOnPreferenceClickListener(this); Preference rate_us = getPreferenceManager().findPreference("rate_us"); rate_us.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { rateUs(getActivity()); return false; } }); Preference contact_us = getPreferenceManager().findPreference("contact_us"); contact_us.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { shareToMail(emails, "[CONTACT US - SAY IT!]", getActivity()); return false; } }); Preference bug_report = getPreferenceManager().findPreference("bug_report"); bug_report.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { shareToMail(emails, "[CONTACT US - SAY IT!]", getActivity()); return false; } }); Preference donate_ad = getPreferenceManager().findPreference("donation_ad"); donate_ad.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { //Launch AD if (mRewardedVideoAd.isLoaded()) { mRewardedVideoAd.show(); } return false; } }); final Preference about_us = getPreferenceManager().findPreference("about_us"); about_us.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Utility.openURL(getActivity(), "https://lucacesaranoblog.wordpress.com/2017/07/18/about-us/"); return false; } }); final Preference eula = getPreferenceManager().findPreference("eula"); eula.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Utility.openURL(getActivity(), "https://lucacesaranoblog.wordpress.com/2017/04/28/say-it-eula-agreement/"); return false; } }); /*final Preference github = getPreferenceManager().findPreference("github"); github.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Utility.openURL(getActivity(), "https://github.com/Cesarsk/Say_it"); return false; } });*/ final Preference other_apps = getPreferenceManager().findPreference("other_apps"); other_apps.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Utility.openURL(getActivity(), "https://play.google.com/store/apps/developer?id=Cesarsk+Dev+Team"); return false; } }); final Preference voice_settings = getPreferenceManager().findPreference("tts_settings"); voice_settings.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Intent intent = new Intent(); intent.setAction("com.android.settings.TTS_SETTINGS"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); return false; } }); // compute your public key and store it in base64EncodedPublicKey mHelper = new IabHelper(getActivity(), LCSecurity.base64EncodedPublicKey); mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { public void onIabSetupFinished(IabResult result) { if (!result.isSuccess()) { // Oh no, there was a problem. if (MainActivity.isLoggingEnabled) Log.d("Say It!", "Problem setting up In-app Billing: " + result); } // Hooray, IAB is fully set up! if (MainActivity.isLoggingEnabled) Log.d("Say It!", "Hooray. IAB is fully set up!" + result); } }); mIabPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() { @Override public void onIabPurchaseFinished(IabResult result, Purchase info) { if (result.isFailure()) { Toast.makeText(getActivity(), "Purchase Failed! Perhaps have you already purchased the item?", Toast.LENGTH_SHORT).show(); } else if (info.getSku().equals(PlayActivity.no_ads_in_app)) { UtilitySharedPrefs.loadAdsStatus(getActivity()); UtilitySharedPrefs.savePrefs(getActivity(), true, MainActivity.NO_ADS_STATUS_KEY); } } }; mQueryFinishedListener = new IabHelper.QueryInventoryFinishedListener() { public void onQueryInventoryFinished(IabResult result, Inventory inventory) { if (result.isFailure()) { if (MainActivity.isLoggingEnabled) Toast.makeText(getActivity(), "Query Failed!", Toast.LENGTH_SHORT).show(); return; } //Open Purchase Dialog try { mHelper.flagEndAsync(); mHelper.launchPurchaseFlow(getActivity(), PlayActivity.no_ads_in_app, 64000, mIabPurchaseFinishedListener); } catch (IabHelper.IabAsyncInProgressException e) { e.printStackTrace(); } } }; final Preference remove_ads = getPreferenceManager().findPreference("remove_ads"); if (MainActivity.NO_ADS) { remove_ads.setEnabled(false); remove_ads.setSummary("Thank you for supporting us ?"); } else { remove_ads.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { //helper to remove ads List<String> additionalSkuList = new ArrayList<>(); additionalSkuList.add(PlayActivity.no_ads_in_app); try { mHelper.flagEndAsync(); mHelper.queryInventoryAsync(true, additionalSkuList, mQueryFinishedListener); } catch (IabHelper.IabAsyncInProgressException e) { e.printStackTrace(); } return false; } }); } final Preference reset_tutorial = getPreferenceManager().findPreference("reset_showcase"); reset_tutorial.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Random rand = new Random(); int randomNum = rand.nextInt((10000 - 10) + 1) + 10; //(max - min) + 1 + min MainActivity.id_showcase_playactivity = "" + randomNum; Toast.makeText(getActivity(), "Tutorial has been reset", Toast.LENGTH_SHORT).show(); //MainActivity.id_showcase_fragments = "" + randomNum2; //int randomNum2 = rand.nextInt((10000 - 10) + 1) + 10; //(max - min) + 1 + min //These two statements are commented because MaterialShowCase often crashes on fragments and while pressing the back button. return false; } }); //setting an own Alert Dialog's title color final Spannable title = new SpannableString("Delete Recordings"); title.setSpan(new ForegroundColorSpan(Color.DKGRAY), 0, title.length(), 0); final Spannable message = new SpannableString("Are you sure you want to delete all recordings?"); message.setSpan(new ForegroundColorSpan(Color.GRAY), 0, message.length(), 0); final Preference delete_recordings = getPreferenceManager().findPreference("delete_recordings"); delete_recordings.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { new AlertDialog.Builder(getActivity()).setTitle(title).setMessage(message) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Utility.delete_recordings(getActivity()); Toast.makeText(getActivity(), "Recordings deleted!", Toast.LENGTH_SHORT).show(); } }).setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { //do nothing } }).show(); return true; } }); final ListPreference button_vibration = (ListPreference) getPreferenceManager() .findPreference("button_vibration"); button_vibration.setSummary(button_vibration.getEntry()); final Spannable default_vibration_settings_title = new SpannableString("Vibration Settings"); default_vibration_settings_title.setSpan(new ForegroundColorSpan(Color.DKGRAY), 0, default_vibration_settings_title.length(), 0); button_vibration.setDialogTitle(default_vibration_settings_title); button_vibration.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { String new_value = newValue.toString(); index_default_vibration = button_vibration.findIndexOfValue(new_value); CharSequence[] entries = button_vibration.getEntries(); UtilitySharedPrefs.savePrefs(getActivity(), new_value, MainActivity.DEFAULT_VIBRATION_KEY); button_vibration .setSummary(button_vibration.getEntries()[button_vibration.findIndexOfValue(new_value)]); Toast.makeText(getActivity(), String.valueOf(entries[index_default_vibration]), Toast.LENGTH_SHORT) .show(); UtilitySharedPrefs.loadSettingsPrefs(context); return true; } }); final ListPreference default_accent = (ListPreference) getPreferenceManager() .findPreference("default_accent"); default_accent.setSummary(default_accent.getEntry()); final Spannable default_accent_title = new SpannableString("Default Accent"); default_accent_title.setSpan(new ForegroundColorSpan(Color.DKGRAY), 0, default_accent_title.length(), 0); default_accent.setDialogTitle(default_accent_title); default_accent.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { String new_value = newValue.toString(); index_default_accent = default_accent.findIndexOfValue(new_value); CharSequence[] entries = default_accent.getEntries(); UtilitySharedPrefs.savePrefs(getActivity(), new_value, MainActivity.DEFAULT_ACCENT_KEY); default_accent.setSummary(default_accent.getEntries()[default_accent.findIndexOfValue(new_value)]); //Toast.makeText(getActivity(), String.valueOf(entries[index_default_accent]), Toast.LENGTH_SHORT).show(); UtilitySharedPrefs.loadSettingsPrefs(context); return true; } }); final ListPreference theme_selector = (ListPreference) getPreferenceManager() .findPreference("theme_selector"); final Spannable theme_selector_title = new SpannableString("Theme"); theme_selector_title.setSpan(new ForegroundColorSpan(Color.DKGRAY), 0, theme_selector_title.length(), 0); theme_selector.setDialogTitle(theme_selector_title); theme_selector.setSummary(theme_selector.getEntry()); theme_selector.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { String new_value = newValue.toString(); index_default_theme = theme_selector.findIndexOfValue(new_value); CharSequence[] entries = theme_selector.getEntries(); UtilitySharedPrefs.savePrefs(getActivity(), new_value, MainActivity.DEFAULT_THEME_KEY); theme_selector.setSummary(theme_selector.getEntries()[theme_selector.findIndexOfValue(new_value)]); //Toast.makeText(getActivity(), String.valueOf(entries[index_default_theme]), Toast.LENGTH_SHORT).show(); UtilitySharedPrefs.loadSettingsPrefs(context); Toast.makeText(getActivity(), "Done! Reboot to see changes.", Toast.LENGTH_SHORT).show(); return true; } }); Preference acknowledgements = getPreferenceManager().findPreference("acknowledgements"); acknowledgements.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { final Intent preference_intent = new Intent(getActivity(), FileTextActivity.class); Bundle args = new Bundle(); args.putString(FileTextActivity.PREFERENCE, "acknowledgements"); preference_intent.putExtras(args); startActivity(preference_intent, ActivityOptions.makeSceneTransitionAnimation(getActivity()).toBundle()); return false; } }); app_version.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Utility.openURL(getActivity(), "https://lucacesaranoblog.wordpress.com/2017/04/18/privacy-policy/"); return false; } }); }
From source file:com.example.app_2.activities.ImageGridActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Pass the event to ActionBarDrawerToggle, if it returns // true, then it has handled the app icon touch event if (!mDualPane) if (mDrawerToggle.onOptionsItemSelected(item)) { return true; }//from w w w. j a v a2s . c o m // Handle presses on the action bar items switch (item.getItemId()) { case R.id.action_add_image:// TODO dodawanie nowych obrazkw Intent bind_intent = new Intent(this, BindImagesToCategoryActivity.class); if (actual_category_fk.getCategoryId() == Database.getMainRootFk()) { Toast.makeText(getApplicationContext(), "Tutaj nie mona dodawa obrazkw, wybierz najpierw uytkownika", Toast.LENGTH_LONG).show(); return true; } bind_intent.putExtra("executing_category_id", actual_category_fk.getCategoryId()); startActivity(bind_intent); return true; case R.id.action_add_new_image: Intent new_imageIntent = new Intent(this, AddImageActivity.class); Bundle bundle = new Bundle(); bundle.putLong("cat_fk", actual_category_fk.getCategoryId()); new_imageIntent.putExtras(bundle); startActivity(new_imageIntent); return true; case R.id.action_settings: Intent intent = new Intent(this, SettingsActivity.class); startActivity(intent); overridePendingTransition(R.anim.right_slide_in, R.anim.right_slide_out); finish(); return true; case R.id.action_logout: igf.mEditMode = true; SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext()); SharedPreferences sharedPref = getApplicationContext().getSharedPreferences("USER", Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPref.edit(); //zapisanie usawie uytkownika do bazy Uri uri = Uri.parse(UserContract.CONTENT_URI + "/" + sharedPref.getLong("logged_user_id", 0)); ContentValues cv = new ContentValues(); cv.put(UserContract.Columns.FONT_SIZE, sp.getInt("pref_img_desc_font_size", 15)); cv.put(UserContract.Columns.IMG_SIZE, sp.getInt("pref_img_size", 100)); cv.put(UserContract.Columns.CAT_BACKGROUND, String.valueOf(sp.getInt("category_view_background", 0xff33b5e5))); cv.put(UserContract.Columns.CONTEXT_CAT_BACKGROUND, String.valueOf(sp.getInt("context_category_view_background", 0xffe446ff))); getContentResolver().update(uri, cv, null, null); editor.putLong("logged_user_root", Database.getMainRootFk()); editor.putLong("logged_user_id", 0); editor.commit(); fragmentsHistory.clear(); Intent i = getIntent(); finish(); startActivity(i); replaceCategory(Database.getMainRootFk(), 0, false); return true; case R.id.action_login_user: Intent login_intent = new Intent(this, UserLoginActivity.class); startActivity(login_intent); finish(); fragmentsHistory.clear(); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.android.contacts.ContactSaveService.java
public static Intent createUndoIntent(Context context, Intent resultIntent) { final Intent serviceIntent = new Intent(context, ContactSaveService.class); serviceIntent.setAction(ContactSaveService.ACTION_UNDO); serviceIntent.putExtras(resultIntent); return serviceIntent; }