List of usage examples for android.content Intent resolveActivity
public ComponentName resolveActivity(@NonNull PackageManager pm)
From source file:de.earthlingz.oerszebra.DroidZebra.java
private void sendMail() { //GetNowTime// ww w. ja v a 2s . c o m Calendar calendar = Calendar.getInstance(); Date nowTime = calendar.getTime(); StringBuilder sbBlackPlayer = new StringBuilder(); StringBuilder sbWhitePlayer = new StringBuilder(); ZebraBoard gs = mZebraThread.getGameState(); SharedPreferences settings = getSharedPreferences(SHARED_PREFS_NAME, 0); byte[] moves = null; if (gs != null) { moves = gs.getMoveSequence(); } Intent intent = new Intent(); Intent chooser = Intent.createChooser(intent, ""); intent.setAction(Intent.ACTION_SEND); intent.setType("message/rfc822"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { settings.getString(SETTINGS_KEY_SENDMAIL, DEFAULT_SETTING_SENDMAIL) }); intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.app_name)); //get BlackPlayer and WhitePlayer switch (settingsProvider.getSettingFunction()) { case FUNCTION_HUMAN_VS_HUMAN: sbBlackPlayer.append("Player"); sbWhitePlayer.append("Player"); break; case FUNCTION_ZEBRA_BLACK: sbBlackPlayer.append("DroidZebra-"); sbBlackPlayer.append(settingsProvider.getSettingZebraDepth()); sbBlackPlayer.append("/"); sbBlackPlayer.append(settingsProvider.getSettingZebraDepthExact()); sbBlackPlayer.append("/"); sbBlackPlayer.append(settingsProvider.getSettingZebraDepthWLD()); sbWhitePlayer.append("Player"); break; case FUNCTION_ZEBRA_WHITE: sbBlackPlayer.append("Player"); sbWhitePlayer.append("DroidZebra-"); sbWhitePlayer.append(settingsProvider.getSettingZebraDepth()); sbWhitePlayer.append("/"); sbWhitePlayer.append(settingsProvider.getSettingZebraDepthExact()); sbWhitePlayer.append("/"); sbWhitePlayer.append(settingsProvider.getSettingZebraDepthWLD()); break; case FUNCTION_ZEBRA_VS_ZEBRA: sbBlackPlayer.append("DroidZebra-"); sbBlackPlayer.append(settingsProvider.getSettingZebraDepth()); sbBlackPlayer.append("/"); sbBlackPlayer.append(settingsProvider.getSettingZebraDepthExact()); sbBlackPlayer.append("/"); sbBlackPlayer.append(settingsProvider.getSettingZebraDepthWLD()); sbWhitePlayer.append("DroidZebra-"); sbWhitePlayer.append(settingsProvider.getSettingZebraDepth()); sbWhitePlayer.append("/"); sbWhitePlayer.append(settingsProvider.getSettingZebraDepthExact()); sbWhitePlayer.append("/"); sbWhitePlayer.append(settingsProvider.getSettingZebraDepthWLD()); default: } StringBuilder sb = new StringBuilder(); sb.append(getResources().getString(R.string.mail_generated)); sb.append("\r\n"); sb.append(getResources().getString(R.string.mail_date)); sb.append(" "); sb.append(nowTime); sb.append("\r\n\r\n"); sb.append(getResources().getString(R.string.mail_move)); sb.append(" "); StringBuilder sbMoves = new StringBuilder(); if (moves != null) { for (byte move1 : moves) { if (move1 != 0x00) { Move move = new Move(move1); sbMoves.append(move.getText()); if (Objects.equal(getState().getLastMove(), move)) { break; } } } } sb.append(sbMoves); sb.append("\r\n\r\n"); sb.append(sbBlackPlayer.toString()); sb.append(" (B) "); sb.append(getState().getBlackScore()); sb.append(":"); sb.append(getState().getWhiteScore()); sb.append(" (W) "); sb.append(sbWhitePlayer.toString()); intent.putExtra(Intent.EXTRA_TEXT, sb.toString()); // Intent // Verify the original intent will resolve to at least one activity if (intent.resolveActivity(getPackageManager()) != null) { startActivity(chooser); } }
From source file:com.android.soma.Launcher.java
protected boolean updateVoiceSearchIcon(boolean searchVisible) { final View voiceButtonContainer = findViewById(R.id.voice_button_container); final View voiceButton = findViewById(R.id.voice_button); // We only show/update the voice search icon if the search icon is enabled as well final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); ComponentName globalSearchActivity = searchManager.getGlobalSearchActivity(); ComponentName activityName = null;// w ww .j a va2 s . com if (globalSearchActivity != null) { // Check if the global search activity handles voice search Intent intent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH); intent.setPackage(globalSearchActivity.getPackageName()); activityName = intent.resolveActivity(getPackageManager()); } if (activityName == null) { // Fallback: check if an activity other than the global search activity // resolves this Intent intent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH); activityName = intent.resolveActivity(getPackageManager()); } if (searchVisible && activityName != null) { int coi = getCurrentOrientationIndexForGlobalIcons(); sVoiceSearchIcon[coi] = updateButtonWithIconFromExternalActivity(R.id.voice_button, activityName, R.drawable.ic_home_voice_search_holo, TOOLBAR_VOICE_SEARCH_ICON_METADATA_NAME); if (sVoiceSearchIcon[coi] == null) { sVoiceSearchIcon[coi] = updateButtonWithIconFromExternalActivity(R.id.voice_button, activityName, R.drawable.ic_home_voice_search_holo, TOOLBAR_ICON_METADATA_NAME); } if (voiceButtonContainer != null) voiceButtonContainer.setVisibility(View.VISIBLE); voiceButton.setVisibility(View.VISIBLE); updateVoiceButtonProxyVisible(false); invalidatePressedFocusedStates(voiceButtonContainer, voiceButton); return true; } else { if (voiceButtonContainer != null) voiceButtonContainer.setVisibility(View.GONE); if (voiceButton != null) voiceButton.setVisibility(View.GONE); updateVoiceButtonProxyVisible(false); return false; } }
From source file:com.android.soma.Launcher.java
/** * Sets the app market icon/*from w w w. j av a2 s .c o m*/ */ private void updateAppMarketIcon() { if (!DISABLE_MARKET_BUTTON) { final View marketButton = findViewById(R.id.market_button); Intent intent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_APP_MARKET); // Find the app market activity by resolving an intent. // (If multiple app markets are installed, it will return the ResolverActivity.) ComponentName activityName = intent.resolveActivity(getPackageManager()); if (activityName != null) { int coi = getCurrentOrientationIndexForGlobalIcons(); mAppMarketIntent = intent; sAppMarketIcon[coi] = updateTextButtonWithIconFromExternalActivity(R.id.market_button, activityName, R.drawable.ic_launcher_market_holo, TOOLBAR_ICON_METADATA_NAME); marketButton.setVisibility(View.VISIBLE); } else { // We should hide and disable the view so that we don't try and restore the visibility // of it when we swap between drag & normal states from IconDropTarget subclasses. marketButton.setVisibility(View.GONE); marketButton.setEnabled(false); } } }
From source file:org.de.jmg.learn.MainActivity.java
@SuppressLint("InlinedApi") public void SaveVokAs(boolean blnUniCode, boolean blnNew) throws Exception { boolean blnActionCreateDocument = false; try {// w w w . ja v a 2 s . c om if (fPA.fragMain != null && fPA.fragMain.mainView != null) fPA.fragMain.EndEdit(false); if (!libString.IsNullOrEmpty(vok.getFileName()) || vok.getURI() == null || Build.VERSION.SDK_INT < 19) { boolean blnSuccess; for (int i = 0; i < 2; i++) { try { String key = "AlwaysStartExternalProgram"; int AlwaysStartExternalProgram = prefs.getInt(key, 999); lib.YesNoCheckResult res; if (AlwaysStartExternalProgram == 999 && !(vok.getURI() != null && i == 1)) { res = lib.ShowMessageYesNoWithCheckbox(this, "", getString(R.string.msgStartExternalProgram), getString(R.string.msgRememberChoice), false); if (res != null) { if (res.res == yesnoundefined.undefined) return; if (res.checked) prefs.edit().putInt(key, res.res == yesnoundefined.yes ? -1 : 0).commit(); } else { yesnoundefined par = yesnoundefined.undefined; res = new lib.YesNoCheckResult(par, true); } } else { yesnoundefined par = yesnoundefined.undefined; if (AlwaysStartExternalProgram == -1) par = yesnoundefined.yes; if (AlwaysStartExternalProgram == 0) par = yesnoundefined.no; res = new lib.YesNoCheckResult(par, true); } if ((vok.getURI() != null && i == 1) || res.res == yesnoundefined.no) { Intent intent = new Intent(this, AdvFileChooser.class); ArrayList<String> extensions = new ArrayList<>(); extensions.add(".k??"); extensions.add(".v??"); extensions.add(".K??"); extensions.add(".V??"); extensions.add(".KAR"); extensions.add(".VOK"); extensions.add(".kar"); extensions.add(".vok"); extensions.add(".dic"); extensions.add(".DIC"); if (libString.IsNullOrEmpty(vok.getFileName())) { if (vok.getURI() != null) { intent.setData(vok.getURI()); } } else { File F = new File(vok.getFileName()); Uri uri = Uri.fromFile(F); intent.setData(uri); } intent.putExtra("URIName", vok.getURIName()); intent.putStringArrayListExtra("filterFileExtension", extensions); intent.putExtra("blnUniCode", blnUniCode); intent.putExtra("DefaultDir", new File(JMGDataDirectory).exists() ? JMGDataDirectory : Environment.getExternalStorageDirectory().getPath()); intent.putExtra("selectFolder", false); intent.putExtra("blnNew", blnNew); if (_blnUniCode) _oldUniCode = yesnoundefined.yes; else _oldUniCode = yesnoundefined.no; _blnUniCode = blnUniCode; this.startActivityForResult(intent, FILE_CHOOSERADV); blnSuccess = true; } else if (Build.VERSION.SDK_INT < 19) { //org.openintents.filemanager Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setData(vok.getURI()); intent.putExtra("org.openintents.extra.WRITEABLE_ONLY", true); intent.putExtra("org.openintents.extra.TITLE", getString(R.string.SaveAs)); intent.putExtra("org.openintents.extra.BUTTON_TEXT", getString(R.string.btnSave)); intent.setType("*/*"); Intent chooser = Intent.createChooser(intent, getString(R.string.SaveAs)); if (intent.resolveActivity(context.getPackageManager()) != null) { startActivityForResult(chooser, FILE_OPENINTENT); blnSuccess = true; } else { lib.ShowToast(this, getString(R.string.InstallFilemanager)); intent.setData(null); intent.removeExtra("org.openintents.extra.WRITEABLE_ONLY"); intent.removeExtra("org.openintents.extra.TITLE"); intent.removeExtra("org.openintents.extra.BUTTON_TEXT"); startActivityForResult(chooser, FILE_OPENINTENT); blnSuccess = true; } } else { blnActionCreateDocument = true; blnSuccess = true; } } catch (Exception ex) { blnSuccess = false; Log.e("SaveAs", ex.getMessage(), ex); if (i == 1) { lib.ShowException(this, ex); } } if (blnSuccess) break; } } else if (Build.VERSION.SDK_INT >= 19) { blnActionCreateDocument = true; } if (blnActionCreateDocument) { /** * Open a file for writing and append some text to it. */ // ACTION_OPEN_DOCUMENT is the intent to choose a file via the system's // file browser. Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT); // Create a file with the requested MIME type. String defaultURI = prefs.getString("defaultURI", ""); if (!libString.IsNullOrEmpty(defaultURI)) { String FName = ""; if (vok.getURI() != null) { String path2 = lib.dumpUriMetaData(this, vok.getURI()); if (path2.contains(":")) path2 = path2.split(":")[0]; FName = path2.substring(path2.lastIndexOf("/") + 1); } else if (!libString.IsNullOrEmpty(vok.getFileName())) { FName = new File(vok.getFileName()).getName(); } intent.putExtra(Intent.EXTRA_TITLE, FName); //defaultURI = (!defaultURI.endsWith("/")?defaultURI.substring(0,defaultURI.lastIndexOf("/")+1):defaultURI); Uri def = Uri.parse(defaultURI); intent.setData(def); } else { Log.d("empty", "empty"); //intent.setType("file/*"); } // Filter to only show results that can be "opened", such as a // file (as opposed to a list of contacts or timezones). intent.addCategory(Intent.CATEGORY_OPENABLE); // Filter to show only text files. intent.setType("*/*"); startActivityForResult(intent, EDIT_REQUEST_CODE); } } catch (Exception ex) { libLearn.gStatus = "SaveVokAs"; lib.ShowException(this, ex); } }
From source file:eu.basicairdata.graziano.gpslogger.FragmentTracklist.java
@Subscribe public void onEvent(EventBusMSGNormal msg) { if (msg.MSGType == EventBusMSG.TRACKLIST_SELECTION) { final long selID = msg.id; if (selID >= 0) { getActivity().runOnUiThread(new Runnable() { @Override/* w w w . j av a 2 s . c o m*/ public void run() { selectedtrackID = selID; registerForContextMenu(view); getActivity().openContextMenu(view); unregisterForContextMenu(view); } }); } } if (msg.MSGType == EventBusMSG.INTENT_SEND) { final long trackid = msg.id; if (trackid > 0) { Track track = GPSApplication.getInstance().GPSDataBase.getTrack(trackid); Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND_MULTIPLE); //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(Intent.EXTRA_SUBJECT, "GPS Logger - Track " + track.getName()); PhysicalDataFormatter phdformatter = new PhysicalDataFormatter(); PhysicalData phdDuration; PhysicalData phdSpeedMax; PhysicalData phdSpeedAvg; PhysicalData phdDistance; PhysicalData phdAltitudeGap; PhysicalData phdOverallDirection; phdDuration = phdformatter.format(track.getPrefTime(), PhysicalDataFormatter.FORMAT_DURATION); phdSpeedMax = phdformatter.format(track.getSpeedMax(), PhysicalDataFormatter.FORMAT_SPEED); phdSpeedAvg = phdformatter.format(track.getPrefSpeedAverage(), PhysicalDataFormatter.FORMAT_SPEED_AVG); phdDistance = phdformatter.format(track.getEstimatedDistance(), PhysicalDataFormatter.FORMAT_DISTANCE); phdAltitudeGap = phdformatter.format( track.getEstimatedAltitudeGap( GPSApplication.getInstance().getPrefEGM96AltitudeCorrection()), PhysicalDataFormatter.FORMAT_ALTITUDE); phdOverallDirection = phdformatter.format(track.getBearing(), PhysicalDataFormatter.FORMAT_BEARING); if (track.getNumberOfLocations() <= 1) { intent.putExtra(Intent.EXTRA_TEXT, (CharSequence) ("GPS Logger - Track " + track.getName() + "\n" + track.getNumberOfLocations() + " " + getString(R.string.trackpoints) + "\n" + track.getNumberOfPlacemarks() + " " + getString(R.string.placemarks))); } else { intent.putExtra(Intent.EXTRA_TEXT, (CharSequence) ("GPS Logger - Track " + track.getName() + "\n" + track.getNumberOfLocations() + " " + getString(R.string.trackpoints) + "\n" + track.getNumberOfPlacemarks() + " " + getString(R.string.placemarks) + "\n" + "\n" + getString(R.string.pref_track_stats) + " " + (GPSApplication.getInstance().getPrefShowTrackStatsType() == 0 ? getString(R.string.pref_track_stats_totaltime) : getString(R.string.pref_track_stats_movingtime)) + ":" + "\n" + getString(R.string.distance) + " = " + phdDistance.Value + " " + phdDistance.UM + "\n" + getString(R.string.duration) + " = " + phdDuration.Value + "\n" + getString(R.string.altitude_gap) + " = " + phdAltitudeGap.Value + " " + phdAltitudeGap.UM + "\n" + getString(R.string.max_speed) + " = " + phdSpeedMax.Value + " " + phdSpeedMax.UM + "\n" + getString(R.string.average_speed) + " = " + phdSpeedAvg.Value + " " + phdSpeedAvg.UM + "\n" + getString(R.string.overall_direction) + " = " + phdOverallDirection.Value + " " + phdOverallDirection.UM)); } intent.setType("text/xml"); ArrayList<Uri> files = new ArrayList<>(); String fname = track.getName() + ".kml"; File file = new File(Environment.getExternalStorageDirectory() + "/GPSLogger/AppData/", fname); if (file.exists() && GPSApplication.getInstance().getPrefExportKML()) { Uri uri = Uri.fromFile(file); files.add(uri); } fname = track.getName() + ".gpx"; file = new File(Environment.getExternalStorageDirectory() + "/GPSLogger/AppData/", fname); if (file.exists() && GPSApplication.getInstance().getPrefExportGPX()) { Uri uri = Uri.fromFile(file); files.add(uri); } fname = track.getName() + ".txt"; file = new File(Environment.getExternalStorageDirectory() + "/GPSLogger/AppData/", fname); if (file.exists() && GPSApplication.getInstance().getPrefExportTXT()) { Uri uri = Uri.fromFile(file); files.add(uri); } intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, files); String title = getString(R.string.card_menu_share); // Create intent to show chooser Intent chooser = Intent.createChooser(intent, title); // Verify the intent will resolve to at least one activity if ((intent.resolveActivity(getContext().getPackageManager()) != null) && (!files.isEmpty())) { startActivity(chooser); } } } }
From source file:android.app.Activity.java
/** * Navigate from this activity to the activity specified by upIntent, finishing this activity * in the process. If the activity indicated by upIntent already exists in the task's history, * this activity and all others before the indicated activity in the history stack will be * finished./*w w w . j a va 2 s.com*/ * * <p>If the indicated activity does not appear in the history stack, this will finish * each activity in this task until the root activity of the task is reached, resulting in * an "in-app home" behavior. This can be useful in apps with a complex navigation hierarchy * when an activity may be reached by a path not passing through a canonical parent * activity.</p> * * <p>This method should be used when performing up navigation from within the same task * as the destination. If up navigation should cross tasks in some cases, see * {@link #shouldUpRecreateTask(Intent)}.</p> * * @param upIntent An intent representing the target destination for up navigation * * @return true if up navigation successfully reached the activity indicated by upIntent and * upIntent was delivered to it. false if an instance of the indicated activity could * not be found and this activity was simply finished normally. */ public boolean navigateUpTo(Intent upIntent) { if (mParent == null) { ComponentName destInfo = upIntent.getComponent(); if (destInfo == null) { destInfo = upIntent.resolveActivity(getPackageManager()); if (destInfo == null) { return false; } upIntent = new Intent(upIntent); upIntent.setComponent(destInfo); } int resultCode; Intent resultData; synchronized (this) { resultCode = mResultCode; resultData = mResultData; } if (resultData != null) { resultData.prepareToLeaveProcess(); } try { upIntent.prepareToLeaveProcess(); return ActivityManagerNative.getDefault().navigateUpTo(mToken, upIntent, resultCode, resultData); } catch (RemoteException e) { return false; } } else { return mParent.navigateUpToFromChild(this, upIntent); } }
From source file:android.app.Activity.java
/** * Returns true if the app should recreate the task when navigating 'up' from this activity * by using targetIntent./*from w w w . ja v a 2 s . co m*/ * * <p>If this method returns false the app can trivially call * {@link #navigateUpTo(Intent)} using the same parameters to correctly perform * up navigation. If this method returns false, the app should synthesize a new task stack * by using {@link TaskStackBuilder} or another similar mechanism to perform up navigation.</p> * * @param targetIntent An intent representing the target destination for up navigation * @return true if navigating up should recreate a new task stack, false if the same task * should be used for the destination */ public boolean shouldUpRecreateTask(Intent targetIntent) { try { PackageManager pm = getPackageManager(); ComponentName cn = targetIntent.getComponent(); if (cn == null) { cn = targetIntent.resolveActivity(pm); } ActivityInfo info = pm.getActivityInfo(cn, 0); if (info.taskAffinity == null) { return false; } return !ActivityManagerNative.getDefault().targetTaskAffinityMatchesActivity(mToken, info.taskAffinity); } catch (RemoteException e) { return false; } catch (NameNotFoundException e) { return false; } }
From source file:org.mariotaku.twidere.fragment.UserFragment.java
@Override public boolean onOptionsItemSelected(final MenuItem item) { final Context context = getContext(); final AsyncTwitterWrapper twitter = mTwitterWrapper; final ParcelableUser user = getUser(); final UserRelationship userRelationship = mRelationship; if (user == null || twitter == null) return false; switch (item.getItemId()) { case R.id.block: { if (userRelationship == null) return true; if (userRelationship.blocking) { twitter.destroyBlockAsync(user.account_key, user.key); } else {/*from w w w. j a va 2 s . c o m*/ CreateUserBlockDialogFragment.show(getFragmentManager(), user); } break; } case R.id.report_spam: { ReportSpamDialogFragment.show(getFragmentManager(), user); break; } case R.id.add_to_filter: { if (userRelationship == null) return true; final ContentResolver cr = getContentResolver(); if (userRelationship.filtering) { final String where = Expression.equalsArgs(Filters.Users.USER_KEY).getSQL(); final String[] whereArgs = { user.key.toString() }; cr.delete(Filters.Users.CONTENT_URI, where, whereArgs); Utils.showInfoMessage(getActivity(), R.string.message_user_unmuted, false); } else { cr.insert(Filters.Users.CONTENT_URI, ContentValuesCreator.createFilteredUser(user)); Utils.showInfoMessage(getActivity(), R.string.message_user_muted, false); } getFriendship(); break; } case R.id.mute_user: { if (userRelationship == null) return true; if (userRelationship.muting) { twitter.destroyMuteAsync(user.account_key, user.key); } else { CreateUserMuteDialogFragment.show(getFragmentManager(), user); } break; } case R.id.mention: { final Intent intent = new Intent(INTENT_ACTION_MENTION); final Bundle bundle = new Bundle(); bundle.putParcelable(EXTRA_USER, user); intent.putExtras(bundle); startActivity(intent); break; } case R.id.send_direct_message: { final Uri.Builder builder = new Uri.Builder(); builder.scheme(SCHEME_TWIDERE); builder.authority(AUTHORITY_DIRECT_MESSAGES_CONVERSATION); builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_KEY, user.account_key.toString()); builder.appendQueryParameter(QUERY_PARAM_USER_KEY, user.key.toString()); final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build()); intent.putExtra(EXTRA_ACCOUNT, ParcelableCredentialsUtils.getCredentials(getActivity(), user.account_key)); intent.putExtra(EXTRA_USER, user); startActivity(intent); break; } case R.id.set_color: { final Intent intent = new Intent(getActivity(), ColorPickerDialogActivity.class); intent.putExtra(EXTRA_COLOR, mUserColorNameManager.getUserColor(user.key)); intent.putExtra(EXTRA_ALPHA_SLIDER, false); intent.putExtra(EXTRA_CLEAR_BUTTON, true); startActivityForResult(intent, REQUEST_SET_COLOR); break; } case R.id.clear_nickname: { mUserColorNameManager.clearUserNickname(user.key); break; } case R.id.set_nickname: { final String nick = mUserColorNameManager.getUserNickname(user.key); SetUserNicknameDialogFragment.show(getFragmentManager(), user.key, nick); break; } case R.id.add_to_list: { final Intent intent = new Intent(INTENT_ACTION_SELECT_USER_LIST); intent.setClass(getActivity(), UserListSelectorActivity.class); intent.putExtra(EXTRA_ACCOUNT_KEY, user.account_key); intent.putExtra(EXTRA_SCREEN_NAME, DataStoreUtils.getAccountScreenName(getActivity(), user.account_key)); startActivityForResult(intent, REQUEST_ADD_TO_LIST); break; } case R.id.open_with_account: { final Intent intent = new Intent(INTENT_ACTION_SELECT_ACCOUNT); intent.setClass(getActivity(), AccountSelectorActivity.class); intent.putExtra(EXTRA_SINGLE_SELECTION, true); intent.putExtra(EXTRA_ACCOUNT_HOST, user.key.getHost()); startActivityForResult(intent, REQUEST_SELECT_ACCOUNT); break; } case R.id.follow: { if (userRelationship == null) return true; final boolean updatingRelationship = twitter.isUpdatingRelationship(user.account_key, user.key); if (!updatingRelationship) { if (userRelationship.following) { DestroyFriendshipDialogFragment.show(getFragmentManager(), user); } else { twitter.createFriendshipAsync(user.account_key, user.key); } } return true; } case R.id.enable_retweets: { final boolean newState = !item.isChecked(); final FriendshipUpdate update = new FriendshipUpdate(); update.retweets(newState); twitter.updateFriendship(user.account_key, user.key.getId(), update); item.setChecked(newState); return true; } case R.id.muted_users: { IntentUtils.openMutesUsers(getActivity(), user.account_key); return true; } case R.id.blocked_users: { IntentUtils.openUserBlocks(getActivity(), user.account_key); return true; } case R.id.incoming_friendships: { IntentUtils.openIncomingFriendships(getActivity(), user.account_key); return true; } case R.id.user_mentions: { IntentUtils.openUserMentions(context, user.account_key, user.screen_name); return true; } case R.id.saved_searches: { IntentUtils.openSavedSearches(context, user.account_key); return true; } case R.id.scheduled_statuses: { IntentUtils.openScheduledStatuses(context, user.account_key); return true; } case R.id.open_in_browser: { final Uri uri = LinkCreator.getUserWebLink(user); final Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.addCategory(Intent.CATEGORY_BROWSABLE); intent.setPackage(IntentUtils.getDefaultBrowserPackage(context, uri, true)); if (intent.resolveActivity(context.getPackageManager()) != null) { startActivity(intent); } return true; } default: { final Intent intent = item.getIntent(); if (intent != null && intent.resolveActivity(context.getPackageManager()) != null) { startActivity(intent); } break; } } return true; }