Java 类android.app.RemoteInput 实例源码

项目:NewKakaoBot    文件:KakaoTalkListener.java   
public static void send(String room, String message) throws IllegalArgumentException { // @author ManDongI
    Notification.Action session = null;

    for(KakaoData data : KakaoManager.getInstance().getDataList().toArray(new KakaoData[0])) {
        if(data.room.equals(room)) {
            session = data.session;

            break;
        }
    }

    if(session == null) {
        throw new IllegalArgumentException("Can't find the room");
    }

    Intent sendIntent = new Intent();
    Bundle msg = new Bundle();
    for (RemoteInput inputable : session.getRemoteInputs()) msg.putCharSequence(inputable.getResultKey(), message);
    RemoteInput.addResultsToIntent(session.getRemoteInputs(), sendIntent, msg);

    try {
        session.actionIntent.send(context, 0, sendIntent);

        Logger.Log log = new Logger.Log();
        log.type = Logger.Type.APP;
        log.title = "send message";
        log.index = "room: " + room +"\nmessage: " + message;

        Logger.getInstance().add(log);
    } catch (PendingIntent.CanceledException e) {
        e.printStackTrace();
    }
}
项目:KakaoBot    文件:KakaoTalkListener.java   
public static void send(String room, String message) throws IllegalArgumentException { // @author ManDongI
    Notification.Action session = null;

    for(Session i : sessions) {
        if(i.room.equals(room)) {
            session = i.session;

            break;
        }
    }

    if(session == null) {
        throw new IllegalArgumentException("Can't find the room");
    }

    Intent sendIntent = new Intent();
    Bundle msg = new Bundle();
    for (RemoteInput inputable : session.getRemoteInputs()) msg.putCharSequence(inputable.getResultKey(), message);
    RemoteInput.addResultsToIntent(session.getRemoteInputs(), sendIntent, msg);

    try {
        session.actionIntent.send(context, 0, sendIntent);
    } catch (PendingIntent.CanceledException e) {
        e.printStackTrace();
    }
}
项目:permissionsModule    文件:RemoteInputCompatApi20.java   
static RemoteInput[] fromCompat(RemoteInputCompatBase.RemoteInput[] srcArray) {
    if (srcArray == null) {
        return null;
    }
    RemoteInput[] result = new RemoteInput[srcArray.length];
    for (int i = 0; i < srcArray.length; i++) {
        RemoteInputCompatBase.RemoteInput src = srcArray[i];
        result[i] = new RemoteInput.Builder(src.getResultKey())
                .setLabel(src.getLabel())
                .setChoices(src.getChoices())
                .setAllowFreeFormInput(src.getAllowFreeFormInput())
                .addExtras(src.getExtras())
                .build();
    }
    return result;
}
项目:discover-android-n    文件:ReplyBroadcastReceiver.java   
@Override
public void onReceive(Context context, Intent intent) {
    // Get remote input
    Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
    // Exit if remote input is null (always true for API < 24)
    if (remoteInput == null) {
        return;
    }
    // Get reply text
    String reply = remoteInput.getString(KEY_TEXT_REPLY);
    // Create reply notification
    Notification replyNotification =
            new Notification.Builder(context)
                    .setSmallIcon(R.drawable.ic_notifications_active_black_24dp)
                    .setContentTitle("Reply received!")
                    .setContentText(reply)
                    .build();
    // Send reply notification
    NotificationManager notificationManager =
            (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(REPLY_NOTIFICATION_ID, replyNotification);
}
项目:FMTech    文件:RemoteInputCompatApi20.java   
static RemoteInput[] fromCompat(RemoteInputCompatBase.RemoteInput[] paramArrayOfRemoteInput)
{
  RemoteInput[] arrayOfRemoteInput;
  if (paramArrayOfRemoteInput == null) {
    arrayOfRemoteInput = null;
  }
  for (;;)
  {
    return arrayOfRemoteInput;
    arrayOfRemoteInput = new RemoteInput[paramArrayOfRemoteInput.length];
    for (int i = 0; i < paramArrayOfRemoteInput.length; i++)
    {
      RemoteInputCompatBase.RemoteInput localRemoteInput = paramArrayOfRemoteInput[i];
      arrayOfRemoteInput[i] = new RemoteInput.Builder(localRemoteInput.getResultKey()).setLabel(localRemoteInput.getLabel()).setChoices(localRemoteInput.getChoices()).setAllowFreeFormInput(localRemoteInput.getAllowFreeFormInput()).addExtras(localRemoteInput.getExtras()).build();
    }
  }
}
项目:FMTech    文件:NotificationCompatApi20.java   
public static void addAction(Notification.Builder paramBuilder, NotificationCompatBase.Action paramAction)
{
  Notification.Action.Builder localBuilder = new Notification.Action.Builder(paramAction.getIcon(), paramAction.getTitle(), paramAction.getActionIntent());
  if (paramAction.getRemoteInputs() != null)
  {
    RemoteInput[] arrayOfRemoteInput = RemoteInputCompatApi20.fromCompat(paramAction.getRemoteInputs());
    int i = arrayOfRemoteInput.length;
    for (int j = 0; j < i; j++) {
      localBuilder.addRemoteInput(arrayOfRemoteInput[j]);
    }
  }
  if (paramAction.getExtras() != null) {
    localBuilder.addExtras(paramAction.getExtras());
  }
  paramBuilder.addAction(localBuilder.build());
}
项目:FMTech    文件:efj.java   
public static void a(Notification.Builder paramBuilder, ea paramea)
{
  Notification.Action.Builder localBuilder = new Notification.Action.Builder(paramea.a(), paramea.b(), paramea.c());
  if (paramea.e() != null)
  {
    RemoteInput[] arrayOfRemoteInput = a(paramea.e());
    int i1 = arrayOfRemoteInput.length;
    for (int i2 = 0; i2 < i1; i2++) {
      localBuilder.addRemoteInput(arrayOfRemoteInput[i2]);
    }
  }
  if (paramea.d() != null) {
    localBuilder.addExtras(paramea.d());
  }
  paramBuilder.addAction(localBuilder.build());
}
项目:365browser    文件:NotificationPlatformBridge.java   
@Nullable
static String getNotificationReply(Intent intent) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
        // RemoteInput was added in KITKAT_WATCH.
        if (intent.getStringExtra(NotificationConstants.EXTRA_NOTIFICATION_REPLY) != null) {
            // If the notification click went through the job scheduler, we will have set
            // the reply as a standard string extra.
            return intent.getStringExtra(NotificationConstants.EXTRA_NOTIFICATION_REPLY);
        }
        Bundle remoteInputResults = RemoteInput.getResultsFromIntent(intent);
        if (remoteInputResults != null) {
            CharSequence reply =
                    remoteInputResults.getCharSequence(NotificationConstants.KEY_TEXT_REPLY);
            if (reply != null) {
                return reply.toString();
            }
        }
    }
    return null;
}
项目:MyCTFWriteUps    文件:RemoteInputCompatApi20.java   
static RemoteInput[] fromCompat(RemoteInputCompatBase.RemoteInput aremoteinput[])
    {
        if (aremoteinput != null) goto _L2; else goto _L1
_L1:
        RemoteInput aremoteinput1[] = null;
_L4:
        return aremoteinput1;
_L2:
        RemoteInput aremoteinput2[] = new RemoteInput[aremoteinput.length];
        int i = 0;
        do
        {
            aremoteinput1 = aremoteinput2;
            if (i >= aremoteinput.length)
            {
                continue;
            }
            RemoteInputCompatBase.RemoteInput remoteinput = aremoteinput[i];
            aremoteinput2[i] = (new android.app.RemoteInput.Builder(remoteinput.getResultKey())).setLabel(remoteinput.getLabel()).setChoices(remoteinput.getChoices()).setAllowFreeFormInput(remoteinput.getAllowFreeFormInput()).addExtras(remoteinput.getExtras()).build();
            i++;
        } while (true);
        if (true) goto _L4; else goto _L3
_L3:
    }
