Java Code Examples for android.os.Bundle.getCharSequence()

The following are Jave code examples for showing how to use getCharSequence() of the android.os.Bundle class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: airgram   File: WearReplyReceiver.java   View Source Code Vote up 7 votes
@Override
public void onReceive(Context context, Intent intent) {
    ApplicationLoader.postInitApplication();
    Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
    if (remoteInput == null) {
        return;
    }
    CharSequence text = remoteInput.getCharSequence(NotificationsController.EXTRA_VOICE_REPLY);
    if (text == null || text.length() == 0) {
        return;
    }
    long dialog_id = intent.getLongExtra("dialog_id", 0);
    int max_id = intent.getIntExtra("max_id", 0);
    if (dialog_id == 0 || max_id == 0) {
        return;
    }
    SendMessagesHelper.getInstance().sendMessage(text.toString(), dialog_id, null, null, true, null, null, null);
    MessagesController.getInstance().markDialogAsRead(dialog_id, max_id, max_id, 0, true, false);
}
 
Example 2
Project: PlusGram   File: AutoMessageReplyReceiver.java   View Source Code Vote up 6 votes
@Override
public void onReceive(Context context, Intent intent) {
    ApplicationLoader.postInitApplication();
    Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
    if (remoteInput == null) {
        return;
    }
    CharSequence text = remoteInput.getCharSequence(NotificationsController.EXTRA_VOICE_REPLY);
    if (text == null || text.length() == 0) {
        return;
    }
    long dialog_id = intent.getLongExtra("dialog_id", 0);
    int max_id = intent.getIntExtra("max_id", 0);
    if (dialog_id == 0 || max_id == 0) {
        return;
    }
    SendMessagesHelper.getInstance().sendMessage(text.toString(), dialog_id, null, null, true, null, null, null);
    MessagesController.getInstance().markDialogAsRead(dialog_id, max_id, max_id, 0, true, false);
}
 
Example 3
Project: Phoenix-for-VK   File: SendService.java   View Source Code Vote up 6 votes
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    String action = intent != null ? intent.getAction() : null;

    if (ACTION_ADD_MESSAGE.equals(action)) {
        int accountId = intent.getExtras().getInt(Extra.ACCOUNT_ID);
        int peerId = intent.getExtras().getInt(Extra.PEER_ID);

        Bundle msg = RemoteInput.getResultsFromIntent(intent);
        if (msg != null) {
            CharSequence body = msg.getCharSequence(Extra.BODY);
            addMessage(accountId, peerId, body);
        }
    } else {
        send();
    }

    return START_NOT_STICKY;
}
 
Example 4
Project: LucaHome-AndroidApplication   File: NotificationService.java   View Source Code Vote up 6 votes
private void handleStatusBarNotification(@NonNull StatusBarNotification statusBarNotification, @NonNull String intentAction) {
    String packageName = statusBarNotification.getPackageName();

    String tickerText = "";
    if (statusBarNotification.getNotification().tickerText != null) {
        tickerText = statusBarNotification.getNotification().tickerText.toString();
    }

    Bundle extras = statusBarNotification.getNotification().extras;
    String title = extras.getString("android.title");

    String text = "";
    CharSequence textCharSequence = extras.getCharSequence("android.text");
    if (textCharSequence != null) {
        text = textCharSequence.toString();
    } else {
        Logger.getInstance().Warning(TAG, "textCharSequence is null!");
    }

    Bitmap bitmap = statusBarNotification.getNotification().largeIcon;

    Notification.Action[] notificationActions = statusBarNotification.getNotification().actions;

    Intent messageReceiveIntent = new Intent(intentAction);

    messageReceiveIntent.putExtra(EXTRA_KEY_PACKAGE_NAME, packageName);
    messageReceiveIntent.putExtra(EXTRA_KEY_TICKER_TEXT, tickerText);
    messageReceiveIntent.putExtra(EXTRA_KEY_TITLE, title);
    messageReceiveIntent.putExtra(EXTRA_KEY_TEXT, text);
    messageReceiveIntent.putExtra(EXTRA_KEY_NOTIFICATION_ACTIONS, notificationActions);

    if (bitmap != null) {
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
        byte[] byteArray = stream.toByteArray();
        messageReceiveIntent.putExtra(EXTRA_KEY_ICON, byteArray);
    }

    LocalBroadcastManager.getInstance(_context).sendBroadcast(messageReceiveIntent);
}
 
