Java Code Examples for android.content.Intent#getCharSequenceExtra()
The following examples show how to use
android.content.Intent#getCharSequenceExtra() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: FCM-for-Mojo File: FFMIntentService.java License: GNU General Public License v3.0 | 6 votes |
@Override protected void onHandleIntent(Intent intent) { if (intent == null) { return; } final String action = intent.getAction(); if (ACTION_UPDATE_ICON.equals(action)) { handleUpdateIcon(intent.getBooleanExtra(EXTRA_ALL, false)); } else if (ACTION_REPLY.equals(action)) { CharSequence content = intent.getCharSequenceExtra(EXTRA_CONTENT); Chat chat = intent.getParcelableExtra(EXTRA_CHAT); handleReply(content, chat); } else if (ACTION_DOWNLOAD_QRCODE.equals(action)) { handleDownloadQrCode(); } else if (ACTION_RESTART_WEBQQ.equals(action)) { handleRestart(); } }
Example 2
Source Project: MTweaks-KernelAdiutorMOD File: CreateFragment.java License: GNU General Public License v3.0 | 5 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == 0 && data != null) { CharSequence text = data.getCharSequenceExtra(EditorActivity.TEXT_INTENT); if (text != null) { mCodeViews.get(mSettings.get(requestCode)).resetTest(); mCodeViews.get(mSettings.get(requestCode)).setCode(text.toString().trim()); showFab(); } } }
Example 3
Source Project: container File: ChooserActivity.java License: GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { Intent intent = getIntent(); int userId = intent.getIntExtra(Constants.EXTRA_USER_HANDLE, VUserHandle.getCallingUserId()); mOptions = intent.getParcelableExtra(EXTRA_DATA); mResultWho = intent.getStringExtra(EXTRA_WHO); mRequestCode = intent.getIntExtra(EXTRA_REQUEST_CODE, 0); Parcelable targetParcelable = intent.getParcelableExtra(Intent.EXTRA_INTENT); if (!(targetParcelable instanceof Intent)) { VLog.w("ChooseActivity", "Target is not an intent: " + targetParcelable); finish(); return; } Intent target = (Intent) targetParcelable; CharSequence title = intent.getCharSequenceExtra(Intent.EXTRA_TITLE); if (title == null) { title = getString(R.string.choose); } Parcelable[] pa = intent.getParcelableArrayExtra(Intent.EXTRA_INITIAL_INTENTS); Intent[] initialIntents = null; if (pa != null) { initialIntents = new Intent[pa.length]; for (int i = 0; i < pa.length; i++) { if (!(pa[i] instanceof Intent)) { VLog.w("ChooseActivity", "Initial intent #" + i + " not an Intent: " + pa[i]); finish(); return; } initialIntents[i] = (Intent) pa[i]; } } super.onCreate(savedInstanceState, target, title, initialIntents, null, false, userId); }
Example 4
Source Project: Cirrus_depricated File: CopyToClipboardActivity.java License: GNU General Public License v2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // get the clipboard system service ClipboardManager clipboardManager = (ClipboardManager) this.getSystemService(CLIPBOARD_SERVICE); // get the text to copy into the clipboard Intent intent = getIntent(); CharSequence text = intent.getCharSequenceExtra(Intent.EXTRA_TEXT); // and put the text the clipboard if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { // API level >= 11 -> modern Clipboard ClipData clip = ClipData.newPlainText("Synox was here", text); ((android.content.ClipboardManager)clipboardManager).setPrimaryClip(clip); } else { // API level >= 11 -> legacy Clipboard clipboardManager.setText(text); } // alert the user that the text is in the clipboard and we're done Toast.makeText(this, R.string.clipboard_text_copied, Toast.LENGTH_SHORT).show(); finish(); }
Example 5
Source Project: maoni File: MaoniActivity.java License: MIT License | 5 votes |
private void setAppRelatedInfo() { final Intent intent = getIntent(); final CharSequence callerActivity = intent.getCharSequenceExtra(CALLER_ACTIVITY); mAppInfo = new Feedback.App( callerActivity != null ? callerActivity : getClass().getSimpleName(), intent.hasExtra(APPLICATION_INFO_BUILD_CONFIG_DEBUG) ? intent.getBooleanExtra(APPLICATION_INFO_BUILD_CONFIG_DEBUG, false) : null, intent.getStringExtra(APPLICATION_INFO_PACKAGE_NAME), intent.getIntExtra(APPLICATION_INFO_VERSION_CODE, -1), intent.getStringExtra(APPLICATION_INFO_BUILD_CONFIG_FLAVOR), intent.getStringExtra(APPLICATION_INFO_BUILD_CONFIG_BUILD_TYPE), intent.hasExtra(APPLICATION_INFO_VERSION_NAME) ? intent.getStringExtra(APPLICATION_INFO_VERSION_NAME) : null); }
Example 6
Source Project: AndroidPreferenceActivity File: PreferenceActivity.java License: Apache License 2.0 | 5 votes |
/** * Returns the char sequence, which is specified by a specific intent extra. The char sequence * can either be specified as a string or as a resource id. * * @param intent * The intent, which specifies the char sequence, as an instance of the class {@link * Intent}. The intent may not be null * @param name * The name of the intent extra, which specifies the char sequence, as a {@link String}. * The name may not be null * @return The char sequence, which is specified by the given intent, as an instance of the * class {@link CharSequence} or null, if the intent does not specify a char sequence with the * given name */ private CharSequence getCharSequenceFromIntent(@NonNull final Intent intent, @NonNull final String name) { CharSequence charSequence = intent.getCharSequenceExtra(name); if (charSequence == null) { int resourceId = intent.getIntExtra(name, 0); if (resourceId != 0) { charSequence = getText(resourceId); } } return charSequence; }
Example 7
Source Project: chronosnap File: CaptureService.java License: MIT License | 5 votes |
/** * Reimplementation of Service.onStartCommand() */ @Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent != null) { // Dispatch the command to the appropriate method final String action = intent.getAction(); switch (action) { case ACTION_BROADCAST_STATUS: broadcastStatus(); break; case ACTION_START_CAPTURE: CharSequence sequenceName = intent.getCharSequenceExtra(EXTRA_SEQUENCE_NAME); startCapture(sequenceName); break; case ACTION_STOP_CAPTURE: stopCapture(); break; case ACTION_CAPTURE: capture(); break; } } return START_STICKY; }
Example 8
Source Project: 365browser File: SelectionPopupController.java License: Apache License 2.0 | 5 votes |
@Override public void onReceivedProcessTextResult(int resultCode, Intent data) { if (mWebContents == null || resultCode != Activity.RESULT_OK || data == null) return; // Do not handle the result if no text is selected or current selection is not editable. if (!hasSelection() || !isSelectionEditable()) return; CharSequence result = data.getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT); if (result != null) { // TODO(hush): Use a variant of replace that re-selects the replaced text. // crbug.com/546710 mWebContents.replace(result.toString()); } }
Example 9
Source Project: KernelAdiutor File: CreateFragment.java License: GNU General Public License v3.0 | 5 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == 0 && data != null) { CharSequence text = data.getCharSequenceExtra(EditorActivity.TEXT_INTENT); if (text != null) { mCodeViews.get(mSettings.get(requestCode)).resetTest(); mCodeViews.get(mSettings.get(requestCode)).setCode(text.toString().trim()); showFab(); } } }
Example 10
Source Project: smartcard-reader File: FileShareActivity.java License: GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); Spanned text = (Spanned) intent.getCharSequenceExtra(Intent.EXTRA_TEXT); if (text != null && Intent.ACTION_SEND.equals(intent.getAction()) && "text/html".equals(intent.getType())) { // check external storage if (isExternalStorageWritable()) { // write string to file try { File file = new File(getExternalFilesDir(null), "smartcard_reader_" + System.currentTimeMillis() + ".html"); Log.d(TAG, "abs file path: " + file.getAbsolutePath()); OutputStream os = new FileOutputStream(file); OutputStreamWriter osw = new OutputStreamWriter(os); osw.write(Html.toHtml(text)); osw.close(); Util.showToast(this, getString(R.string.saved_to, file.getName())); // add file to media library for viewing via mtp Intent scanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); scanIntent.setData(Uri.fromFile(file)); sendBroadcast(scanIntent); } catch (IOException e) { Log.e(TAG, "failed to write file: " + e.toString()); Util.showToast(this, getString(R.string.save_exception)); } } else { Util.showToast(this, getString(R.string.save_not_mounted)); } } finish(); }
Example 11
Source Project: apigee-android-sdk File: AddUserToGroupActivity.java License: Apache License 2.0 | 5 votes |
/** * Called when the activity starts. Sets up the UI to * collect values needed. */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_add_user_to_group); // Bind UI widgets to variables in this code. addUserToGroupMessage = (TextView) findViewById(R.id.textAddUserToGroupMessage); groupsSpinner = (Spinner) findViewById(R.id.groupsSpinner); // Get the Apigee data client for interacting with the application. usersGroupsApp = (UsersAndGroupsApplication) getApplication(); dataClient = usersGroupsApp.getDataClient(); // Use the Intent instance to grab a value // passed from another activity. Intent intent = getIntent(); userId = intent.getCharSequenceExtra("userId"); // Simply a little guidance. if (userId.length() > 0){ addUserToGroupMessage.setText("Add " + userId + " to a group you select:"); } // Get all of the groups and populate the spinner. getGroups(); // Get just the groups the current user is in and show that list. getGroupsForUser(); }
Example 12
Source Project: BaldPhone File: AddContactActivity.java License: Apache License 2.0 | 4 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (!checkPermissions(this, requiredPermissions())) return; setContentView(R.layout.add__edit_conatct_activity); attachXml(); final Intent callingIntent = getIntent(); if (callingIntent == null) throw new IllegalStateException(TAG + " calling intent cannot be null!"); final String contactLookupKey = callingIntent.getStringExtra(SingleContactActivity.CONTACT_LOOKUP_KEY); if (contactLookupKey != null) try { fillWithContact(contactLookupKey); } catch (IllegalStateException | Contact.ContactNotFoundException e) { // sometimes it may happen, that the lookup key changes during the transition; // while very unlikely (happened to me once in 200 tests), it should be checked startActivity(new Intent(this, ContactsActivity.class)); finish(); return; } else { final CharSequence contactNumber = callingIntent.getCharSequenceExtra(CONTACT_NUMBER); if (contactNumber != null) { et_mobile_number.setText(contactNumber); } } iv_image.setOnClickListener(v -> startActivityForResult( new Intent(this, PhotosActivity.class).setAction(Intent.ACTION_GET_CONTENT), SELECT_IMAGE_REQUEST_CODE) ); iv_delete.setOnClickListener(v -> { iv_image.setImageResource(R.drawable.photo_on_button); newPhoto = null; v.setVisibility(View.INVISIBLE); }); save.setOnClickListener(v -> save()); ((BaldTitleBar) findViewById(R.id.bald_title_bar)).getBt_back().setOnClickListener(v -> { if (safeToExit()) finish(); else showExitMessage(); }); }
Example 13
Source Project: Ticket-Analysis File: IntentUtil.java License: MIT License | 4 votes |
public static CharSequence getCharSequenceExtra(Intent intent, String name) { if (!hasIntent(intent) || !hasExtra(intent, name)) return null; return intent.getCharSequenceExtra(name); }
Example 14
Source Project: ticdesign File: RingtonePickerActivity.java License: Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mHandler = new Handler(); Intent intent = getIntent(); /* * Get whether to show the 'Default' item, and the URI to play when the * default is clicked */ mHasDefaultItem = intent.getBooleanExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true); mUriForDefaultItem = intent.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI); if (mUriForDefaultItem == null) { mUriForDefaultItem = Settings.System.DEFAULT_RINGTONE_URI; } if (savedInstanceState != null) { mClickedPos = savedInstanceState.getInt(SAVE_CLICKED_POS, POS_UNKNOWN); } // Get whether to show the 'Silent' item mHasSilentItem = intent.getBooleanExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true); // Give the Activity so it can do managed queries mRingtoneManager = new RingtoneManager(this); // Get the types of ringtones to show mType = intent.getIntExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, -1); if (mType != -1) { mRingtoneManager.setType(mType); } mCursor = mRingtoneManager.getCursor(); // The volume keys will control the stream that we are choosing a ringtone for setVolumeControlStream(mRingtoneManager.inferStreamType()); // Get the URI whose list item should have a checkmark mExistingUri = intent .getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI); final AlertParams p = mAlertParams; p.mCursor = mCursor; p.mOnClickListener = mRingtoneClickListener; p.mLabelColumn = MediaStore.Audio.Media.TITLE; p.mIsSingleChoice = true; p.mOnItemSelectedListener = this; if (SHOW_BUTTONS) { p.mPositiveButtonIcon = getDrawable(R.drawable.tic_ic_btn_ok); p.mPositiveButtonListener = this; p.mNegativeButtonIcon = getDrawable(R.drawable.tic_ic_btn_cancel); p.mNegativeButtonListener = this; } p.mOnPrepareListViewListener = this; p.mTitle = intent.getCharSequenceExtra(RingtoneManager.EXTRA_RINGTONE_TITLE); if (p.mTitle == null) { p.mTitle = getString(R.string.ringtone_picker_title); } p.mAdapter = mWithHeaderCursorAdapter = new WithHeaderCursorAdapter(this, p.mCursor, p.mLabelColumn); setupAlert(); }
Example 15
Source Project: OnActivityResult File: IntentHelper.java License: Apache License 2.0 | 4 votes |
public static CharSequence getExtraCharSequence(final Intent intent, final String key, final CharSequence defaultValue) { final CharSequence extra = intent.getCharSequenceExtra(key); return extra != null ? extra : defaultValue; }