Example usage for android.os Bundle getCharSequence

List of usage examples for android.os Bundle getCharSequence

Introduction

In this page you can find the example usage for android.os Bundle getCharSequence.

Prototype

@Override
@Nullable
public CharSequence getCharSequence(@Nullable String key) 

Source Link

Document

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Usage

From source file:qauth.djd.qauthclient.login.ContentFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    //View rootView = inflater.inflate(R.layout.recycler_view_frag, container, false);
    View rootView;//from ww w  .  j a v a 2  s  . c  om
    //rootView.setTag(TAG);

    Bundle args = getArguments();
    Log.i("LOOK HERE", "tag: " + args.getCharSequence(KEY_TITLE));

    if (args.getCharSequence(KEY_TITLE).toString().equals("SIGN UP")) {
        rootView = inflater.inflate(R.layout.fragment_sign_up, container, false);

        if (checkPlayServices()) {
            gcm = GoogleCloudMessaging.getInstance(getActivity());
            regid = getRegistrationId(context);

            Log.i(TAG, "regId: " + regid);

            if (regid.isEmpty()) {
                registerInBackground();
            }
        } else {
            Log.i(TAG, "No valid Google Play Services APK found.");
        }

        EditText editTextEmail = (EditText) rootView.findViewById(R.id.editTextSignupEmail);
        editTextEmail.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (hasFocus) {
                    Log.i("LOOK HERE", "has focus");
                } else {
                    EditText et = (EditText) v;
                    email = et.getText().toString();
                }
            }
        });

        EditText editTextPassword = (EditText) rootView.findViewById(R.id.editTextSignupPassword);
        editTextPassword.setOnEditorActionListener(new android.widget.TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                Log.i("test", "getting here");
                if (actionId == 6) {
                    Log.i("test", "getting here2");
                    String deviceId = Settings.Secure.getString(getActivity().getContentResolver(),
                            Settings.Secure.ANDROID_ID);

                    if (!email.equals("")) {
                        new Register(email, v.getText().toString(), deviceId, getRegistrationId(context),
                                getActivity()).execute();
                    } else {
                        Toast.makeText(getActivity(), "Invalid email", Toast.LENGTH_SHORT).show();
                    }

                    return true;
                } else {
                    return false;
                }
            }
        });

    } else if (args.getCharSequence(KEY_TITLE).toString().equals("  LOG IN ")) {
        rootView = inflater.inflate(R.layout.fragment_log_in, container, false);
    } else {
        rootView = inflater.inflate(R.layout.fragment_sign_up, container, false);
    }

    return rootView;

}

From source file:com.intuitlabs.wear.voiceandchoice.ActionReceiver.java

/**
 * {@inheritDoc}//w  w  w .ja v a  2s. co m
 */
@Override
public void onReceive(final Context context, final Intent _intent) {

    /** notificationId used to issue the notification, so we can cancel the notification */
    final int notificationId = _intent.getIntExtra(Intent.EXTRA_UID, -1);

    /** The bundle that was created during the speech recognition process */
    final Bundle remoteInput = RemoteInput.getResultsFromIntent(_intent);

    /* The user's choice, either directly selected or as a speech recognition result. */
    final String reply = remoteInput != null
            ? remoteInput.getCharSequence(AndroidNotification.EXTRA_VOICE_REPLY).toString()
            : "";

    /* The integer value, associated with the command string in the original json document that was used to generate the notification */
    @SuppressWarnings("unchecked")
    final Map<String, Integer> cmdkeys = (Map<String, Integer>) ListStyle.readFromSharedPreference(context);
    final int selectedId = new PhoneticSearch<>(cmdkeys).match(reply);

    Log.v(LOG_TAG, "Selection / Speech Recognition result: " + reply);
    Log.i(LOG_TAG, "Selection / Selected ID " + selectedId);

    /* Cancel the Notification, which makes it disappear on phone and watch */
    final NotificationManager manager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    manager.cancel(notificationId);

    switch (selectedId) {
    // Purchase Turbo Tax / Go to Web Page
    case 0:
    case 4:
        final String url = context.getString(R.string.turbotax_url);
        context.startActivity(
                new Intent(Intent.ACTION_VIEW).setData(Uri.parse(url)).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
        break;

    // create a calendar Event
    case 1:
    case 5:
        final Calendar cal = Calendar.getInstance();
        cal.set(2015, 3, 15);

        final Intent intent = new Intent(Intent.ACTION_INSERT).setData(CalendarContract.Events.CONTENT_URI)
                .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, cal.getTimeInMillis())
                .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, cal.getTimeInMillis() + 60 * 60 * 1000)
                .putExtra(CalendarContract.Events.TITLE, context.getString(R.string.turbotax_title))
                .putExtra(CalendarContract.Events.DESCRIPTION, context.getString(R.string.turbotax_description))
                .putExtra(CalendarContract.Events.EVENT_LOCATION, context.getString(R.string.turbotax_location))
                .putExtra(CalendarContract.Events.AVAILABILITY, CalendarContract.Events.AVAILABILITY_BUSY)
                .putExtra(Intent.EXTRA_EMAIL, context.getString(R.string.turbotax_email))
                .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
        break;

    // set a reminder
    case 2:
    case 6:
        // todo, set a reminder ..
        break;

    // dismiss, do nothing
    case 3:
    case 7:
    default:
    }
}

