android action_media_button,MediaButtonReceiver

MediaButtonReceiver

This package is part of the

Android support library which

is no longer maintained.

The support library has been superseded by AndroidX

which is part of Jetpack.

We recommend using the AndroidX libraries in all new projects. You should also consider

migrating existing projects to AndroidX.

To find the AndroidX class that maps to this deprecated class, see the AndroidX

support library class

mappings.

public

class

MediaButtonReceiverjava.lang.Object

android.support.v4.media.session.MediaButtonReceiver

A media button receiver receives and helps translate hardware media playback buttons, such as

those found on wired and wireless headsets, into the appropriate callbacks in your app.

You can add this MediaButtonReceiver to your app by adding it directly to your

AndroidManifest.xml:

This class assumes you have a

Service Handling ACTION_MEDIA_BUTTON

A service can receive a key event by including an intent filter that handles

Events can then be handled in private MediaSessionCompat mMediaSessionCompat = ...;

public int onStartCommand(Intent intent, int flags, int startId) {

MediaButtonReceiver.handleIntent(mMediaSessionCompat, intent);

return super.onStartCommand(intent, flags, startId);

}

This ensures that the correct callbacks to

Note: Once the service is started, it must start to run in the

foreground.

MediaBrowserService

If you already have a

Summary

Public constructors

Public methods

Creates a broadcast pending intent that will send a media button event.

Creates a broadcast pending intent that will send a media button event.

Inherited methods

9af5b0d0e95b72f0836e23fa5ea15c04.pngFrom

class

final

void

abortBroadcast()

final

void

clearAbortBroadcast()

final

boolean

getAbortBroadcast()

final

boolean

getDebugUnregister()

final

int

getResultCode()

final

String

getResultData()

getResultExtras(boolean arg0)

final

boolean

isInitialStickyBroadcast()

final

boolean

isOrderedBroadcast()

abstract

void

onReceive(Context arg0, Intent arg1)

peekService(Context arg0, Intent arg1)

final

void

setDebugUnregister(boolean arg0)

final

void

setOrderedHint(boolean arg0)

final

void

setResult(int arg0, String arg1, Bundle arg2)

final

void

setResultCode(int arg0)

final

void

setResultData(String arg0)

final

void

setResultExtras(Bundle arg0)

9af5b0d0e95b72f0836e23fa5ea15c04.pngFrom

class

java.lang.Object

Object

clone()

boolean

equals(Object arg0)

void

finalize()

final

Class>

getClass()

int

hashCode()

final

void

notify()

final

void

notifyAll()

String

toString()

final

void

wait(long arg0, int arg1)

final

void

wait(long arg0)

final

void

wait()

Public constructors

MediaButtonReceiver

MediaButtonReceiver ()

Public methods

buildMediaButtonPendingIntent

PendingIntent buildMediaButtonPendingIntent (Context context,

ComponentName mbrComponent,

long action)

Creates a broadcast pending intent that will send a media button event. The action

will be translated to the appropriate action should be one of the following:Parameters

context

Context: The context of the application.

mbrComponent

ComponentName: The full component name of a media button receiver where you want to send

this intent.

action

long: The action to be sent via the pending intent.

Returns

Created pending intent, or null if the given component name is null or the

action is unsupported/invalid.

buildMediaButtonPendingIntent

PendingIntent buildMediaButtonPendingIntent (Context context,

long action)

Creates a broadcast pending intent that will send a media button event. The action

will be translated to the appropriate action should be one of

the following:Parameters

context

Context: The context of the application.

action

long: The action to be sent via the pending intent.

Returns

Created pending intent, or null if cannot find a unique registered media button

receiver or if the action is unsupported/invalid.

handleIntent

KeyEvent handleIntent (MediaSessionCompat mediaSessionCompat,

Intent intent)

Parameters

mediaSessionCompat

intent

Intent: The intent to parse.

Returns

The extracted

onReceive

void onReceive (Context context,

Intent intent)

Parameters

context

Context

intent

Intent

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值