项目:MyCTFWriteUps    文件:RemoteInputCompatApi20.java   
static RemoteInputCompatBase.RemoteInput[] toCompat(RemoteInput aremoteinput[], RemoteInputCompatBase.RemoteInput.Factory factory)
    {
        if (aremoteinput != null) goto _L2; else goto _L1
_L1:
        RemoteInputCompatBase.RemoteInput aremoteinput1[] = null;
_L4:
        return aremoteinput1;
_L2:
        RemoteInputCompatBase.RemoteInput aremoteinput2[] = factory.newArray(aremoteinput.length);
        int i = 0;
        do
        {
            aremoteinput1 = aremoteinput2;
            if (i >= aremoteinput.length)
            {
                continue;
            }
            RemoteInput remoteinput = aremoteinput[i];
            aremoteinput2[i] = factory.build(remoteinput.getResultKey(), remoteinput.getLabel(), remoteinput.getChoices(), remoteinput.getAllowFreeFormInput(), remoteinput.getExtras());
            i++;
        } while (true);
        if (true) goto _L4; else goto _L3
_L3:
    }
项目:adt-leanback-support    文件:RemoteInputCompatApi20.java   
static RemoteInput[] fromCompat(RemoteInputCompatBase.RemoteInput[] srcArray) {
    if (srcArray == null) {
        return null;
    }
    RemoteInput[] result = new RemoteInput[srcArray.length];
    for (int i = 0; i < srcArray.length; i++) {
        RemoteInputCompatBase.RemoteInput src = srcArray[i];
        result[i] = new RemoteInput.Builder(src.getResultKey())
                .setLabel(src.getLabel())
                .setChoices(src.getChoices())
                .setAllowFreeFormInput(src.getAllowFreeFormInput())
                .addExtras(src.getExtras())
                .build();
    }
    return result;
}
项目:IntranetEpitechV2    文件:RemoteInputCompatApi20.java   
static RemoteInput[] fromCompat(RemoteInputCompatBase.RemoteInput[] srcArray) {
    if (srcArray == null) {
        return null;
    }
    RemoteInput[] result = new RemoteInput[srcArray.length];
    for (int i = 0; i < srcArray.length; i++) {
        RemoteInputCompatBase.RemoteInput src = srcArray[i];
        result[i] = new RemoteInput.Builder(src.getResultKey())
                .setLabel(src.getLabel())
                .setChoices(src.getChoices())
                .setAllowFreeFormInput(src.getAllowFreeFormInput())
                .addExtras(src.getExtras())
                .build();
    }
    return result;
}
项目:chromium-for-android-56-debug-video    文件:NotificationPlatformBridge.java   
@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;
}
项目:boohee_v5.6    文件:NotificationCompatApi20.java   
public static void addAction(android.app.Notification.Builder b, Action action) {
    android.app.Notification.Action.Builder actionBuilder = new android.app.Notification.Action.Builder(action.getIcon(), action.getTitle(), action.getActionIntent());
    if (action.getRemoteInputs() != null) {
        for (RemoteInput remoteInput : RemoteInputCompatApi20.fromCompat(action.getRemoteInputs())) {
            actionBuilder.addRemoteInput(remoteInput);
        }
    }
    if (action.getExtras() != null) {
        actionBuilder.addExtras(action.getExtras());
    }
    b.addAction(actionBuilder.build());
}
项目:boohee_v5.6    文件:NotificationCompatApi20.java   
private static Notification.Action getActionFromActionCompat(Action actionCompat) {
    android.app.Notification.Action.Builder actionBuilder = new android.app.Notification.Action.Builder(actionCompat.getIcon(), actionCompat.getTitle(), actionCompat.getActionIntent()).addExtras(actionCompat.getExtras());
    RemoteInputCompatBase.RemoteInput[] remoteInputCompats = actionCompat.getRemoteInputs();
    if (remoteInputCompats != null) {
        for (RemoteInput remoteInput : RemoteInputCompatApi20.fromCompat(remoteInputCompats)) {
            actionBuilder.addRemoteInput(remoteInput);
        }
    }
    return actionBuilder.build();
}
项目:boohee_v5.6    文件:NotificationCompatApi20.java   
public static Action[] getActionsFromParcelableArrayList(ArrayList<Parcelable> parcelables, Factory actionFactory, RemoteInputCompatBase.RemoteInput.Factory remoteInputFactory) {
    if (parcelables == null) {
        return null;
    }
    Action[] actions = actionFactory.newArray(parcelables.size());
    for (int i = 0; i < actions.length; i++) {
        actions[i] = getActionCompatFromAction((Notification.Action) parcelables.get(i), actionFactory, remoteInputFactory);
    }
    return actions;
}
项目:permissionsModule    文件:RemoteInputCompatApi20.java   
static RemoteInputCompatBase.RemoteInput[] toCompat(RemoteInput[] srcArray,
        RemoteInputCompatBase.RemoteInput.Factory factory) {
    if (srcArray == null) {
        return null;
    }
    RemoteInputCompatBase.RemoteInput[] result = factory.newArray(srcArray.length);
    for (int i = 0; i < srcArray.length; i++) {
        RemoteInput src = srcArray[i];
        result[i] = factory.build(src.getResultKey(), src.getLabel(), src.getChoices(),
                src.getAllowFreeFormInput(), src.getExtras());
    }
    return result;
}
项目:permissionsModule    文件:NotificationCompatApi20.java   
public static void addAction(Notification.Builder b, NotificationCompatBase.Action action) {
    Notification.Action.Builder actionBuilder = new Notification.Action.Builder(
            action.getIcon(), action.getTitle(), action.getActionIntent());
    if (action.getRemoteInputs() != null) {
        for (RemoteInput remoteInput : RemoteInputCompatApi20.fromCompat(
                action.getRemoteInputs())) {
            actionBuilder.addRemoteInput(remoteInput);
        }
    }
    if (action.getExtras() != null) {
        actionBuilder.addExtras(action.getExtras());
    }
    b.addAction(actionBuilder.build());
}
项目:permissionsModule    文件:NotificationCompatApi20.java   
private static NotificationCompatBase.Action getActionCompatFromAction(
        Notification.Action action, NotificationCompatBase.Action.Factory actionFactory,
        RemoteInputCompatBase.RemoteInput.Factory remoteInputFactory) {
    RemoteInputCompatBase.RemoteInput[] remoteInputs = RemoteInputCompatApi20.toCompat(
            action.getRemoteInputs(), remoteInputFactory);
    return actionFactory.build(action.icon, action.title, action.actionIntent,
            action.getExtras(), remoteInputs);
}
项目:permissionsModule    文件:NotificationCompatApi20.java   
private static Notification.Action getActionFromActionCompat(
        NotificationCompatBase.Action actionCompat) {
    Notification.Action.Builder actionBuilder = new Notification.Action.Builder(
            actionCompat.getIcon(), actionCompat.getTitle(), actionCompat.getActionIntent())
            .addExtras(actionCompat.getExtras());
    RemoteInputCompatBase.RemoteInput[] remoteInputCompats = actionCompat.getRemoteInputs();
    if (remoteInputCompats != null) {
        RemoteInput[] remoteInputs = RemoteInputCompatApi20.fromCompat(remoteInputCompats);
        for (RemoteInput remoteInput : remoteInputs) {
            actionBuilder.addRemoteInput(remoteInput);
        }
    }
    return actionBuilder.build();
}
项目:permissionsModule    文件:NotificationCompatApi20.java   
/**
 * Get a list of notification compat actions by parsing actions stored within a list of
 * parcelables using the {@link Bundle#getParcelableArrayList} function in the same
 * manner that framework code would do so. In API20, Using Action parcelable directly
 * is correct.
 */
