Most visited

Recently visited

Added in API level 23

MidiDeviceService

public abstract class MidiDeviceService
extends Service

java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.app.Service
         ↳ android.media.midi.MidiDeviceService


一种实现虚拟MIDI设备的服务。 子类必须实现onGetInputPortReceivers()方法,以提供MidiReceiver的列表来接收发送到设备输入端口的数据。 类似地,子类可以调用getOutputPortReceivers()来获取用于从输出端口发送数据的MidiReceiver的列表。

为了扩展这个类,你必须在manifest文件中声明这个服务,使用一个带有SERVICE_INTERFACE操作的意图过滤器和元数据来描述这个虚拟设备。 例如:

 <service android:name=".VirtualDeviceService"
          android:label="@string/service_name">
     <intent-filter>
         <action android:name="android.media.midi.MidiDeviceService" />
     </intent-filter>
           <meta-data android:name="android.media.midi.MidiDeviceService"
                android:resource="@xml/device_info" />
 </service>

Summary

Constants

String SERVICE_INTERFACE

Inherited constants

From class android.app.Service
From class android.content.Context
From interface android.content.ComponentCallbacks2

Public constructors

MidiDeviceService()

Public methods

final MidiDeviceInfo getDeviceInfo()

返回此服务的 MidiDeviceInfo实例

final MidiReceiver[] getOutputPortReceivers()

返回设备输出端口的数组 MidiReceiver

IBinder onBind(Intent intent)

将通信信道返回给服务。

void onClose()

打电话通知我们的设备何时被所有客户关闭

void onCreate()

服务第一次创建时由系统调用。

void onDeviceStatusChanged(MidiDeviceStatus status)

打电话通知我们 MidiDeviceStatus已更改

abstract MidiReceiver[] onGetInputPortReceivers()

返回设备输入端口的数组 MidiReceiver

Inherited methods

From class android.app.Service
From class android.content.ContextWrapper
From class android.content.Context
From class java.lang.Object
From interface android.content.ComponentCallbacks2
From interface android.content.ComponentCallbacks

Constants

SERVICE_INTERFACE

Added in API level 23
String SERVICE_INTERFACE

常量值:“android.media.midi.MidiDeviceService”

Public constructors

MidiDeviceService

Added in API level 23
MidiDeviceService ()

Public methods

getDeviceInfo

Added in API level 23
MidiDeviceInfo getDeviceInfo ()

返回此服务的 MidiDeviceInfo实例

Returns
MidiDeviceInfo our MidiDeviceInfo

getOutputPortReceivers

Added in API level 23
MidiReceiver[] getOutputPortReceivers ()

返回设备输出端口的数组MidiReceiver 这些可用于将数据从设备的输出端口发送出去。

Returns
MidiReceiver[] array of MidiReceivers

onBind

Added in API level 23
IBinder onBind (Intent intent)

将通信信道返回给服务。 如果客户端无法绑定到服务,可能会返回null。 返回IBinder通常是一个复杂的界面已经described using aidl

请注意,与其他应用程序组件不同,此处返回的IBinder接口调用可能不会发生在进程的主线程上 有关主线程的更多信息可以在Processes and Threads中找到。

Parameters
intent Intent: The Intent that was used to bind to this service, as given to Context.bindService. Note that any extras that were included with the Intent at that point will not be seen here.
Returns
IBinder Return an IBinder through which clients can call on to the service.

onClose

Added in API level 23
void onClose ()

打电话通知我们的设备何时被所有客户关闭

onCreate

Added in API level 23
void onCreate ()

服务第一次创建时由系统调用。 不要直接调用这个方法。

onDeviceStatusChanged

Added in API level 23
void onDeviceStatusChanged (MidiDeviceStatus status)

打电话通知我们 MidiDeviceStatus已更改

Parameters
status MidiDeviceStatus: the number of the port that was opened

onGetInputPortReceivers

Added in API level 23
MidiReceiver[] onGetInputPortReceivers ()

返回设备输入端口的数组MidiReceiver 子类必须覆盖它以提供将接收发送到设备输入端口的数据的接收器。 如果设备没有输入端口,则应该返回空数组。

Returns
MidiReceiver[] array of MidiReceivers

Hooray!