Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为应用程序创建android锁屏小部件/通知_Android_Lockscreen - Fatal编程技术网

为应用程序创建android锁屏小部件/通知

为应用程序创建android锁屏小部件/通知,android,lockscreen,Android,Lockscreen,我见过很多应用程序都这么做。我想到了Lux,还有音乐播放器应用程序和其他应用程序。它们在锁屏上显示一个通知,该通知具有可与之交互的功能。我读到锁屏小部件在5.0+上被删除,但我仍然看到这些应用程序创建了这些锁屏功能 我是Android开发新手,所以可能对术语感到困惑。我在哪里可以找到关于如何创建这种类型的锁屏功能的信息。嗨,可以使用Android的一部分来完成 这部分代码用于拦截媒体控件 @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) pub

我见过很多应用程序都这么做。我想到了Lux,还有音乐播放器应用程序和其他应用程序。它们在锁屏上显示一个通知,该通知具有可与之交互的功能。我读到锁屏小部件在5.0+上被删除,但我仍然看到这些应用程序创建了这些锁屏功能

我是Android开发新手,所以可能对术语感到困惑。我在哪里可以找到关于如何创建这种类型的锁屏功能的信息。

嗨,可以使用Android的一部分来完成 这部分代码用于拦截媒体控件

@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);
}

}

太好了,这是一个很好的起点。正是我需要的。谢谢Thanxx@Marcelo Mason