Example 5
Project: NeoTerm   File: TabSwitcherModel.java   View Source Code Vote up 6 votes
@Override
public final void restoreInstanceState(@Nullable final Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        firstVisibleTabIndex = savedInstanceState.getInt(FIRST_VISIBLE_TAB_INDEX_EXTRA, -1);
        firstVisibleTabPosition =
                savedInstanceState.getFloat(FIRST_VISIBLE_TAB_POSITION_EXTRA, -1);
        logLevel = (LogLevel) savedInstanceState.getSerializable(LOG_LEVEL_EXTRA);
        tabs = savedInstanceState.getParcelableArrayList(TABS_EXTRA);
        switcherShown = savedInstanceState.getBoolean(SWITCHER_SHOWN_EXTRA);
        selectedTab = savedInstanceState.getParcelable(SELECTED_TAB_EXTRA);
        padding = savedInstanceState.getIntArray(PADDING_EXTRA);
        tabIconId = savedInstanceState.getInt(TAB_ICON_ID_EXTRA);
        tabIconBitmap = savedInstanceState.getParcelable(TAB_ICON_BITMAP_EXTRA);
        tabBackgroundColor = savedInstanceState.getParcelable(TAB_BACKGROUND_COLOR_EXTRA);
        tabTitleTextColor = savedInstanceState.getParcelable(TAB_TITLE_TEXT_COLOR_EXTRA);
        tabCloseButtonIconId = savedInstanceState.getInt(TAB_CLOSE_BUTTON_ICON_ID_EXTRA);
        tabCloseButtonIconBitmap =
                savedInstanceState.getParcelable(TAB_CLOSE_BUTTON_ICON_BITMAP_EXTRA);
        showToolbars = savedInstanceState.getBoolean(SHOW_TOOLBARS_EXTRA);
        toolbarTitle = savedInstanceState.getCharSequence(TOOLBAR_TITLE_EXTRA);
        childRecyclerAdapter.restoreInstanceState(savedInstanceState);
    }
}
 
Example 6
Project: PlusGram   File: WearReplyReceiver.java   View Source Code Vote up 6 votes
@Override
public void onReceive(Context context, Intent intent) {
    ApplicationLoader.postInitApplication();
    Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
    if (remoteInput == null) {
        return;
    }
    CharSequence text = remoteInput.getCharSequence(NotificationsController.EXTRA_VOICE_REPLY);
    if (text == null || text.length() == 0) {
        return;
    }
    long dialog_id = intent.getLongExtra("dialog_id", 0);
    int max_id = intent.getIntExtra("max_id", 0);
    if (dialog_id == 0 || max_id == 0) {
        return;
    }
    SendMessagesHelper.getInstance().sendMessage(text.toString(), dialog_id, null, null, true, null, null, null);
    MessagesController.getInstance().markDialogAsRead(dialog_id, max_id, max_id, 0, true, false);
}
 
Example 7
Project: device-messaging   File: MessageReplyReceiver.java   View Source Code Vote up 5 votes
/**
 * Get the message text from the intent.
 * Note that you should call {@code RemoteInput#getResultsFromIntent(intent)} to process
 * the RemoteInput.
 */
private CharSequence getMessageText(Intent intent) {
    Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
    if (remoteInput != null) {
        return remoteInput.getCharSequence(MessagingService.EXTRA_VOICE_REPLY);
    }
    return null;
}
 
Example 8
Project: FCM-for-Mojo   File: FFMBroadcastReceiver.java   View Source Code Vote up 5 votes
private void handleReply(final Context context, Bundle remoteInput, Chat chat) {
    CharSequence reply = null;
    if (remoteInput != null) {
        reply = remoteInput.getCharSequence(NOTIFICATION_INPUT_KEY);
    }

    FFMIntentService.startReply(context, reply, chat);
}
 
Example 9
Project: Cable-Android   File: AndroidAutoReplyReceiver.java   View Source Code Vote up 5 votes
private CharSequence getMessageText(Intent intent) {
  Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
  if (remoteInput != null) {
    return remoteInput.getCharSequence(VOICE_REPLY_KEY);
  }
  return null;
}
 
Example 10
Project: PeSanKita-android   File: AndroidAutoReplyReceiver.java   View Source Code Vote up 5 votes
private CharSequence getMessageText(Intent intent) {
  Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
  if (remoteInput != null) {
    return remoteInput.getCharSequence(VOICE_REPLY_KEY);
  }
  return null;
}
 