public static NotificationCompatBase.Action[] getActionsFromParcelableArrayList(
        ArrayList<Parcelable> parcelables,
        NotificationCompatBase.Action.Factory actionFactory,
        RemoteInputCompatBase.RemoteInput.Factory remoteInputFactory) {
    if (parcelables == null) {
        return null;
    }
    NotificationCompatBase.Action[] actions = actionFactory.newArray(parcelables.size());
    for (int i = 0; i < actions.length; i++) {
        Notification.Action action = (Notification.Action) parcelables.get(i);
        actions[i] = getActionCompatFromAction(action, actionFactory, remoteInputFactory);
    }
    return actions;
}
项目:AndroidChromium    文件:NotificationPlatformBridge.java   
@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;
}
项目:AndroidAutoTourGuide    文件:MessageReplyBroadcastReceiver.java   
@Override
public void onReceive(Context context, Intent intent) {
    Log.d ( TAG, "onReceive()..." + new Date() ) ;

    String voiceReplyContent = "No reply";

    Bundle remoteInputBundle = RemoteInput.getResultsFromIntent(intent);
    Log.d ( TAG, "onReceive() remoteInputBundle=" + remoteInputBundle ) ;
    if (remoteInputBundle != null) {
         CharSequence charSequence = remoteInputBundle.getCharSequence(EXTRA_VOICE_REPLY) ;
        voiceReplyContent = charSequence.toString() ;
    }

    Log.d ( TAG, "onReceive()... voiceReplyContent=" + voiceReplyContent ) ;

    // originate notification that will end up showing on the handheld
    Notification notification = new Notification.Builder(context)
            .setSmallIcon(R.drawable.alarm36)
            .setContentTitle("From Head unit")
            .setContentText( voiceReplyContent )
            .setColor( context.getResources().getColor(R.color.colorPrimary)).build() ;

    NotificationManager notificationManager =
            (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify( 7200, notification );

}
项目:discover-android-n    文件:MainActivity.java   
private void sendNotification() {
    // Create a reply intent sending us back to the activity
    Intent replyIntent = new Intent(this, MainActivity.class);
    // Add a notification reply intent to the task stack
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    stackBuilder.addNextIntent(replyIntent);
    // Create reply pending intent as broadcast
    PendingIntent replyPendingIntent = PendingIntent.getBroadcast(
            MainActivity.this,
            0,
            new Intent(MainActivity.this, ReplyBroadcastReceiver.class),
            PendingIntent.FLAG_UPDATE_CURRENT
    );
    // Create the remote input
    RemoteInput remoteInput = new RemoteInput.Builder(ReplyBroadcastReceiver.KEY_TEXT_REPLY)
            .setLabel("Reply")
            .build();
    // Create the reply action
    Notification.Action action =
            new Notification.Action.Builder(
                    R.drawable.ic_arrow_forward_black_24dp,
                    "Reply",
                    replyPendingIntent)
                    .addRemoteInput(remoteInput)
                    .build();
    // Build the notification
    Notification newMessageNotification =
            new Notification.Builder(this)
                    .setSmallIcon(R.drawable.ic_notifications_active_black_24dp)
                    .setContentTitle("Notification")
                    .addAction(action)
                    .build();
    // Send the notification
    NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(NOTIFICATION_ID, newMessageNotification);
}
项目:FMTech    文件:efj.java   
public static Notification.Action a(ea paramea)
{
  Notification.Action.Builder localBuilder = new Notification.Action.Builder(paramea.a(), paramea.b(), paramea.c()).addExtras(paramea.d());
  ew[] arrayOfew = paramea.e();
  if (arrayOfew != null)
  {
    RemoteInput[] arrayOfRemoteInput = a(arrayOfew);
    int i1 = arrayOfRemoteInput.length;
    for (int i2 = 0; i2 < i1; i2++) {
      localBuilder.addRemoteInput(arrayOfRemoteInput[i2]);
    }
  }
  return localBuilder.build();
}
项目:FMTech    文件:efj.java   
public static RemoteInput[] a(ew[] paramArrayOfew)
{
  if (paramArrayOfew == null) {
    return null;
  }
  RemoteInput[] arrayOfRemoteInput = new RemoteInput[paramArrayOfew.length];
  for (int i1 = 0; i1 < paramArrayOfew.length; i1++)
  {
    ew localew = paramArrayOfew[i1];
    arrayOfRemoteInput[i1] = new RemoteInput.Builder(localew.a()).setLabel(localew.b()).setChoices(localew.c()).setAllowFreeFormInput(localew.d()).addExtras(localew.e()).build();
  }
  return arrayOfRemoteInput;
}
项目:kdeconnect-android    文件:NotificationsPlugin.java   
@RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
private void getDetailsOfNotification(RemoteInput remoteInput) {
    //Some more details of RemoteInput... no idea what for but maybe it will be useful at some point
    String resultKey = remoteInput.getResultKey();
    String label = remoteInput.getLabel().toString();
    Boolean canFreeForm = remoteInput.getAllowFreeFormInput();
    if (remoteInput.getChoices() != null && remoteInput.getChoices().length > 0) {
        String[] possibleChoices = new String[remoteInput.getChoices().length];
        for (int i = 0; i < remoteInput.getChoices().length; i++) {
            possibleChoices[i] = remoteInput.getChoices()[i].toString();
        }
    }
}
项目:Capitolo6    文件:MainActivity.java   
@Override
protected void onResume() {
    super.onResume();
    if (getIntent() != null) {
        Bundle inputResults = RemoteInput.getResultsFromIntent(getIntent());
        if (inputResults != null) {
            CharSequence replyText = inputResults.getCharSequence(KEY_REPLY);
            if (replyText != null) {
                Toast.makeText(this, TextUtils.concat(getString(R.string.reply_was), replyText),
                        Toast.LENGTH_LONG).show();
            }
        }
    }
}
项目:Capitolo6    文件:NotificationPresets.java   
@Override
public Notification buildNotification(Context context) {
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
            new Intent(context, MainActivity.class), 0);

    Notification page2 = buildBasicNotification(context)
            .extend(new Notification.WearableExtender()
                    .setHintShowBackgroundOnly(true)
                    .setBackground(BitmapFactory.decodeResource(context.getResources(),
                            R.drawable.example_big_picture)))
            .build();

    Notification page3 = buildBasicNotification(context)
            .setContentTitle(context.getString(R.string.third_page))
            .setContentText(null)
            .extend(new Notification.WearableExtender()
                    .setContentAction(0 /* action A */))
            .build();

    SpannableStringBuilder choice2 = new SpannableStringBuilder(
            "This choice is best");
    choice2.setSpan(new StyleSpan(Typeface.BOLD_ITALIC), 5, 11, 0);

    return buildBasicNotification(context)
            .extend(new Notification.WearableExtender()
                    .addAction(new Notification.Action(R.mipmap.ic_launcher,
                            context.getString(R.string.action_a), pendingIntent))
                    .addAction(new Notification.Action.Builder(R.mipmap.ic_launcher,
                            context.getString(R.string.reply), pendingIntent)
                            .addRemoteInput(new RemoteInput.Builder(MainActivity.KEY_REPLY)
                                    .setChoices(new CharSequence[] {
                                            context.getString(R.string.choice_1),
                                            choice2 })
                                    .build())
                            .build())
                    .addPage(page2)
                    .addPage(page3))
            .build();
}
项目:MyCTFWriteUps    文件:NotificationCompatApi21.java   
static Bundle getBundleForUnreadConversation(NotificationCompatBase.UnreadConversation unreadconversation)
{
    if (unreadconversation == null)
    {
        return null;
    }
    Bundle bundle = new Bundle();
    Parcelable aparcelable[] = null;
    Object obj = aparcelable;
    if (unreadconversation.getParticipants() != null)
    {
        obj = aparcelable;
        if (unreadconversation.getParticipants().length > 1)
        {
            obj = unreadconversation.getParticipants()[0];
        }
    }
    aparcelable = new Parcelable[unreadconversation.getMessages().length];
    for (int i = 0; i < aparcelable.length; i++)
    {
        Bundle bundle1 = new Bundle();
        bundle1.putString("text", unreadconversation.getMessages()[i]);
        bundle1.putString("author", ((String) (obj)));
        aparcelable[i] = bundle1;
    }

    bundle.putParcelableArray("messages", aparcelable);
    obj = unreadconversation.getRemoteInput();
    if (obj != null)
    {
        bundle.putParcelable("remote_input", fromCompatRemoteInput(((RemoteInputCompatBase.RemoteInput) (obj))));
    }
    bundle.putParcelable("on_reply", unreadconversation.getReplyPendingIntent());
    bundle.putParcelable("on_read", unreadconversation.getReadPendingIntent());
    bundle.putStringArray("participants", unreadconversation.getParticipants());
    bundle.putLong("timestamp", unreadconversation.getLatestTimestamp());
    return bundle;
}
项目:adt-leanback-support    文件:RemoteInputCompatApi20.java   
static RemoteInputCompatBase.RemoteInput[] toCompat(RemoteInput[] srcArray,
        RemoteInputCompatBase.RemoteInput.Factory factory) {
    if (srcArray == null) {
        return null;
    }
    RemoteInputCompatBase.RemoteInput[] result = factory.newArray(srcArray.length);
    for (int i = 0; i < srcArray.length; i++) {
        RemoteInput src = srcArray[i];
        result[i] = factory.build(src.getResultKey(), src.getLabel(), src.getChoices(),
                src.getAllowFreeFormInput(), src.getExtras());
    }
    return result;
}
项目:adt-leanback-support    文件:NotificationCompatApi20.java   
public static void addAction(Notification.Builder b, NotificationCompatBase.Action action) {
    Notification.Action.Builder actionBuilder = new Notification.Action.Builder(
            action.getIcon(), action.getTitle(), action.getActionIntent());
    if (action.getRemoteInputs() != null) {
        for (RemoteInput remoteInput : RemoteInputCompatApi20.fromCompat(
                action.getRemoteInputs())) {
            actionBuilder.addRemoteInput(remoteInput);
        }
    }
    if (action.getExtras() != null) {
        actionBuilder.addExtras(action.getExtras());
    }
    b.addAction(actionBuilder.build());
}
项目:adt-leanback-support    文件:NotificationCompatApi20.java   
private static NotificationCompatBase.Action getActionCompatFromAction(
        Notification.Action action, NotificationCompatBase.Action.Factory actionFactory,
        RemoteInputCompatBase.RemoteInput.Factory remoteInputFactory) {
    RemoteInputCompatBase.RemoteInput[] remoteInputs = RemoteInputCompatApi20.toCompat(
            action.getRemoteInputs(), remoteInputFactory);
    return actionFactory.build(action.icon, action.title, action.actionIntent,
            action.getExtras(), remoteInputs);
}
项目:adt-leanback-support    文件:NotificationCompatApi20.java   
private static Notification.Action getActionFromActionCompat(
        NotificationCompatBase.Action actionCompat) {
    Notification.Action.Builder actionBuilder = new Notification.Action.Builder(
            actionCompat.getIcon(), actionCompat.getTitle(), actionCompat.getActionIntent())
            .addExtras(actionCompat.getExtras());
    RemoteInputCompatBase.RemoteInput[] remoteInputCompats = actionCompat.getRemoteInputs();
    if (remoteInputCompats != null) {
        RemoteInput[] remoteInputs = RemoteInputCompatApi20.fromCompat(remoteInputCompats);
        for (RemoteInput remoteInput : remoteInputs) {
            actionBuilder.addRemoteInput(remoteInput);
        }
    }
    return actionBuilder.build();
}
项目:adt-leanback-support    文件:NotificationCompatApi20.java   
/**
 * Get a list of notification compat actions by parsing actions stored within a list of
 * parcelables using the {@link Bundle#getParcelableArrayList} function in the same
 * manner that framework code would do so. In API20, Using Action parcelable directly
 * is correct.
 */
