當前位置: 首頁>>代碼示例>>Java>>正文


Java RemoteInput類代碼示例

本文整理匯總了Java中android.support.v4.app.RemoteInput的典型用法代碼示例。如果您正苦於以下問題:Java RemoteInput類的具體用法?Java RemoteInput怎麽用?Java RemoteInput使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RemoteInput類屬於android.support.v4.app包,在下文中一共展示了RemoteInput類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onReceive

import android.support.v4.app.RemoteInput; //導入依賴的package包/類
@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);
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:20,代碼來源:WearReplyReceiver.java

示例2: onStartCommand

import android.support.v4.app.RemoteInput; //導入依賴的package包/類
@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;
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:20,代碼來源:SendService.java

示例3: addAndroidAutoAction

import android.support.v4.app.RemoteInput; //導入依賴的package包/類
public void addAndroidAutoAction(@NonNull PendingIntent androidAutoReplyIntent,
                                 @NonNull PendingIntent androidAutoHeardIntent, long timestamp)
{

  if (mContentTitle == null || mContentText == null)
    return;

  RemoteInput remoteInput = new RemoteInput.Builder(AndroidAutoReplyReceiver.VOICE_REPLY_KEY)
                                .setLabel(context.getString(R.string.MessageNotifier_reply))
                                .build();

  NotificationCompat.CarExtender.UnreadConversation.Builder unreadConversationBuilder =
          new NotificationCompat.CarExtender.UnreadConversation.Builder(mContentTitle.toString())
              .addMessage(mContentText.toString())
              .setLatestTimestamp(timestamp)
              .setReadPendingIntent(androidAutoHeardIntent)
              .setReplyAction(androidAutoReplyIntent, remoteInput);

  extend(new NotificationCompat.CarExtender().setUnreadConversation(unreadConversationBuilder.build()));
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:21,代碼來源:SingleRecipientNotificationBuilder.java

示例4: createInlineReply

import android.support.v4.app.RemoteInput; //導入依賴的package包/類
@TargetApi(Build.VERSION_CODES.N)
private static void createInlineReply(
        Context ctx, NotificationCompat.Builder builder, NotificationEntity entity) {
    RemoteInput remoteInput = new RemoteInput.Builder(Constants.EXTRA_COMMENT)
            .setLabel(ctx.getString(R.string.change_details_review_hint))
            .setAllowFreeFormInput(true)
            .build();
    NotificationCompat.Action action =
            new NotificationCompat.Action.Builder(
                    R.drawable.ic_send,
                    ctx.getString(R.string.action_reply),
                    getReplyPendingIntent(ctx, entity))
            .addRemoteInput(remoteInput)
            .setAllowGeneratedReplies(false)
            .build();
    builder.addAction(action);
}
 
開發者ID:jruesga,項目名稱:rview,代碼行數:18,代碼來源:NotificationsHelper.java

示例5: replyToNotification

import android.support.v4.app.RemoteInput; //導入依賴的package包/類
private void replyToNotification(Context context, Intent intent) {
    Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
    final int changeId = intent.getIntExtra(Constants.EXTRA_LEGACY_CHANGE_ID, -1);
    final String accountId = intent.getStringExtra(Constants.EXTRA_ACCOUNT_HASH);
    final int groupId = intent.getIntExtra(Constants.EXTRA_NOTIFICATION_GROUP_ID, 0);
    if (remoteInput != null && groupId != 0 && changeId >= 0 && accountId != null) {
        final Account account = ModelHelper.getAccountFromHash(context, accountId);
        if (account == null) {
            return;
        }

        CharSequence message = remoteInput.getCharSequence(Constants.EXTRA_COMMENT);
        if (message == null) {
            return;
        }

        performSendReply(context, account, groupId, changeId, message.toString());
    } else {
        // What happens here? Dismiss the notification in case, but don't mark as read
        NotificationsHelper.dismissNotification(context, groupId);
        NotificationEntity.dismissGroupNotifications(context, groupId);
    }
}
 
開發者ID:jruesga,項目名稱:rview,代碼行數:24,代碼來源:NotificationReceiver.java

示例6: onCreate

import android.support.v4.app.RemoteInput; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_wearable_replay);

    CharSequence replayString;

    //get the voice replays from the remote input.
    Bundle bundle = RemoteInput.getResultsFromIntent(getIntent());
    if (bundle != null) {
        replayString = bundle.getCharSequence(WearableNotification.REMOTE_INPUT_LABEL);
    } else {
        replayString = "No replay from the response.";
    }

    Toast.makeText(this, replayString, Toast.LENGTH_LONG).show();

    finish();
}
 
開發者ID:kevalpatel2106,項目名稱:android-samples,代碼行數:20,代碼來源:WearableReplayActivity.java

示例7: onReceive