Example 11
Project: boohee_v5.6   File: NotificationCompat.java   View Source Code Vote up 5 votes
public WearableExtender(Action action) {
    Bundle wearableBundle = action.getExtras().getBundle(EXTRA_WEARABLE_EXTENSIONS);
    if (wearableBundle != null) {
        this.mFlags = wearableBundle.getInt(KEY_FLAGS, 1);
        this.mInProgressLabel = wearableBundle.getCharSequence(KEY_IN_PROGRESS_LABEL);
        this.mConfirmLabel = wearableBundle.getCharSequence(KEY_CONFIRM_LABEL);
        this.mCancelLabel = wearableBundle.getCharSequence(KEY_CANCEL_LABEL);
    }
}
 
Example 12
Project: android-WearAccessibilityApp   File: MessagingIntentService.java   View Source Code Vote up 5 votes
private CharSequence getMessage(Intent intent) {
    Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
    if (remoteInput != null) {
        return remoteInput.getCharSequence(EXTRA_REPLY);
    }
    return null;
}
 
Example 13
Project: chromium-for-android-56-debug-video   File: NotificationPlatformBridge.java   View Source Code Vote up 5 votes
@Nullable
private static String getNotificationReply(Intent intent) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
        // RemoteInput was added in KITKAT_WATCH.
        Bundle remoteInputResults = RemoteInput.getResultsFromIntent(intent);
        if (remoteInputResults != null) {
            CharSequence reply =
                    remoteInputResults.getCharSequence(NotificationConstants.KEY_TEXT_REPLY);
            if (reply != null) {
                return reply.toString();
            }
        }
    }
    return null;
}
 
Example 14
Project: letv   File: NotificationCompat.java   View Source Code Vote up 5 votes
public WearableExtender(Action action) {
    Bundle wearableBundle = action.getExtras().getBundle(EXTRA_WEARABLE_EXTENSIONS);
    if (wearableBundle != null) {
        this.mFlags = wearableBundle.getInt(KEY_FLAGS, 1);
        this.mInProgressLabel = wearableBundle.getCharSequence(KEY_IN_PROGRESS_LABEL);
        this.mConfirmLabel = wearableBundle.getCharSequence(KEY_CONFIRM_LABEL);
        this.mCancelLabel = wearableBundle.getCharSequence(KEY_CANCEL_LABEL);
    }
}
 
Example 15
Project: Android-Wear-Projects   File: MessageReplyReceiver.java   View Source Code Vote up 5 votes
private CharSequence getMessageText(Intent intent) {
    Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
    if (remoteInput != null) {
        return remoteInput.getCharSequence(MessagingService.EXTRA_VOICE_REPLY);
    }
    return null;
}
 
Example 16
Project: ChromeLikeTabSwitcher   File: TabSwitcherModel.java   View Source Code Vote up 5 votes
@Override
public final void restoreInstanceState(@Nullable final Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        referenceTabIndex = savedInstanceState.getInt(REFERENCE_TAB_INDEX_EXTRA, -1);
        referenceTabPosition = savedInstanceState.getFloat(REFERENCE_TAB_POSITION_EXTRA, -1);
        logLevel = (LogLevel) savedInstanceState.getSerializable(LOG_LEVEL_EXTRA);
        tabs = savedInstanceState.getParcelableArrayList(TABS_EXTRA);
        switcherShown = savedInstanceState.getBoolean(SWITCHER_SHOWN_EXTRA);
        int selectedTabIndex = savedInstanceState.getInt(SELECTED_TAB_INDEX_EXTRA);
        selectedTab = selectedTabIndex != -1 ? tabs.get(selectedTabIndex) : null;
        padding = savedInstanceState.getIntArray(PADDING_EXTRA);
        applyPaddingToTabs = savedInstanceState.getBoolean(APPLY_PADDING_TO_TABS_EXTRA);
        tabIconId = savedInstanceState.getInt(TAB_ICON_ID_EXTRA);
        tabIconBitmap = savedInstanceState.getParcelable(TAB_ICON_BITMAP_EXTRA);
        tabBackgroundColor = savedInstanceState.getParcelable(TAB_BACKGROUND_COLOR_EXTRA);
        tabContentBackgroundColor =
                savedInstanceState.getInt(TAB_CONTENT_BACKGROUND_COLOR_EXTRA);
        tabTitleTextColor = savedInstanceState.getParcelable(TAB_TITLE_TEXT_COLOR_EXTRA);
        tabCloseButtonIconId = savedInstanceState.getInt(TAB_CLOSE_BUTTON_ICON_ID_EXTRA);
        tabCloseButtonIconBitmap =
                savedInstanceState.getParcelable(TAB_CLOSE_BUTTON_ICON_BITMAP_EXTRA);
        tabProgressBarColor = savedInstanceState.getInt(TAB_PROGRESS_BAR_COLOR_EXTRA, -1);
        showToolbars = savedInstanceState.getBoolean(SHOW_TOOLBARS_EXTRA);
        toolbarTitle = savedInstanceState.getCharSequence(TOOLBAR_TITLE_EXTRA);
        getContentRecyclerAdapter().restoreInstanceState(savedInstanceState);
    }
}
 