From source file:ca.marklauman.tools.FragmentPopup.java

@Override
public void onViewCreated(View v, Bundle savedInstanceState) {
    super.onViewCreated(v, savedInstanceState);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
        setupAnimator();// w w w. jav a 2  s  .c  o m
    if (savedInstanceState != null) {
        message = savedInstanceState.getCharSequence(KEY_MSG);
        button_vis = savedInstanceState.getBoolean(KEY_BTN);
    }
    if (message != null)
        show(message, button_vis, true);
}

From source file:com.socialdisasters.other.ReplyActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Bundle remoteInput = RemoteInput.getResultsFromIntent(getIntent());
    Long buddyId = getIntent().getLongExtra(ChatService.EXTRA_BUDDY_ID, -1L);

    if (remoteInput != null && buddyId >= 0) {
        final Intent intent = new Intent(this, ChatService.class);
        intent.setAction(ChatService.ACTION_SEND_MESSAGE);
        intent.putExtra(ChatService.EXTRA_BUDDY_ID, buddyId);
        intent.putExtra(ChatService.EXTRA_TEXT_BODY,
                remoteInput.getCharSequence(ChatService.EXTRA_VOICE_REPLY).toString());
        startService(intent);/*from  w ww  .  j  a  v  a 2 s  . c  om*/

        ChatService.cancelNotification(this, buddyId);
    }

    this.finish();
}

From source file:mobi.cangol.mobile.base.BaseContentFragment.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);/*  w  w w .  j  av a2 s . c o m*/
    setMenuVisibility(true);
    if (savedInstanceState == null) {

    } else {
        title = savedInstanceState.getCharSequence("title");
    }
}

From source file:com.yangtsaosoftware.pebblemessenger.services.NotificationService.java

@Override
public void onNotificationPosted(StatusBarNotification sbn) {
    if (sbn == null)
        return;// w w w. j a  v a2s . c  o  m
    Constants.log(LOG_TAG, "New Access Event:" + sbn.getPackageName() + " tag:" + sbn.getTag());
    /*if(event.getEventType()!= AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED){
            
    return;
    }
    */
    PowerManager powMan = (PowerManager) this.getSystemService(POWER_SERVICE);
    if (!notifScreenOn && powMan.isScreenOn()) {
        Constants.log(LOG_TAG, "because screen out!");
        return;
    }
    //Parcelable parcelable=event.getParcelableData();
    //if(!(parcelable instanceof Notification)) return;
    Notification notif = sbn.getNotification();
    if (sbn.isOngoing()) {
        Constants.log(LOG_TAG, "because is Ongoing!");
        return;
    }

    String eventPackageName;

    if (sbn.getPackageName() != null) {
        eventPackageName = sbn.getPackageName();
    } else {
        Constants.log(LOG_TAG, "Can't get event package name. Returning.");
        return;
    }

    boolean found = false;
    for (String packageName : packages) {
        if (packageName.equalsIgnoreCase(eventPackageName)) {
            found = true;
            break;
        }
    }
    if (!found) {
        Constants.log(LOG_TAG, eventPackageName + " was not found in the include list. Returning.");
        return;
    }
    String title = eventPackageName.substring(eventPackageName.lastIndexOf('.') + 1);
    // get the notification text
    Bundle notiBundle = notif.extras;
    StringBuilder notifySb = new StringBuilder();
    CharSequence notifyChars = notiBundle.getCharSequence(Notification.EXTRA_TITLE);
    if (notifyChars != null) {
        notifySb.append(notifyChars);
    } else {
        Constants.log(LOG_TAG, "empty message title,return!");
        return;
    }

    CharSequence bodyCS = notiBundle.getCharSequence(Notification.EXTRA_TEXT);
    if (bodyCS != null) {
        notifySb.append(":");
        notifySb.append(bodyCS);
    } else {
        Constants.log(LOG_TAG, "empty message body,return!" + notifySb.toString());
        return;
    }
    bodyCS = notiBundle.getCharSequence(Notification.EXTRA_SUB_TEXT);
    if (bodyCS != null) {
        notifySb.append(bodyCS);
    }

    Message msg = Message.obtain();
    msg.what = MessageProcessingService.MSG_NEW_MESSAGE;
    Bundle b = new Bundle();
    b.putString(MessageDbHandler.COL_MESSAGE_APP, title);
    b.putString(MessageDbHandler.COL_MESSAGE_CONTENT, notifySb.toString());
    Constants.log(LOG_TAG, "Send new message title:" + title + " body:" + notifySb.toString());
    msg.setData(b);
    try {
        rMessageProcessHandler.send(msg);
    } catch (RemoteException e) {
        e.printStackTrace();
        Constants.log(LOG_TAG, "Error when sending message to MessageProcessingService.");
    }
}

