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

The following are Jave code examples for showing how to use getCharSequenceArray() 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: WearVibrationCenter   File: NotificationTextParser.java   View Source Code Vote up 5 votes
@SuppressWarnings("ConstantConditions")
@TargetApi(value = Build.VERSION_CODES.JELLY_BEAN)
public boolean parseInboxNotification(Bundle extras)
{
    if (extras.containsKey(Notification.EXTRA_SUMMARY_TEXT))
        title = formatCharSequence(extras.getCharSequence(NotificationCompat.EXTRA_SUMMARY_TEXT));
    else if (extras.containsKey(Notification.EXTRA_SUB_TEXT))
        title = formatCharSequence(extras.getCharSequence(NotificationCompat.EXTRA_SUB_TEXT));
    else if (extras.containsKey(Notification.EXTRA_TITLE))
        title = formatCharSequence(extras.getCharSequence(NotificationCompat.EXTRA_TITLE));
    else
        return false;

    CharSequence[] lines = extras.getCharSequenceArray(NotificationCompat.EXTRA_TEXT_LINES);

    int i = 0;
    while (true)
    {
        text += formatCharSequence(lines[i]) + "\n\n";

            i++;
            if (i >= lines.length)
                break;
    }

    text = text.trim();

    return true;
}
 
Example 2
Project: GitHub   File: Injector.java   View Source Code Vote up 4 votes
public CharSequence[] getCharSequenceArray(Bundle state, String key) {
    return state.getCharSequenceArray(key + baseKey);
}
 
Example 3
Project: android-state   File: InjectionHelper.java   View Source Code Vote up 4 votes
public CharSequence[] getCharSequenceArray(Bundle state, String key) {
    return state.getCharSequenceArray(key + mBaseKey);
}
 
Example 4
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 5
Project: prada   File: UploadAgent.java   View Source Code Vote up 4 votes
@Override
public void handleMessage(Message msg) {
    switch (msg.what) {
        case MSG_AGENT_START:
            //agentStart();
        break;
        case MSG_AGENT_SERVICE_BOUND:
            // Log.i(TAG + ":MSG_AGENT_SERVICE_BOUND", "sendPrepareUploadFiles()");
            sendPrepareUploadFiles(uploadFiles);
        break;
        case MSG_AGENT_START_WRITE:
            Log.i(TAG, "handleMessage: MSG_AGENT_START_WRITE");
            if (msg.obj != null){
                if (msg.obj instanceof ParcelFileDescriptor){
                  if (uploadFiles != null) {
                    if (uploadFiles.size() > 0) {
                      if (msg.getData() != null) {
                        ExplorCurrentUploadData(msg.getData());
                        WriteFileDescriptor wFD = new WriteFileDescriptor();
                        writeFilesHM.put(currentUploadFile, (ParcelFileDescriptor)msg.obj);
                        //wFD.writeFileDescriptor = (ParcelFileDescriptor)msg.obj;
                        wFD.writeFileDescriptor = writeFilesHM.get(currentUploadFile);
                        new Thread(wFD).start();
                        deliverMessage(mService, UploadAgent.MSG_SERVICE_START_READ, null);
                      }
                    }
                  }
                } else {
                    //Toast.makeText(getApplicationContext(), "UploadAgent:no Descriptor!", Toast.LENGTH_SHORT).show();
                }
            }
            break;
        case MSG_AGENT_COMPLETE_WRITE:
            //Toast.makeText(getApplicationContext(), "UploadAgent: Delete File!: " + isDeleteAftUpload, Toast.LENGTH_SHORT).show();
            Bundle data = msg.getData();
            if (data.containsKey(COMPLETE_READ_FILES)) {
                CharSequence[] filesArr = data.getCharSequenceArray(COMPLETE_READ_FILES);
                onCompleteWrite(filesArr);
            } else {
                onCompleteWrite(null);
            }
            break;
        case MSG_AGENT_SERVICE_OFF:
            Log.i(TAG, "handleMessage: MSG_AGENT_SERVICE_OFF");
            isAbandon = true;
            onAgentServiceOff();
        break;
        default:
            super.handleMessage(msg);
    }
}