Example 17
Project: GitHub   File: Injector.java   View Source Code Vote up 4 votes
public CharSequence getCharSequence(Bundle state, String key) {
    return state.getCharSequence(key + baseKey);
}
 
Example 18
Project: FCM-for-Mojo   File: MessagingStyle.java   View Source Code Vote up 4 votes
@Override
protected void restoreFromCompatExtras(Bundle extras) {
    super.restoreFromCompatExtras(extras);

    mSummaryText = extras.getCharSequence(NotificationCompat.EXTRA_SUMMARY_TEXT);
}
 
Example 19
Project: WearVibrationCenter   File: NotificationTextParser.java   View Source Code Vote up 4 votes
@SuppressWarnings("ConstantConditions") //Android Studio does not correlate between containsKey() and get() and thus throws warnings
   @TargetApi(value = Build.VERSION_CODES.JELLY_BEAN)
public boolean tryParseNatively(Notification notification)
{
	Bundle extras = NotificationCompat.getExtras(notification);
	if (extras == null)
		return false;

       if (parseMessageStyleNotification(notification, extras))
           return true;

       if (extras.containsKey(Notification.EXTRA_TEXT_LINES) && extras.getCharSequenceArray(Notification.EXTRA_TEXT_LINES).length > 0)
       {
           if (parseInboxNotification(extras))
               return true;
       }

	if (!extras.containsKey(Notification.EXTRA_TEXT) && !extras.containsKey(Notification.EXTRA_TEXT_LINES) && !extras.containsKey(Notification.EXTRA_BIG_TEXT))
	{
		return false;
	}
	
	if (extras.containsKey(Notification.EXTRA_TITLE_BIG))
	{
		CharSequence bigTitle = extras.getCharSequence(NotificationCompat.EXTRA_TITLE_BIG);
           if (bigTitle != null && (bigTitle.length() < 40 || !extras.containsKey(Notification.EXTRA_TITLE)))
			title = bigTitle.toString();
		else
			title = formatCharSequence(extras.getCharSequence(NotificationCompat.EXTRA_TITLE));
	}
	else if (extras.containsKey(NotificationCompat.EXTRA_TITLE))
           title = formatCharSequence(extras.getCharSequence(NotificationCompat.EXTRA_TITLE));

       if (extras.containsKey(Notification.EXTRA_TEXT_LINES))
       {
           for (CharSequence line : extras.getCharSequenceArray(NotificationCompat.EXTRA_TEXT_LINES))
           {
               text += formatCharSequence(line) + "\n\n";
           }
           text = text.trim();
       }
       else if (extras.containsKey(Notification.EXTRA_BIG_TEXT))
       {
           text = formatCharSequence(extras.getCharSequence(NotificationCompat.EXTRA_BIG_TEXT));
       }
       else
       {
           text = formatCharSequence(extras.getCharSequence(NotificationCompat.EXTRA_TEXT));
       }

       if (extras.containsKey(Notification.EXTRA_SUB_TEXT))
       {
           text = text.trim();
           text= text + "\n\n" + formatCharSequence(extras.getCharSequence(NotificationCompat.EXTRA_SUB_TEXT));
       }


       return true;
}
 
Example 20
Project: prada   File: UploadAgent.java   View Source Code Vote up 4 votes
protected void ExplorCurrentUploadData(Bundle data){
    if (data != null) {
      this.currentUploadFile = (String)data.getCharSequence(UPLOAD_CURRENT_FILE_NAME);
      this.currentUploadFileSize = this.uploadFiles.get(this.currentUploadFile);
    }
}