import android.support.v4.app.RemoteInput; //導入依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {

    if (intent != null) {
        Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
        if (remoteInput != null) {
            //入力データを取得
            String value = (String) remoteInput.getCharSequence(KEY_DIRECT_REPLY);
            Toast.makeText(context, value, Toast.LENGTH_SHORT).show();

            //通知に反映して更新
            ArrayList<String> history = new ArrayList<>();
            history.add("コメント:" + value);
            NotiUtils.createNoti(context, history);
        }
    }
}
 
開發者ID:yokmama,項目名稱:honki_android2,代碼行數:18,代碼來源:NotiBroadcastReceiver.java

示例8: onConnect

import android.support.v4.app.RemoteInput; //導入依賴的package包/類
@Override
public void onConnect(@Nullable String message) {
    if (message != null) {
        Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
    } else {
        Intent intent = new Intent(this, HomeActivity.class);

        if (getIntent().hasExtra(HomeActivity.EXTRA_CHANNEL_ID))
            intent.putExtra(HomeActivity.EXTRA_CHANNEL_ID, getIntent().getStringExtra(HomeActivity.EXTRA_CHANNEL_ID));

        if (getIntent().hasExtra(HomeActivity.EXTRA_INSTANT_ID))
            intent.putExtra(HomeActivity.EXTRA_INSTANT_ID, getIntent().getStringExtra(HomeActivity.EXTRA_INSTANT_ID));

        Bundle remoteInput = RemoteInput.getResultsFromIntent(getIntent());
        if (remoteInput != null) {
            intent.putExtra(BaseMessageFragment.EXTRA_REPLY, remoteInput.getCharSequence(BaseMessageFragment.EXTRA_REPLY, "").toString());
            Log.d("RemoteInput", remoteInput.getCharSequence(BaseMessageFragment.EXTRA_REPLY, "").toString());
        }

        startActivity(intent);
    }

    finish();
}
 
開發者ID:DoubleDotLabs,項目名稱:ButterySlack,代碼行數:25,代碼來源:MainActivity.java

示例9: onReceive

import android.support.v4.app.RemoteInput; //導入依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
    QiscusComment comment = intent.getParcelableExtra("data");
    Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
    if (remoteInput != null) {
        CharSequence message = remoteInput.getCharSequence(QiscusPushNotificationUtil.KEY_NOTIFICATION_REPLY);
        NotificationManager notificationManager = (NotificationManager) context.getSystemService(
                Context.NOTIFICATION_SERVICE);
        if (notificationManager != null) {
            notificationManager.cancel(comment.getRoomId());
        }
        QiscusComment qiscusComment = QiscusComment.generateMessage((String) message, comment.getRoomId(), comment.getTopicId());
        Qiscus.getChatConfig().getReplyNotificationHandler().onSend(context, qiscusComment);
    } else {
        Qiscus.getChatConfig().getNotificationClickListener().onClick(context, comment);
    }
}
 
開發者ID:qiscus,項目名稱:qiscus-sdk-android,代碼行數:18,代碼來源:QiscusPushNotificationClickReceiver.java

示例10: createAndroidNotificationAction

import android.support.v4.app.RemoteInput; //導入依賴的package包/類
@NonNull
private NotificationCompat.Action createAndroidNotificationAction(NotificationAction notificationAction, PendingIntent pendingIntent) {
    NotificationCompat.Action.Builder builder = new NotificationCompat.Action.Builder(
            notificationAction.getIcon(),
            context.getString(notificationAction.getTitleResourceId()),
            pendingIntent);

    if (notificationAction.hasInput()) {
        RemoteInput.Builder inputBuilder = new RemoteInput.Builder(notificationAction.getId());
        if (notificationAction.getInputLabelResourceId() > 0) {
            inputBuilder.setLabel(context.getString(notificationAction.getInputLabelResourceId()));
        }
        builder.addRemoteInput(inputBuilder.build());
    }

    return builder.build();
}
 
開發者ID:infobip,項目名稱:mobile-messaging-sdk-android,代碼行數:18,代碼來源:InteractiveNotificationHandler.java

示例11: onReceive

import android.support.v4.app.RemoteInput; //導入依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
    switch (intent.getAction()) {
        case GBApplication.ACTION_QUIT: {
            finish();
            break;
        }
        case ACTION_REPLY: {
            Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
            CharSequence reply = remoteInput.getCharSequence(EXTRA_REPLY);
            LOG.info("got wearable reply: " + reply);
            GB.toast(context, "got wearable reply: " + reply, Toast.LENGTH_SHORT, GB.INFO);
            break;
        }
        case DeviceService.ACTION_HEARTRATE_MEASUREMENT: {
            int hrValue = intent.getIntExtra(DeviceService.EXTRA_HEART_RATE_VALUE, -1);
            GB.toast(DebugActivity.this, "Heart Rate measured: " + hrValue, Toast.LENGTH_LONG, GB.INFO);
            break;
        }
    }
}
 
開發者ID:scifiswapnil,項目名稱:gadgetbridge_artikcloud,代碼行數:22,代碼來源:DebugActivity.java

示例12: fireNotification