From source file:com.google.android.apps.muzei.notifications.NewWallpaperNotificationReceiver.java

private void triggerUserCommandFromRemoteInput(final Context context, Intent intent) {
    Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
    if (remoteInput == null) {
        return;//from w  ww.j  a  v a  2  s  . c  o m
    }
    final String selectedCommand = remoteInput.getCharSequence(EXTRA_USER_COMMAND).toString();
    final PendingResult pendingResult = goAsync();
    final LiveData<Source> sourceLiveData = MuzeiDatabase.getInstance(context).sourceDao().getCurrentSource();
    sourceLiveData.observeForever(new Observer<Source>() {
        @Override
        public void onChanged(@Nullable final Source selectedSource) {
            sourceLiveData.removeObserver(this);
            if (selectedSource != null) {
                for (UserCommand action : selectedSource.commands) {
                    if (TextUtils.equals(selectedCommand, action.getTitle())) {
                        SourceManager.sendAction(context, action.getId());
                        break;
                    }
                    pendingResult.finish();
                }
            }
        }
    });
}

From source file:de.vanita5.twittnuker.fragment.support.AddUserListMemberDialogFragment.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final Context wrapped = ThemeUtils.getDialogThemedContext(getActivity());
    final AlertDialog.Builder builder = new AlertDialog.Builder(wrapped);
    final View view = LayoutInflater.from(wrapped).inflate(R.layout.auto_complete_textview, null);
    builder.setView(view);//w  ww .  ja v a  2 s.  c  o  m
    mEditText = (AutoCompleteTextView) view.findViewById(R.id.edit_text);
    if (savedInstanceState != null) {
        mEditText.setText(savedInstanceState.getCharSequence(EXTRA_TEXT));
    }
    mUserAutoCompleteAdapter = new UserHashtagAutoCompleteAdapter(wrapped);
    mEditText.setAdapter(mUserAutoCompleteAdapter);
    mEditText.setThreshold(1);
    mEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(20) });
    builder.setTitle(R.string.screen_name);
    builder.setPositiveButton(android.R.string.ok, this);
    builder.setNegativeButton(android.R.string.cancel, this);
    return builder.create();
}

From source file:org.getlantern.firetweet.fragment.support.AddUserListMemberDialogFragment.java

@NonNull
@Override/*from  www .  j ava 2s.c o m*/
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final Context wrapped = ThemeUtils.getDialogThemedContext(getActivity());
    final AlertDialog.Builder builder = new AlertDialog.Builder(wrapped);
    final View view = LayoutInflater.from(wrapped).inflate(R.layout.auto_complete_textview, null);
    builder.setView(view);
    mEditText = (AutoCompleteTextView) view.findViewById(R.id.edit_text);
    if (savedInstanceState != null) {
        mEditText.setText(savedInstanceState.getCharSequence(EXTRA_TEXT));
    }
    mUserAutoCompleteAdapter = new UserHashtagAutoCompleteAdapter(wrapped);
    final Bundle args = getArguments();
    mUserAutoCompleteAdapter.setAccountId(args.getLong(EXTRA_ACCOUNT_ID));
    mEditText.setAdapter(mUserAutoCompleteAdapter);
    mEditText.setThreshold(1);
    mEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(20) });
    builder.setTitle(R.string.screen_name);
    builder.setPositiveButton(android.R.string.ok, this);
    builder.setNegativeButton(android.R.string.cancel, this);
    return builder.create();
}

From source file:org.mariotaku.twidere.fragment.support.AddUserListMemberDialogFragment.java

@NonNull
@Override//  w  w  w  .j  av  a2 s  . com
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final Context wrapped = ThemeUtils.getDialogThemedContext(getActivity());
    final AlertDialog.Builder builder = new AlertDialog.Builder(wrapped);
    final View view = LayoutInflater.from(wrapped).inflate(R.layout.dialog_auto_complete_textview, null);
    builder.setView(view);
    mEditText = (AutoCompleteTextView) view.findViewById(R.id.edit_text);
    if (savedInstanceState != null) {
        mEditText.setText(savedInstanceState.getCharSequence(EXTRA_TEXT));
    }
    mUserAutoCompleteAdapter = new UserHashtagAutoCompleteAdapter(wrapped);
    final Bundle args = getArguments();
    mUserAutoCompleteAdapter.setAccountId(args.getLong(EXTRA_ACCOUNT_ID));
    mEditText.setAdapter(mUserAutoCompleteAdapter);
    mEditText.setThreshold(1);
    mEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(20) });
    builder.setTitle(R.string.screen_name);
    builder.setPositiveButton(android.R.string.ok, this);
    builder.setNegativeButton(android.R.string.cancel, this);
    return builder.create();
}