<bdo id='l3ZMM'></bdo><ul id='l3ZMM'></ul>
    1. <tfoot id='l3ZMM'></tfoot>
    2. <legend id='l3ZMM'><style id='l3ZMM'><dir id='l3ZMM'><q id='l3ZMM'></q></dir></style></legend>

        <i id='l3ZMM'><tr id='l3ZMM'><dt id='l3ZMM'><q id='l3ZMM'><span id='l3ZMM'><b id='l3ZMM'><form id='l3ZMM'><ins id='l3ZMM'></ins><ul id='l3ZMM'></ul><sub id='l3ZMM'></sub></form><legend id='l3ZMM'></legend><bdo id='l3ZMM'><pre id='l3ZMM'><center id='l3ZMM'></center></pre></bdo></b><th id='l3ZMM'></th></span></q></dt></tr></i><div id='l3ZMM'><tfoot id='l3ZMM'></tfoot><dl id='l3ZMM'><fieldset id='l3ZMM'></fieldset></dl></div>

      1. <small id='l3ZMM'></small><noframes id='l3ZMM'>

        如何在android中的通知中添加按钮?

        时间:2023-09-08

        <small id='J8lHD'></small><noframes id='J8lHD'>

          <tbody id='J8lHD'></tbody>

        • <i id='J8lHD'><tr id='J8lHD'><dt id='J8lHD'><q id='J8lHD'><span id='J8lHD'><b id='J8lHD'><form id='J8lHD'><ins id='J8lHD'></ins><ul id='J8lHD'></ul><sub id='J8lHD'></sub></form><legend id='J8lHD'></legend><bdo id='J8lHD'><pre id='J8lHD'><center id='J8lHD'></center></pre></bdo></b><th id='J8lHD'></th></span></q></dt></tr></i><div id='J8lHD'><tfoot id='J8lHD'></tfoot><dl id='J8lHD'><fieldset id='J8lHD'></fieldset></dl></div>
          • <tfoot id='J8lHD'></tfoot>

                  <bdo id='J8lHD'></bdo><ul id='J8lHD'></ul>
                  <legend id='J8lHD'><style id='J8lHD'><dir id='J8lHD'><q id='J8lHD'></q></dir></style></legend>
                  本文介绍了如何在android中的通知中添加按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的应用播放音乐,当用户通过从屏幕顶部(或通常从平板电脑屏幕的右下角)滑动打开通知屏幕时,我想向他们展示一个按钮来停止当前播放的音乐并开始如果他们愿意,可以再做一次.

                  My app plays music and when users open notifications screen by swiping from the top of the screen ( or generally from the bottom right of the screen on tablets ), I want to present them a button to stop the currently playing music and start it again if they want.

                  我不打算将小部件放在用户的主屏幕上,而只是放在通知中.我该怎么做?

                  I am not planning to put a widget on the user's home screen, but just into notifications. How can I do this?

                  推荐答案

                  您可以为动作创建一个意图(在这种情况下停止播放),然后将其作为动作按钮添加到您的通知中.

                  You can create an intent for the action (in this case stop playing) and then add it as an action button to your notification.

                  Intent snoozeIntent = new Intent(this, MyBroadcastReceiver.class);
                  snoozeIntent.setAction(ACTION_SNOOZE);
                  snoozeIntent.putExtra(EXTRA_NOTIFICATION_ID, 0);
                  PendingIntent snoozePendingIntent =
                          PendingIntent.getBroadcast(this, 0, snoozeIntent, 0);
                  
                  NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this, CHANNEL_ID)
                          .setSmallIcon(R.drawable.notification_icon)
                          .setContentTitle("My notification")
                          .setContentText("Hello World!")
                          .setPriority(NotificationCompat.PRIORITY_DEFAULT)
                          .setContentIntent(pendingIntent)
                          .addAction(R.drawable.ic_snooze, getString(R.string.snooze),
                                  snoozePendingIntent);
                  

                  请参阅Android 文档.

                  这篇关于如何在android中的通知中添加按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 Android Widget 上处理多个按钮单击 下一篇:待处理意图的多个实例

                  相关文章

                • <i id='4ByH3'><tr id='4ByH3'><dt id='4ByH3'><q id='4ByH3'><span id='4ByH3'><b id='4ByH3'><form id='4ByH3'><ins id='4ByH3'></ins><ul id='4ByH3'></ul><sub id='4ByH3'></sub></form><legend id='4ByH3'></legend><bdo id='4ByH3'><pre id='4ByH3'><center id='4ByH3'></center></pre></bdo></b><th id='4ByH3'></th></span></q></dt></tr></i><div id='4ByH3'><tfoot id='4ByH3'></tfoot><dl id='4ByH3'><fieldset id='4ByH3'></fieldset></dl></div>

                  <small id='4ByH3'></small><noframes id='4ByH3'>

                      <bdo id='4ByH3'></bdo><ul id='4ByH3'></ul>

                      <tfoot id='4ByH3'></tfoot>

                      <legend id='4ByH3'><style id='4ByH3'><dir id='4ByH3'><q id='4ByH3'></q></dir></style></legend>