【问题标题】:Image background behind "Notifications"“通知”背后的图片背景
【发布时间】:2016-03-18 06:21:36
【问题描述】:

快速解释: 问题:将图像放在通知列表后面的背景中...... 我试过了:用一张大图,但这不是我想要的......

嗯,我看到了一个自定义通知的应用程序,如下所示...

我想要一个自定义背景,但我不知道该怎么做,我找到了其他示例,但我解释了如何更改通知,如自定义、背景、按钮、图标等。但我没有找到具体的解决方案...

我找到的链接:

android lollipop notification background colour

Change Notification Layout

我会为你提供帮助。

【问题讨论】:

    标签: android image background notifications


    【解决方案1】:
    /**
    * Set up the remote control and tell the system we want to be the default receiver for the MEDIA buttons
    * @see http://android-developers.blogspot.fr/2010/06/allowing-applications-to-play-nicer.html
    */
    @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
    public void setUpRemoteControlClient() {
    Context context = VLCApplication.getAppContext();
    AudioManager audioManager = (AudioManager)context.getSystemService(AUDIO_SERVICE);
    
    if(Util.isICSOrLater()) {
        audioManager.registerMediaButtonEventReceiver(mRemoteControlClientReceiverComponent);
    
        if (mRemoteControlClient == null) {
            Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
            mediaButtonIntent.setComponent(mRemoteControlClientReceiverComponent);
            PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(context, 0, mediaButtonIntent, 0);
    
            // create and register the remote control client
            mRemoteControlClient = new RemoteControlClient(mediaPendingIntent);
            audioManager.registerRemoteControlClient(mRemoteControlClient);
        }
    
        mRemoteControlClient.setTransportControlFlags(
                RemoteControlClient.FLAG_KEY_MEDIA_PLAY |
                RemoteControlClient.FLAG_KEY_MEDIA_PAUSE |
                RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS |
                RemoteControlClient.FLAG_KEY_MEDIA_NEXT |
                RemoteControlClient.FLAG_KEY_MEDIA_STOP);
    } else if (Util.isFroyoOrLater()) {
        audioManager.registerMediaButtonEventReceiver(mRemoteControlClientReceiverComponent);
        }
    }
    

    这部分是为了更新艺术品,以及其他信息:

    @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
    private void updateRemoteControlClientMetadata() {
    if(!Util.isICSOrLater()) // NOP check
        return;
    
    if (mRemoteControlClient != null) {
        MetadataEditor editor = mRemoteControlClient.editMetadata(true);
        editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, getCurrentMedia().getAlbum());
        editor.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, getCurrentMedia().getArtist());
        editor.putString(MediaMetadataRetriever.METADATA_KEY_GENRE, getCurrentMedia().getGenre());
        editor.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, getCurrentMedia().getTitle());
        editor.putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, getCurrentMedia().getLength());
        editor.putBitmap(MetadataEditor.BITMAP_KEY_ARTWORK, getCover());
        editor.apply();
    }
    }
    

    【讨论】:

      【解决方案2】:

      它是媒体控制器应用吗?

      因为: 您想要的解决方案仅适用于已将自身注册为媒体控制器的应用程序,因此不播放音频的应用程序不能/不应使用此机制来更改锁屏壁纸。

      【讨论】:

      • 是的,它是一个媒体应用程序,它是 deezer 应用程序,那么,我不能在我的应用程序中这样做吗?...
      • 可以使用 RemoteControlClient 来完成,它是自 ICS 以来 Android 的一部分。如果您想要一个工作示例,请下载 VLC for Android 并查看 org.videolan.vlc.AudioService:这部分代码是拦截媒体控件。
      猜你喜欢
      • 2013-08-16
      • 1970-01-01
      • 2014-08-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多