public static NotificationCompatBase.Action[] getActionsFromParcelableArrayList(
        ArrayList<Parcelable> parcelables,
        NotificationCompatBase.Action.Factory actionFactory,
        RemoteInputCompatBase.RemoteInput.Factory remoteInputFactory) {
    if (parcelables == null) {
        return null;
    }
    NotificationCompatBase.Action[] actions = actionFactory.newArray(parcelables.size());
    for (int i = 0; i < actions.length; i++) {
        Notification.Action action = (Notification.Action) parcelables.get(i);
        actions[i] = getActionCompatFromAction(action, actionFactory, remoteInputFactory);
    }
    return actions;
}
项目:AndroidWearable-Samples    文件:MainActivity.java   
@Override
protected void onResume() {
    super.onResume();
    if (getIntent() != null) {
        Bundle inputResults = RemoteInput.getResultsFromIntent(getIntent());
        if (inputResults != null) {
            CharSequence replyText = inputResults.getCharSequence(KEY_REPLY);
            if (replyText != null) {
                Toast.makeText(this, TextUtils.concat(getString(R.string.reply_was), replyText),
                        Toast.LENGTH_LONG).show();
            }
        }
    }
}
项目:AndroidWearable-Samples    文件:NotificationPresets.java   
@Override
public Notification buildNotification(Context context) {
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
            new Intent(context, MainActivity.class), 0);

    Notification page2 = buildBasicNotification(context)
            .extend(new Notification.WearableExtender()
                    .setHintShowBackgroundOnly(true)
                    .setBackground(BitmapFactory.decodeResource(context.getResources(),
                            R.drawable.example_big_picture)))
            .build();

    Notification page3 = buildBasicNotification(context)
            .setContentTitle(context.getString(R.string.third_page))
            .setContentText(null)
            .extend(new Notification.WearableExtender()
                    .setContentAction(0 /* action A */))
            .build();

    SpannableStringBuilder choice2 = new SpannableStringBuilder(
            "This choice is best");
    choice2.setSpan(new StyleSpan(Typeface.BOLD_ITALIC), 5, 11, 0);

    return buildBasicNotification(context)
            .extend(new Notification.WearableExtender()
                    .addAction(new Notification.Action(R.mipmap.ic_launcher,
                            context.getString(R.string.action_a), pendingIntent))
                    .addAction(new Notification.Action.Builder(R.mipmap.ic_launcher,
                            context.getString(R.string.reply), pendingIntent)
                            .addRemoteInput(new RemoteInput.Builder(MainActivity.KEY_REPLY)
                                    .setChoices(new CharSequence[] {
                                            context.getString(R.string.choice_1),
                                            choice2 })
                                    .build())
                            .build())
                    .addPage(page2)
                    .addPage(page3))
            .build();
}
项目:notifications-android-L    文件:VoiceInputResultActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_voice_input_result);

    tvResult = (TextView) findViewById(R.id.tv_activity_voice_input_result);

    Bundle remoteInput = RemoteInput.getResultsFromIntent(getIntent());
    if(remoteInput!=null){
        CharSequence result = remoteInput.getCharSequence(KEY_VOICE_INPUT);
        tvResult.setText(result);
    }
}
项目:android-Notifications    文件:MainActivity.java   
@Override
protected void onResume() {
    super.onResume();
    if (getIntent() != null) {
        Bundle inputResults = RemoteInput.getResultsFromIntent(getIntent());
        if (inputResults != null) {
            CharSequence replyText = inputResults.getCharSequence(KEY_REPLY);
            if (replyText != null) {
                Toast.makeText(this, TextUtils.concat(getString(R.string.reply_was), replyText),
                        Toast.LENGTH_LONG).show();
            }
        }
    }
}
项目:android-Notifications    文件:NotificationPresets.java   
@Override
public Notification buildNotification(Context context) {
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
            new Intent(context, MainActivity.class), 0);

    Notification page2 = buildBasicNotification(context)
            .extend(new Notification.WearableExtender()
                    .setHintShowBackgroundOnly(true)
                    .setBackground(BitmapFactory.decodeResource(context.getResources(),
                            R.drawable.example_big_picture)))
            .build();

    Notification page3 = buildBasicNotification(context)
            .setContentTitle(context.getString(R.string.third_page))
            .setContentText(null)
            .extend(new Notification.WearableExtender()
                    .setContentAction(0 /* action A */))
            .build();

    SpannableStringBuilder choice2 = new SpannableStringBuilder(
            "This choice is best");
    choice2.setSpan(new StyleSpan(Typeface.BOLD_ITALIC), 5, 11, 0);

    return buildBasicNotification(context)
            .extend(new Notification.WearableExtender()
                    .addAction(new Notification.Action(R.mipmap.ic_launcher,
                            context.getString(R.string.action_a), pendingIntent))
                    .addAction(new Notification.Action.Builder(R.mipmap.ic_launcher,
                            context.getString(R.string.reply), pendingIntent)
                            .addRemoteInput(new RemoteInput.Builder(MainActivity.KEY_REPLY)
                                    .setChoices(new CharSequence[] {
                                            context.getString(R.string.choice_1),
                                            choice2 })
                                    .build())
                            .build())
                    .addPage(page2)
                    .addPage(page3))
            .build();
}