List of usage examples for android.content Intent hasExtra
public boolean hasExtra(String name)
From source file:com.tct.mail.ui.AbstractActivityController.java
/** * Handle an intent to open the app. This method is called only when there is no saved state, * so we need to set state that wasn't set before. It is correct to change the viewmode here * since it has not been previously set. * * This method is called for a subset of the reasons mentioned in * {@link #onCreate(android.os.Bundle)}. Notably, this is called when launching the app from * notifications, widgets, and shortcuts. * @param intent intent passed to the activity. *//* w ww.jav a 2 s . c o m*/ private void handleIntent(Intent intent) { LogUtils.d(LOG_TAG, "IN AAC.handleIntent. action=%s", intent.getAction()); if (Intent.ACTION_VIEW.equals(intent.getAction())) { if (intent.hasExtra(Utils.EXTRA_ACCOUNT)) { setAccount(Account.newInstance(intent.getStringExtra(Utils.EXTRA_ACCOUNT))); } if (mAccount == null) { return; } final boolean isConversationMode = intent.hasExtra(Utils.EXTRA_CONVERSATION); if (intent.getBooleanExtra(Utils.EXTRA_FROM_NOTIFICATION, false)) { Analytics.getInstance().setCustomDimension(Analytics.CD_INDEX_ACCOUNT_TYPE, AnalyticsUtils.getAccountTypeForAccount(mAccount.getEmailAddress())); Analytics.getInstance().sendEvent("notification_click", isConversationMode ? "conversation" : "conversation_list", null, 0); } if (isConversationMode && mViewMode.getMode() == ViewMode.UNKNOWN) { mViewMode.enterConversationMode(); } else { mViewMode.enterConversationListMode(); } // Put the folder and conversation, and ask the loader to create this folder. final Bundle args = new Bundle(); final Uri folderUri; if (intent.hasExtra(Utils.EXTRA_FOLDER_URI)) { folderUri = intent.getParcelableExtra(Utils.EXTRA_FOLDER_URI); } else if (intent.hasExtra(Utils.EXTRA_FOLDER)) { final Folder folder = Folder.fromString(intent.getStringExtra(Utils.EXTRA_FOLDER)); folderUri = folder.folderUri.fullUri; //TS: junwei-xu 2014-1-5 EMAIL BUGFIX_879468 ADD_S } else if (intent.getData() != null) { folderUri = intent.getData(); //TS: junwei-xu 2014-1-5 EMAIL BUGFIX_879468 ADD_E } else { final Bundle extras = intent.getExtras(); LogUtils.d(LOG_TAG, "Couldn't find a folder URI in the extras: %s", extras == null ? "null" : extras.toString()); folderUri = mAccount.settings.defaultInbox; } // Check if we should load all conversations instead of using // the default behavior which loads an initial subset. mIgnoreInitialConversationLimit = intent.getBooleanExtra(Utils.EXTRA_IGNORE_INITIAL_CONVERSATION_LIMIT, false); args.putParcelable(Utils.EXTRA_FOLDER_URI, folderUri); args.putParcelable(Utils.EXTRA_CONVERSATION, intent.getParcelableExtra(Utils.EXTRA_CONVERSATION)); restartOptionalLoader(LOADER_FIRST_FOLDER, mFolderCallbacks, args); } else if (Intent.ACTION_SEARCH.equals(intent.getAction())) { if (intent.hasExtra(Utils.EXTRA_ACCOUNT)) { mHaveSearchResults = false; //TS: zheng.zou 2015-03-18 EMAIL BUGFIX_744708 ADD_S mToastBar.hide(false, false); //TS: zheng.zou 2015-03-18 EMAIL BUGFIX_744708 ADD_E // Save this search query for future suggestions. final String query = intent.getStringExtra(SearchManager.QUERY); final String authority = mContext.getString(R.string.suggestions_authority); final SearchRecentSuggestions suggestions = new SearchRecentSuggestions(mContext, authority, SuggestionsProvider.MODE); suggestions.saveRecentQuery(query, null); setAccount((Account) intent.getParcelableExtra(Utils.EXTRA_ACCOUNT)); fetchSearchFolder(intent); if (shouldEnterSearchConvMode()) { mViewMode.enterSearchResultsConversationMode(); } else { mViewMode.enterSearchResultsListMode(); } /** TCT: init the list context for remote search, except folder. @{ */ // use a UNINITIALIZED folder temporarily. need update when finish search load. Folder folder = Folder.newUnsafeInstance(); mConvListContext = ConversationListContext.forSearchQuery(mAccount, folder, query); mConvListContext .setSearchField(mActivity.getIntent().getStringExtra(SearchParams.BUNDLE_QUERY_FIELD)); /** @} */ } else { /** TCT: The action is search but no extra account means it's a global search. @{ */ mGlobalSearch = true; LogUtils.logFeature(LogTag.SEARCH_TAG, "Handle ACTION_SEARCH , is mGlobalSearch [%s]", mGlobalSearch); // reload conbined inbox folder if needed. if (mAccount != null && (mFolder == null || !mFolder.isInitialized())) { Bundle args = new Bundle(); LogUtils.logFeature(LogTag.SEARCH_TAG, " GlobalSearch but without Folder, reload inbox again."); args.putParcelable(Utils.EXTRA_FOLDER_URI, mAccount.settings.defaultInbox); restartOptionalLoader(LOADER_FIRST_FOLDER, mFolderCallbacks, args); } /** @} */ } } if (mAccount != null) { restartOptionalLoader(LOADER_ACCOUNT_UPDATE_CURSOR, mAccountCallbacks, Bundle.EMPTY); } }
From source file:com.github.dfa.diaspora_android.activity.ShareActivity.java
@SuppressLint("SetJavaScriptEnabled") @Override//from w w w. ja va 2s .com protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main__activity); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); if (toolbar != null) { toolbar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (Helpers.isOnline(ShareActivity.this)) { Intent intent = new Intent(ShareActivity.this, MainActivity.class); startActivityForResult(intent, 100); overridePendingTransition(0, 0); finish(); } else { Snackbar.make(swipeView, R.string.no_internet, Snackbar.LENGTH_LONG).show(); } } }); } setTitle(R.string.new_post); progressBar = (ProgressBar) findViewById(R.id.progressBar); swipeView = (SwipeRefreshLayout) findViewById(R.id.swipe); swipeView.setEnabled(false); podDomain = ((App) getApplication()).getSettings().getPodDomain(); webView = (WebView) findViewById(R.id.webView); webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); WebSettings wSettings = webView.getSettings(); wSettings.setJavaScriptEnabled(true); wSettings.setBuiltInZoomControls(true); if (Build.VERSION.SDK_INT >= 21) wSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); /* * WebViewClient */ webView.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { Log.d(TAG, url); if (!url.contains(podDomain)) { Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(i); return true; } return false; } public void onPageFinished(WebView view, String url) { Log.i(TAG, "Finished loading URL: " + url); } }); /* * WebChromeClient */ webView.setWebChromeClient(new WebChromeClient() { public void onProgressChanged(WebView wv, int progress) { progressBar.setProgress(progress); if (progress > 0 && progress <= 60) { Helpers.getNotificationCount(wv); } if (progress > 60) { Helpers.applyDiasporaMobileSiteChanges(wv); } if (progress == 100) { progressBar.setVisibility(View.GONE); } else { progressBar.setVisibility(View.VISIBLE); } } @Override public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) { if (mFilePathCallback != null) mFilePathCallback.onReceiveValue(null); mFilePathCallback = filePathCallback; Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(getPackageManager()) != null) { // Create the File where the photo should go File photoFile = null; try { photoFile = createImageFile(); takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath); } catch (IOException ex) { // Error occurred while creating the File Snackbar.make(getWindow().findViewById(R.id.main__layout), "Unable to get image", Snackbar.LENGTH_LONG).show(); } // Continue only if the File was successfully created if (photoFile != null) { mCameraPhotoPath = "file:" + photoFile.getAbsolutePath(); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); } else { takePictureIntent = null; } } Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType("image/*"); Intent[] intentArray; if (takePictureIntent != null) { intentArray = new Intent[] { takePictureIntent }; } else { intentArray = new Intent[0]; } Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray); startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE); return true; } }); if (savedInstanceState == null) { if (Helpers.isOnline(ShareActivity.this)) { webView.loadUrl("https://" + podDomain + "/status_messages/new"); } else { Snackbar.make(getWindow().findViewById(R.id.main__layout), R.string.no_internet, Snackbar.LENGTH_LONG).show(); } } Intent intent = getIntent(); String action = intent.getAction(); String type = intent.getType(); if (Intent.ACTION_SEND.equals(action) && type != null) { if ("text/plain".equals(type)) { if (intent.hasExtra(Intent.EXTRA_SUBJECT)) { handleSendSubject(intent); } else { handleSendText(intent); } } else if (type.startsWith("image/")) { // TODO Handle single image being sent -> see manifest handleSendImage(intent); } //} else { // Handle other intents, such as being started from the home screen } }
From source file:com.android.mms.ui.ComposeMessageActivity.java
private void initActivityState(Bundle bundle) { Intent intent = getIntent(); if (bundle != null) { setIntent(getIntent().setAction(Intent.ACTION_VIEW)); String recipients = bundle.getString(RECIPIENTS); if (LogTag.VERBOSE) log("get mConversation by recipients " + recipients); mConversation = Conversation.get(this, ContactList.getByNumbers(recipients, false /* don't block */, true /* replace number */), false);// w w w . j a v a2s . c o m addRecipientsListeners(); mSendDiscreetMode = bundle.getBoolean(KEY_EXIT_ON_SENT, false); mForwardMessageMode = bundle.getBoolean(KEY_FORWARDED_MESSAGE, false); if (mSendDiscreetMode) { mMsgListView.setVisibility(View.INVISIBLE); } mWorkingMessage.readStateFromBundle(bundle); return; } // If we have been passed a thread_id, use that to find our conversation. long threadId = intent.getLongExtra(THREAD_ID, 0); if (threadId > 0) { if (LogTag.VERBOSE) log("get mConversation by threadId " + threadId); mConversation = Conversation.get(this, threadId, false); } else { Uri intentData = intent.getData(); if (intentData != null) { // try to get a conversation based on the data URI passed to our intent. if (LogTag.VERBOSE) log("get mConversation by intentData " + intentData); mConversation = Conversation.get(this, intentData, false); mWorkingMessage.setText(getBody(intentData)); } else { // special intent extra parameter to specify the address String address = intent.getStringExtra("address"); if (!TextUtils.isEmpty(address)) { if (LogTag.VERBOSE) log("get mConversation by address " + address); mConversation = Conversation.get(this, ContactList.getByNumbers(address, false /* don't block */, true /* replace number */), false); } else { if (LogTag.VERBOSE) log("create new conversation"); mConversation = Conversation.createNew(this); } } } addRecipientsListeners(); updateThreadIdIfRunning(); mSendDiscreetMode = intent.getBooleanExtra(KEY_EXIT_ON_SENT, false); mForwardMessageMode = intent.getBooleanExtra(KEY_FORWARDED_MESSAGE, false); if (mSendDiscreetMode) { mMsgListView.setVisibility(View.INVISIBLE); } if (intent.hasExtra("sms_body")) { mWorkingMessage.setText(intent.getStringExtra("sms_body")); } mWorkingMessage.setSubject(intent.getStringExtra("subject"), false); }
From source file:com.tct.mail.compose.ComposeActivity.java
/** * Fill all the widgets with the content found in the Intent Extra, if any. * Also apply the same style to all widgets. Note: if initFromExtras is * called as a result of switching between reply, reply all, and forward per * the latest revision of Gmail, and the user has already made changes to * attachments on a previous incarnation of the message (as a reply, reply * all, or forward), the original attachments from the message will not be * re-instantiated. The user's changes will be respected. This follows the * web gmail interaction.//w ww. j a va2 s. c o m * @return {@code true} if the activity should not call {@link #finishSetup}. */ public boolean initFromExtras(Intent intent) { // If we were invoked with a SENDTO intent, the value // should take precedence final Uri dataUri = intent.getData(); if (dataUri != null) { if (MAIL_TO.equals(dataUri.getScheme())) { initFromMailTo(dataUri.toString()); } else { if (!mAccount.composeIntentUri.equals(dataUri)) { String toText = dataUri.getSchemeSpecificPart(); // TS: junwei-xu 2015-03-23 EMAIL BUGFIX_980239 MOD_S //if (toText != null) { if (Address.isAllValid(toText)) { // TS: junwei-xu 2015-04-23 EMAIL BUGFIX_980239 MOD_E mTo.setText(""); addToAddresses(Arrays.asList(TextUtils.split(toText, ","))); } } } } String[] extraStrings = intent.getStringArrayExtra(Intent.EXTRA_EMAIL); if (extraStrings != null) { addToAddresses(Arrays.asList(extraStrings)); } extraStrings = intent.getStringArrayExtra(Intent.EXTRA_CC); if (extraStrings != null) { addCcAddresses(Arrays.asList(extraStrings), null); } extraStrings = intent.getStringArrayExtra(Intent.EXTRA_BCC); if (extraStrings != null) { addBccAddresses(Arrays.asList(extraStrings)); } String extraString = intent.getStringExtra(Intent.EXTRA_SUBJECT); if (extraString != null) { mSubject.setText(extraString); } for (String extra : ALL_EXTRAS) { if (intent.hasExtra(extra)) { String value = intent.getStringExtra(extra); if (EXTRA_TO.equals(extra)) { addToAddresses(Arrays.asList(TextUtils.split(value, ","))); } else if (EXTRA_CC.equals(extra)) { addCcAddresses(Arrays.asList(TextUtils.split(value, ",")), null); } else if (EXTRA_BCC.equals(extra)) { addBccAddresses(Arrays.asList(TextUtils.split(value, ","))); } else if (EXTRA_SUBJECT.equals(extra)) { mSubject.setText(value); } else if (EXTRA_BODY.equals(extra)) { //[BUGFIX]-Add-BEGINbySCDTABLET.yafang.wei,07/21/2016,2565329 // Modifytofixsignatureshowsbeforebodyissuewhensharewebsitebyemail if (mBodyView.getText().toString().trim() .equals(convertToPrintableSignature(mSignature).trim())) { mBodyView.setText(""); setBody(value, true /* with signature */); appendSignature(); } else { setBody(value, true /* with signature */); } //[BUGFIX]-Add-ENDbySCDTABLET.yafang.wei } else if (EXTRA_QUOTED_TEXT.equals(extra)) { initQuotedText(value, true /* shouldQuoteText */); } } } Bundle extras = intent.getExtras(); //[BUGFIX]-MOD-BEGIN by TSNJ,wenlu.wu,10/20/2014,FR-739335 if (extras != null && !mBodyAlreadySet) { //[BUGFIX]-MOD-END by TSNJ,wenlu.wu,10/20/2014,FR-739335 CharSequence text = extras.getCharSequence(Intent.EXTRA_TEXT); //[BUGFIX]-Add-BEGINbySCDTABLET.yafang.wei,07/21/2016,2565329 // Modifytofixsignatureshowsbeforebodyissuewhensharewebsitebyemail if (mBodyView.getText().toString().trim().equals(convertToPrintableSignature(mSignature).trim())) { mBodyView.setText(""); setBody((text != null) ? text : "", true /* with signature */); appendSignature(); } else { setBody((text != null) ? text : "", true /* with signature */); } //[BUGFIX]-Add-ENDbySCDTABLET.yafang.wei // TODO - support EXTRA_HTML_TEXT } mExtraValues = intent.getParcelableExtra(EXTRA_VALUES); if (mExtraValues != null) { LogUtils.d(LOG_TAG, "Launched with extra values: %s", mExtraValues.toString()); initExtraValues(mExtraValues); return true; } return false; }
From source file:com.shinymayhem.radiopresets.ServiceRadioPlayer.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (LOCAL_LOGV) log("onStartCommand()", "v"); //check if resuming after close for memory, or other crash if ((flags & Service.START_FLAG_REDELIVERY) != 0) { //maybe handle this with dialog and tap to resume if (LOCAL_LOGD) log("Intent redelivery, restarting", "d"); }//from w ww . jav a 2s . c o m mIntent = intent; if (intent == null) { if (LOCAL_LOGD) log("No intent", "w"); } else { String action = intent.getAction(); if (action == null) { if (LOCAL_LOGD) log("No action specified", "w"); //why? //return flag indicating no further action needed if service is stopped by system and later resumes return START_NOT_STICKY; } else if (action.equals(Intent.ACTION_RUN)) //called when service is being bound by player activity { if (LOCAL_LOGV) log("service being started probably so it can be bound", "v"); return START_NOT_STICKY; } else if (action.equals(ACTION_PLAY.toString())) //Play intent { int preset = Integer.valueOf(intent.getIntExtra(ActivityMain.EXTRA_STATION_PRESET, 0)); if (LOCAL_LOGD) log("PLAY action in intent. Preset in extra:" + String.valueOf(preset), "d"); play(preset); //return START_REDELIVER_INTENT; return START_NOT_STICKY; } else if (action.equals(ACTION_PLAY_STREAM.toString())) //Play intent { if (LOCAL_LOGV) log("PLAY_STREAM action in intent", "v"); String url = intent.getStringExtra(EXTRA_URL); if (LOCAL_LOGD) log("URL in extra:" + url, "d"); //check whether the url should be updated (for metadata retrieval purposes) boolean updateUrl = intent.getBooleanExtra(EXTRA_UPDATE_URL, false); if (updateUrl) { mUrl = url; } playUrl(url); //return START_REDELIVER_INTENT; return START_NOT_STICKY; } else if (action.equals(ACTION_UNSUPPORTED_FORMAT_ERROR.toString())) { String format = intent.getStringExtra(EXTRA_FORMAT); if (LOCAL_LOGD) log("Known unsupported format: " + format, "d"); String title = getResources().getString(R.string.error_title); String message = getResources().getString(R.string.error_format) + ":" + format; mCurrentPlayerState = ServiceRadioPlayer.STATE_ERROR; //set 'now playing' to error stopInfo(getResources().getString(R.string.status_error)); this.getErrorNotification(title, message); return START_NOT_STICKY; } else if (action.equals(ACTION_FORMAT_ERROR.toString())) { String message = intent.getStringExtra(EXTRA_ERROR_MESSAGE); if (LOCAL_LOGD) log("URL was unable to play:" + message, "d"); String title = getResources().getString(R.string.error_title); mCurrentPlayerState = ServiceRadioPlayer.STATE_ERROR; //set 'now playing' to error stopInfo(getResources().getString(R.string.status_error)); this.getErrorNotification(title, message); return START_NOT_STICKY; } else if (action.equals(ACTION_STREAM_ERROR.toString())) { int responseCode = intent.getIntExtra(EXTRA_RESPONSE_CODE, 0); String responseMessage = intent.getStringExtra(EXTRA_RESPONSE_MESSAGE); if (LOCAL_LOGD) log("Stream error. Code:" + String.valueOf(responseCode) + ", Message:" + responseMessage, "d"); String title = getResources().getString(R.string.error_title); String message; switch (responseCode) { case 404: message = getResources().getString(R.string.error_not_found); break; case 400: if (responseMessage.equals("Server Full")) { message = getResources().getString(R.string.error_server_full); } else { message = getResources().getString(R.string.error_unknown); } break; default: message = getResources().getString(R.string.error_unknown); } mCurrentPlayerState = ServiceRadioPlayer.STATE_ERROR; //set 'now playing' to error stopInfo(getResources().getString(R.string.status_error)); this.getErrorNotification(title, message); return START_NOT_STICKY; } else if (action.equals(ACTION_NEXT.toString())) //Next preset intent { if (LOCAL_LOGD) log("NEXT action in intent", "d"); nextPreset(); return START_NOT_STICKY; } else if (action.equals(ACTION_PREVIOUS.toString())) //Previous preset intent { if (LOCAL_LOGD) log("PREVIOUS action in intent", "d"); previousPreset(); return START_NOT_STICKY; } else if (action.equals(ACTION_STOP.toString())) //Stop intent { if (LOCAL_LOGD) log("STOP action in intent", "d"); end(); return START_NOT_STICKY; } else if (action.equals(ACTION_LIKE.toString())) //Stop intent { if (intent.hasExtra(EXTRA_SET_TRUE)) { boolean set = intent.getBooleanExtra(EXTRA_SET_TRUE, false); if (set) { if (LOCAL_LOGD) log("LIKE action in intent with true", "d"); this.like(); } else { if (LOCAL_LOGD) log("LIKE action in intent with false", "d"); this.unlike(); } } return START_NOT_STICKY; } else if (action.equals(ACTION_DISLIKE.toString())) //Stop intent { if (intent.hasExtra(EXTRA_SET_TRUE)) { boolean set = intent.getBooleanExtra(EXTRA_SET_TRUE, true); if (set) { if (LOCAL_LOGD) log("DISLIKE action in intent with true", "d"); this.dislike(); } else { if (LOCAL_LOGD) log("DISLIKE action in intent with false", "d"); this.undislike(); } } return START_NOT_STICKY; } else if (action.equals(ACTION_PULL_WIDGET_INFO.toString())) { if (LOCAL_LOGV) log("UPDATE_WIDGET action in intent", "v"); updateDetails(); endIfNotNeeded(); return START_NOT_STICKY; } else { log("Unknown Action:" + action, "w"); } } //return START_STICKY; return START_NOT_STICKY; //return START_REDELIVER_INTENT; }
From source file:com.tct.mail.compose.ComposeActivity.java
private Account obtainAccount(Intent intent) { Account account = null;/*from w w w . ja v a 2s.com*/ Object accountExtra = null; if (intent != null && intent.getExtras() != null) { accountExtra = intent.getExtras().get(Utils.EXTRA_ACCOUNT); if (accountExtra instanceof Account) { account = (Account) accountExtra; //TS: gangjin.weng 2015-04-17 EMAIL BUGFIX_974962 Add_S if (account != null && !account.getAccountId().equalsIgnoreCase("Account Id")) { return account; } else { account = null; } //TS: gangjin.weng 2015-04-17 EMAIL BUGFIX_974962 Add_E } else if (accountExtra instanceof String) { // This is the Account attached to the widget compose intent. account = Account.newInstance((String) accountExtra); //TS: gangjin.weng 2015-04-17 EMAIL BUGFIX_974962 Add_S if (account != null && !account.getAccountId().equalsIgnoreCase("Account Id")) { return account; } else { account = null; } //TS: gangjin.weng 2015-04-17 EMAIL BUGFIX_974962 Add_E // AM: zhiqiang.shao 2015-03-30 EMAIL BUGFIX_957619,960434 MOD_S // if (account != null) { // return account; // } } if (account != null) { if (!Address.isAllValid(account.getEmailAddress()) && mAccounts.length > 0) { return account = mAccounts[0]; } return account; } // AM: zhiqiang.shao 2015-03-30 EMAIL BUGFIX_957619,960434 MOD_E accountExtra = intent.hasExtra(Utils.EXTRA_ACCOUNT) ? intent.getStringExtra(Utils.EXTRA_ACCOUNT) : intent.getStringExtra(EXTRA_SELECTED_ACCOUNT); } // AM: Kexue.Geng 2015-03-06 EMAIL BUGFIX_927828 MOD_S /* MailAppProvider provider = MailAppProvider.getInstance(); String lastAccountUri = provider.getLastSentFromAccount(); if (TextUtils.isEmpty(lastAccountUri)) { lastAccountUri = provider.getLastViewedAccount(); } if (!TextUtils.isEmpty(lastAccountUri)) { accountExtra = Uri.parse(lastAccountUri); } */ boolean goOriginalPath = true; boolean defaultAccountEnable = PLFUtils.getBoolean(getApplicationContext(), "feature_email_defaultAccount_on"); if (defaultAccountEnable) { // If we still have no account, try the default if (account == null) { long accountId = com.tct.emailcommon.provider.Account.getDefaultAccountId(this); if (accountId != com.tct.emailcommon.provider.Account.NO_ACCOUNT) { // Make sure it exists... com.tct.emailcommon.provider.Account defaultAccount = com.tct.emailcommon.provider.Account .restoreAccountWithId(getApplicationContext(), accountId); if (defaultAccount != null) { accountExtra = defaultAccount.getEmailAddress(); goOriginalPath = false; } } } } if (goOriginalPath) { MailAppProvider provider = MailAppProvider.getInstance(); // TS: junwei-xu 2015-11-10 EMAIL BUGFIX-864427 MOD_S //NOTE: We should use last seleceted account as current account. //String lastAccountUri = provider.getLastSentFromAccount(); String lastAccountUri = provider.getLastViewedAccount(); // TS: junwei-xu 2015-11-10 EMAIL BUGFIX-864427 MOD_E if (TextUtils.isEmpty(lastAccountUri)) { lastAccountUri = provider.getLastViewedAccount(); } if (!TextUtils.isEmpty(lastAccountUri)) { accountExtra = Uri.parse(lastAccountUri); } } // AM: Kexue.Geng 2015-03-06 EMAIL BUGFIX_927828 MOD_E // TS: Gantao 2015-06-09 EMAIL BUGFIX-1019278 ADD_S // Note: If we go here,it says that the selected account is "combined view" or null, // anyway ,not normal selected,add a boolean var to avoid the issue when we reply a // mail from combined view. mSelectedAccountUnusual = true; if (mAccounts != null && mAccounts.length > 0) { if (accountExtra instanceof String && !TextUtils.isEmpty((String) accountExtra)) { // For backwards compatibility, we need to check account // names. for (Account a : mAccounts) { if (a.getEmailAddress().equals(accountExtra)) { account = a; } } } else if (accountExtra instanceof Uri) { // The uri of the last viewed account is what is stored in // the current code base. for (Account a : mAccounts) { if (a.uri.equals(accountExtra)) { account = a; } } } if (account == null) { account = mAccounts[0]; } } return account; }
From source file:com.android.cts.verifier.managedprovisioning.ByodHelperActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { Log.w(TAG, "Restored state"); mOriginalSettings = savedInstanceState.getBundle(ORIGINAL_SETTINGS_NAME); } else {//from w ww . j av a 2 s. c om mOriginalSettings = new Bundle(); } mAdminReceiverComponent = new ComponentName(this, DeviceAdminTestReceiver.class.getName()); mDevicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Intent intent = getIntent(); String action = intent.getAction(); Log.d(TAG, "ByodHelperActivity.onCreate: " + action); // we are explicitly started by {@link DeviceAdminTestReceiver} after a successful provisioning. if (action.equals(ACTION_PROFILE_PROVISIONED)) { // Jump back to CTS verifier with result. Intent response = new Intent(ACTION_PROFILE_OWNER_STATUS); response.putExtra(EXTRA_PROVISIONED, isProfileOwner()); startActivityInPrimary(response); // Queried by CtsVerifier in the primary side using startActivityForResult. } else if (action.equals(ACTION_QUERY_PROFILE_OWNER)) { Intent response = new Intent(); response.putExtra(EXTRA_PROVISIONED, isProfileOwner()); setResult(RESULT_OK, response); // Request to delete work profile. } else if (action.equals(ACTION_REMOVE_MANAGED_PROFILE)) { if (isProfileOwner()) { Log.d(TAG, "Clearing cross profile intents"); mDevicePolicyManager.clearCrossProfileIntentFilters(mAdminReceiverComponent); mDevicePolicyManager.wipeData(0); showToast(R.string.provisioning_byod_profile_deleted); } } else if (action.equals(ACTION_INSTALL_APK)) { boolean allowNonMarket = intent.getBooleanExtra(EXTRA_ALLOW_NON_MARKET_APPS, false); boolean wasAllowed = getAllowNonMarket(); // Update permission to install non-market apps setAllowNonMarket(allowNonMarket); mOriginalSettings.putBoolean(INSTALL_NON_MARKET_APPS, wasAllowed); // Request to install a non-market application- easiest way is to reinstall ourself final Intent installIntent = new Intent(Intent.ACTION_INSTALL_PACKAGE) .setData(Uri.parse("package:" + getPackageName())) .putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true).putExtra(Intent.EXTRA_RETURN_RESULT, true); startActivityForResult(installIntent, REQUEST_INSTALL_PACKAGE); // Not yet ready to finish- wait until the result comes back return; // Queried by CtsVerifier in the primary side using startActivityForResult. } else if (action.equals(ACTION_CHECK_INTENT_FILTERS)) { final boolean intentFiltersSetForManagedIntents = new IntentFiltersTestHelper(this) .checkCrossProfileIntentFilters(IntentFiltersTestHelper.FLAG_INTENTS_FROM_MANAGED); setResult(intentFiltersSetForManagedIntents ? RESULT_OK : RESULT_FAILED, null); } else if (action.equals(ACTION_CAPTURE_AND_CHECK_IMAGE)) { // We need the camera permission to send the image capture intent. grantCameraPermissionToSelf(); Intent captureImageIntent = getCaptureImageIntent(); Pair<File, Uri> pair = getTempUri("image.jpg"); mImageFile = pair.first; mImageUri = pair.second; captureImageIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri); if (captureImageIntent.resolveActivity(getPackageManager()) != null) { startActivityForResult(captureImageIntent, REQUEST_IMAGE_CAPTURE); } else { Log.e(TAG, "Capture image intent could not be resolved in managed profile."); showToast(R.string.provisioning_byod_capture_media_error); finish(); } return; } else if (action.equals(ACTION_CAPTURE_AND_CHECK_VIDEO_WITH_EXTRA_OUTPUT) || action.equals(ACTION_CAPTURE_AND_CHECK_VIDEO_WITHOUT_EXTRA_OUTPUT)) { // We need the camera permission to send the video capture intent. grantCameraPermissionToSelf(); Intent captureVideoIntent = getCaptureVideoIntent(); int videoCaptureRequestId; if (action.equals(ACTION_CAPTURE_AND_CHECK_VIDEO_WITH_EXTRA_OUTPUT)) { mVideoUri = getTempUri("video.mp4").second; captureVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, mVideoUri); videoCaptureRequestId = REQUEST_VIDEO_CAPTURE_WITH_EXTRA_OUTPUT; } else { videoCaptureRequestId = REQUEST_VIDEO_CAPTURE_WITHOUT_EXTRA_OUTPUT; } if (captureVideoIntent.resolveActivity(getPackageManager()) != null) { startActivityForResult(captureVideoIntent, videoCaptureRequestId); } else { Log.e(TAG, "Capture video intent could not be resolved in managed profile."); showToast(R.string.provisioning_byod_capture_media_error); finish(); } return; } else if (action.equals(ACTION_CAPTURE_AND_CHECK_AUDIO)) { Intent captureAudioIntent = getCaptureAudioIntent(); if (captureAudioIntent.resolveActivity(getPackageManager()) != null) { startActivityForResult(captureAudioIntent, REQUEST_AUDIO_CAPTURE); } else { Log.e(TAG, "Capture audio intent could not be resolved in managed profile."); showToast(R.string.provisioning_byod_capture_media_error); finish(); } return; } else if (ACTION_KEYGUARD_DISABLED_FEATURES.equals(action)) { final int value = intent.getIntExtra(EXTRA_PARAMETER_1, DevicePolicyManager.KEYGUARD_DISABLE_FEATURES_NONE); mDevicePolicyManager.setKeyguardDisabledFeatures(mAdminReceiverComponent, value); } else if (ACTION_LOCKNOW.equals(action)) { mDevicePolicyManager.lockNow(); setResult(RESULT_OK); } else if (action.equals(ACTION_TEST_NFC_BEAM)) { Intent testNfcBeamIntent = new Intent(this, NfcTestActivity.class); testNfcBeamIntent.putExtras(intent); startActivity(testNfcBeamIntent); finish(); return; } else if (action.equals(ACTION_TEST_CROSS_PROFILE_INTENTS_DIALOG)) { sendIntentInsideChooser(new Intent(CrossProfileTestActivity.ACTION_CROSS_PROFILE_TO_PERSONAL)); } else if (action.equals(ACTION_TEST_APP_LINKING_DIALOG)) { mDevicePolicyManager.addUserRestriction(DeviceAdminTestReceiver.getReceiverComponentName(), UserManager.ALLOW_PARENT_PROFILE_APP_LINKING); Intent toSend = new Intent(Intent.ACTION_VIEW); toSend.setData(Uri.parse("http://com.android.cts.verifier")); sendIntentInsideChooser(toSend); } else if (action.equals(ACTION_SET_USER_RESTRICTION)) { final String restriction = intent.getStringExtra(EXTRA_PARAMETER_1); if (restriction != null) { mDevicePolicyManager.addUserRestriction(DeviceAdminTestReceiver.getReceiverComponentName(), restriction); } } else if (action.equals(ACTION_CLEAR_USER_RESTRICTION)) { final String restriction = intent.getStringExtra(EXTRA_PARAMETER_1); if (restriction != null) { mDevicePolicyManager.clearUserRestriction(DeviceAdminTestReceiver.getReceiverComponentName(), restriction); } } else if (action.equals(ACTION_BYOD_SET_LOCATION_AND_CHECK_UPDATES)) { handleLocationAction(); return; } else if (action.equals(ACTION_NOTIFICATION)) { showNotification(Notification.VISIBILITY_PUBLIC); } else if (ACTION_NOTIFICATION_ON_LOCKSCREEN.equals(action)) { mDevicePolicyManager.lockNow(); showNotification(Notification.VISIBILITY_PRIVATE); } else if (ACTION_CLEAR_NOTIFICATION.equals(action)) { mNotificationManager.cancel(NOTIFICATION_ID); } else if (ACTION_TEST_SELECT_WORK_CHALLENGE.equals(action)) { mDevicePolicyManager.setOrganizationColor(mAdminReceiverComponent, Color.BLUE); mDevicePolicyManager.setOrganizationName(mAdminReceiverComponent, getResources().getString(R.string.provisioning_byod_confirm_work_credentials_header)); startActivity(new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD)); } else if (ACTION_LAUNCH_CONFIRM_WORK_CREDENTIALS.equals(action)) { KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); Intent launchIntent = keyguardManager.createConfirmDeviceCredentialIntent(null, null); startActivity(launchIntent); } else if (ACTION_SET_ORGANIZATION_INFO.equals(action)) { if (intent.hasExtra(OrganizationInfoTestActivity.EXTRA_ORGANIZATION_NAME)) { final String organizationName = intent .getStringExtra(OrganizationInfoTestActivity.EXTRA_ORGANIZATION_NAME); mDevicePolicyManager.setOrganizationName(mAdminReceiverComponent, organizationName); } final int organizationColor = intent.getIntExtra(OrganizationInfoTestActivity.EXTRA_ORGANIZATION_COLOR, mDevicePolicyManager.getOrganizationColor(mAdminReceiverComponent)); mDevicePolicyManager.setOrganizationColor(mAdminReceiverComponent, organizationColor); } else if (ACTION_TEST_PARENT_PROFILE_PASSWORD.equals(action)) { startActivity(new Intent(DevicePolicyManager.ACTION_SET_NEW_PARENT_PROFILE_PASSWORD)); } // This activity has no UI and is only used to respond to CtsVerifier in the primary side. finish(); }
From source file:de.gebatzens.sia.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { setTheme(SIAApp.SIA_APP.school.getTheme()); super.onCreate(savedInstanceState); Log.w("ggvp", "CREATE NEW MAINACTIVITY"); //Debug.startMethodTracing("sia3"); SIAApp.SIA_APP.activity = this; savedState = savedInstanceState;//from w w w .j av a2 s. co m final FragmentData.FragmentList fragments = SIAApp.SIA_APP.school.fragments; Intent intent = getIntent(); if (intent != null && intent.getStringExtra("fragment") != null) { FragmentData frag = fragments .getByType(FragmentData.FragmentType.valueOf(intent.getStringExtra("fragment"))).get(0); SIAApp.SIA_APP.setFragmentIndex(fragments.indexOf(frag)); } if (intent != null && intent.getBooleanExtra("reload", false)) { SIAApp.SIA_APP.refreshAsync(null, true, fragments.get(SIAApp.SIA_APP.getFragmentIndex())); intent.removeExtra("reload"); } setContentView(R.layout.activity_main); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); mContent = getFragment(); transaction.replace(R.id.content_fragment, mContent, "gg_content_fragment"); transaction.commit(); Log.d("ggvp", "DATA: " + fragments.get(SIAApp.SIA_APP.getFragmentIndex()).getData()); if (fragments.get(SIAApp.SIA_APP.getFragmentIndex()).getData() == null) SIAApp.SIA_APP.refreshAsync(null, true, fragments.get(SIAApp.SIA_APP.getFragmentIndex())); if ("Summer".equals(SIAApp.SIA_APP.getCurrentThemeName())) { ImageView summerNavigationPalm = (ImageView) findViewById(R.id.summer_navigation_palm); summerNavigationPalm.setImageResource(R.drawable.summer_palm); ImageView summerBackgroundImage = (ImageView) findViewById(R.id.summer_background_image); summerBackgroundImage.setImageResource(R.drawable.summer_background); } mToolBar = (Toolbar) findViewById(R.id.toolbar); mToolBar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.action_refresh: ((SwipeRefreshLayout) mContent.getView().findViewById(R.id.refresh)).setRefreshing(true); SIAApp.SIA_APP.refreshAsync(new Runnable() { @Override public void run() { ((SwipeRefreshLayout) mContent.getView().findViewById(R.id.refresh)) .setRefreshing(false); } }, true, fragments.get(SIAApp.SIA_APP.getFragmentIndex())); return true; case R.id.action_settings: Intent i = new Intent(MainActivity.this, SettingsActivity.class); startActivityForResult(i, 1); return true; case R.id.action_addToCalendar: showExamDialog(); return true; case R.id.action_help: AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setTitle(getApplication().getString(R.string.help)); builder.setMessage(getApplication().getString(R.string.exam_explain)); builder.setPositiveButton(getApplication().getString(R.string.close), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.create().show(); return true; } return false; } }); updateToolbar(SIAApp.SIA_APP.school.name, fragments.get(SIAApp.SIA_APP.getFragmentIndex()).name); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { SIAApp.SIA_APP.setStatusBarColorTransparent(getWindow()); // because of the navigation drawer } mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolBar, R.string.drawer_open, R.string.drawer_close) { /** Called when a drawer has settled in a completely closed state. */ public void onDrawerClosed(View view) { super.onDrawerClosed(view); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } /** Called when a drawer has settled in a completely open state. */ public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; mDrawerLayout.addDrawerListener(mDrawerToggle); navigationView = (NavigationView) findViewById(R.id.navigation_view); mNavigationHeader = navigationView.getHeaderView(0); mNavigationSchoolpictureText = (TextView) mNavigationHeader.findViewById(R.id.drawer_image_text); mNavigationSchoolpictureText.setText(SIAApp.SIA_APP.school.name); mNavigationSchoolpicture = (ImageView) mNavigationHeader.findViewById(R.id.navigation_schoolpicture); mNavigationSchoolpicture.setImageBitmap(SIAApp.SIA_APP.school.loadImage()); mNavigationSchoolpictureLink = mNavigationHeader.findViewById(R.id.navigation_schoolpicture_link); mNavigationSchoolpictureLink.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View viewIn) { mDrawerLayout.closeDrawers(); Intent linkIntent = new Intent(Intent.ACTION_VIEW); linkIntent.setData(Uri.parse(SIAApp.SIA_APP.school.website)); startActivity(linkIntent); } }); final Menu menu = navigationView.getMenu(); menu.clear(); for (int i = 0; i < fragments.size(); i++) { MenuItem item = menu.add(R.id.fragments, Menu.NONE, i, fragments.get(i).name); item.setIcon(fragments.get(i).getIconRes()); } menu.add(R.id.settings, R.id.settings_item, fragments.size(), R.string.settings); menu.setGroupCheckable(R.id.fragments, true, true); menu.setGroupCheckable(R.id.settings, false, false); final Menu navMenu = navigationView.getMenu(); selectedItem = SIAApp.SIA_APP.getFragmentIndex(); if (selectedItem != -1) navMenu.getItem(selectedItem).setChecked(true); navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { if (menuItem.getItemId() == R.id.settings_item) { mDrawerLayout.closeDrawers(); Intent i = new Intent(MainActivity.this, SettingsActivity.class); startActivityForResult(i, 1); } else { final int index = menuItem.getOrder(); if (SIAApp.SIA_APP.getFragmentIndex() != index) { SIAApp.SIA_APP.setFragmentIndex(index); menuItem.setChecked(true); updateToolbar(SIAApp.SIA_APP.school.name, menuItem.getTitle().toString()); mContent = getFragment(); Animation fadeOut = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_out); fadeOut.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { FrameLayout contentFrame = (FrameLayout) findViewById(R.id.content_fragment); contentFrame.setVisibility(View.INVISIBLE); if (fragments.get(index).getData() == null) SIAApp.SIA_APP.refreshAsync(null, true, fragments.get(index)); //removeAllFragments(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.content_fragment, mContent, "gg_content_fragment"); transaction.commit(); snowView.updateSnow(); } @Override public void onAnimationRepeat(Animation animation) { } }); FrameLayout contentFrame = (FrameLayout) findViewById(R.id.content_fragment); contentFrame.startAnimation(fadeOut); mDrawerLayout.closeDrawers(); } else { mDrawerLayout.closeDrawers(); } } return true; } }); if (Build.VERSION.SDK_INT >= 25) { ShortcutManager shortcutManager = getSystemService(ShortcutManager.class); shortcutManager.removeAllDynamicShortcuts(); for (int i = 0; i < fragments.size(); i++) { Drawable drawable = getDrawable(fragments.get(i).getIconRes()); Bitmap icon; if (drawable instanceof VectorDrawable) { icon = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(icon); drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.draw(canvas); } else { icon = BitmapFactory.decodeResource(getResources(), fragments.get(i).getIconRes()); } Bitmap connectedIcon = Bitmap.createBitmap(icon.getWidth(), icon.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(connectedIcon); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(Color.parseColor("#f5f5f5")); canvas.drawCircle(icon.getWidth() / 2, icon.getHeight() / 2, icon.getWidth() / 2, paint); paint.setColorFilter( new PorterDuffColorFilter(SIAApp.SIA_APP.school.getColor(), PorterDuff.Mode.SRC_ATOP)); canvas.drawBitmap(icon, null, new RectF(icon.getHeight() / 4.0f, icon.getHeight() / 4.0f, icon.getHeight() - icon.getHeight() / 4.0f, icon.getHeight() - icon.getHeight() / 4.0f), paint); Intent newTaskIntent = new Intent(this, MainActivity.class); newTaskIntent.setAction(Intent.ACTION_MAIN); newTaskIntent.putExtra("fragment", fragments.get(i).type.toString()); ShortcutInfo shortcut = new ShortcutInfo.Builder(this, fragments.get(i).name) .setShortLabel(fragments.get(i).name).setLongLabel(fragments.get(i).name) .setIcon(Icon.createWithBitmap(connectedIcon)).setIntent(newTaskIntent).build(); shortcutManager.addDynamicShortcuts(Arrays.asList(shortcut)); } } if (SIAApp.SIA_APP.preferences.getBoolean("app_130_upgrade", true)) { if (!SIAApp.SIA_APP.preferences.getBoolean("first_use_filter", true)) { TextDialog.newInstance(R.string.upgrade1_3title, R.string.upgrade1_3) .show(getSupportFragmentManager(), "upgrade_dialog"); } SIAApp.SIA_APP.preferences.edit().putBoolean("app_130_upgrade", false).apply(); } snowView = (SnowView) findViewById(R.id.snow_view); shareToolbar = (Toolbar) findViewById(R.id.share_toolbar); shareToolbar.getMenu().clear(); shareToolbar.inflateMenu(R.menu.share_toolbar_menu); shareToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { toggleShareToolbar(false); for (Shareable s : MainActivity.this.shared) { s.setMarked(false); } MainActivity.this.shared.clear(); mContent.updateFragment(); } }); shareToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { toggleShareToolbar(false); HashMap<Date, ArrayList<Shareable>> dates = new HashMap<Date, ArrayList<Shareable>>(); for (Shareable s : MainActivity.this.shared) { ArrayList<Shareable> list = dates.get(s.getDate()); if (list == null) { list = new ArrayList<Shareable>(); dates.put(s.getDate(), list); } list.add(s); s.setMarked(false); } MainActivity.this.shared.clear(); List<Date> dateList = new ArrayList<Date>(dates.keySet()); Collections.sort(dateList); String content = ""; for (Date key : dateList) { content += SubstListAdapter.translateDay(key) + "\n\n"; Collections.sort(dates.get(key)); for (Shareable s : dates.get(key)) { content += s.getShareContent() + "\n"; } content += "\n"; } content = content.substring(0, content.length() - 1); mContent.updateFragment(); if (item.getItemId() == R.id.action_copy) { ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText(getString(R.string.entries), content); clipboard.setPrimaryClip(clip); } else if (item.getItemId() == R.id.action_share) { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, content); sendIntent.setType("text/plain"); startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_to))); } return true; } }); if (shared.size() > 0) { shareToolbar.setVisibility(View.VISIBLE); updateShareToolbarText(); } // if a fragment is opened via a notification or a shortcut reset the shared entries // delete extra fragment because the same intent is used when the device gets rotated and the user could have opened a new fragment if (intent != null && intent.hasExtra("fragment")) { resetShareToolbar(); intent.removeExtra("fragment"); } }