import android.support.v4.app.RemoteInput; //導入依賴的package包/類
private void fireNotification() {

        RemoteInput remoteInput = new RemoteInput.Builder(MyRemoteInputBroadcastReceiver.VOICE_INPUT_KEY).
                setLabel( getResources().getString( R.string.app_name)).build() ;

        NotificationCompat.Action wearRemoteInputAction =  new NotificationCompat.Action
                .Builder ( R.drawable.ic_launcher, "Speak", remoteInputPendingIntent)
                .addRemoteInput(remoteInput).build() ;


        NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender();
        wearableExtender.addAction(  wearRemoteInputAction) ;

        Notification notification =
                new NotificationCompat.Builder(this)
                        .setContentTitle(getResources().getString(R.string.app_name))
                        .setContentText(getResources().getString(R.string.notification_text))
                        .setSmallIcon(R.drawable.ic_notification)
                        .extend(wearableExtender)
                        .setColor(getResources().getColor(R.color.colorPrimary))
                        .build();

        NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
        notificationManager.notify(NOTIFICATION_ID, notification);

    }
 
開發者ID:smitzey,項目名稱:wearbooksource,代碼行數:27,代碼來源:NotiVoiceActivity.java

示例13: onReceive

import android.support.v4.app.RemoteInput; //導入依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
    Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
    Bundle bundle = intent.getExtras();
    if (remoteInput != null && bundle != null) {
        if (intent.getAction().equals(ACTION_REPLY)) {

            Message message = new Message(
                    remoteInput.getCharSequence(EXTRA_VOICE_REPLY).toString(),
                    new String[]{bundle.getString(EXTRA_ADDRESS)}
            );

            Transaction sendTransaction = new Transaction(context, SmsHelper.getSendSettings(context));
            sendTransaction.sendNewMessage(message, bundle.getLong(EXTRA_THREAD_ID));

            Intent i = new Intent(context, MarkReadService.class);
            i.putExtra(EXTRA_THREAD_ID, bundle.getLong(EXTRA_THREAD_ID));
            context.startService(i);
        }
    }
}
 
開發者ID:moezbhatti,項目名稱:qksms,代碼行數:22,代碼來源:RemoteMessagingReceiver.java

示例14: getReplyAction

import android.support.v4.app.RemoteInput; //導入依賴的package包/類
public static NotificationCompat.Action getReplyAction(Context context, String address, long threadId) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

    Intent replyIntent = new Intent(ACTION_REPLY).setClass(context, RemoteMessagingReceiver.class);
    replyIntent.putExtra(EXTRA_ADDRESS, address);
    replyIntent.putExtra(EXTRA_THREAD_ID, threadId);

    Set<String> defaultResponses = new HashSet<>(Arrays.asList(context.getResources().getStringArray(R.array.qk_responses)));
    Set<String> responseSet = prefs.getStringSet(SettingsFragment.QK_RESPONSES, defaultResponses);
    ArrayList<String> responses = new ArrayList<>();
    responses.addAll(responseSet);
    Collections.sort(responses);

    PendingIntent replyPI = PendingIntent.getBroadcast(context, 0, replyIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY)
            .setLabel(context.getString(R.string.reply))
            .setChoices(responses.toArray(new String[responses.size()]))
            .build();

    return new NotificationCompat.Action.Builder(
            R.drawable.ic_reply,
            context.getString(R.string.reply), replyPI)
            .addRemoteInput(remoteInput)
            .build();
}
 
開發者ID:moezbhatti,項目名稱:qksms,代碼行數:26,代碼來源:RemoteMessagingReceiver.java

示例15: processPushBundle

import android.support.v4.app.RemoteInput; //導入依賴的package包/類
/**
 * Takes the pushBundle extras from the intent,
 * and sends it through to the PushPlugin for processing.
 */
private boolean processPushBundle(boolean isPushPluginActive, Intent intent) {
    Bundle extras = getIntent().getExtras();
    Bundle remoteInput = null;

    if (extras != null) {
        Bundle originalExtras = extras.getBundle(PUSH_BUNDLE);

        originalExtras.putBoolean(FOREGROUND, false);
        originalExtras.putBoolean(COLDSTART, !isPushPluginActive);
        originalExtras.putBoolean(DISMISSED, extras.getBoolean(DISMISSED));
        originalExtras.putString(ACTION_CALLBACK, extras.getString(CALLBACK));
        originalExtras.remove(NO_CACHE);

        remoteInput = RemoteInput.getResultsFromIntent(intent);
        if (remoteInput != null) {
            String inputString = remoteInput.getCharSequence(INLINE_REPLY).toString();
            Log.d(LOG_TAG, "response: " + inputString);
            originalExtras.putString(INLINE_REPLY, inputString);
        }

        PushPlugin.sendExtras(originalExtras);
    }
    return remoteInput == null;
}
 
開發者ID:phonegap,項目名稱:phonegap-plugin-push,代碼行數:29,代碼來源:PushHandlerActivity.java


注:本文中的android.support.v4.app.RemoteInput類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。