Context.BindService 메서드

정의

오버로드

BindService(Intent, IServiceConnection, Bind)

애플리케이션 서비스에 연결하여 필요한 경우 만듭니다.

BindService(Intent, IServiceConnection, Context+BindServiceFlags)
BindService(Intent, Bind, IExecutor, IServiceConnection)

#bindService(Intent, ServiceConnection, int) bindService(Intent, ServiceConnection, int) ServiceConnection 콜백을 제어하는 실행기에서와 동일합니다.

BindService(Intent, Context+BindServiceFlags, IExecutor, IServiceConnection)

BindService(Intent, IServiceConnection, Bind)

애플리케이션 서비스에 연결하여 필요한 경우 만듭니다.

[Android.Runtime.Register("bindService", "(Landroid/content/Intent;Landroid/content/ServiceConnection;I)Z", "GetBindService_Landroid_content_Intent_Landroid_content_ServiceConnection_IHandler")]
public abstract bool BindService (Android.Content.Intent service, Android.Content.IServiceConnection conn, Android.Content.Bind flags);
[<Android.Runtime.Register("bindService", "(Landroid/content/Intent;Landroid/content/ServiceConnection;I)Z", "GetBindService_Landroid_content_Intent_Landroid_content_ServiceConnection_IHandler")>]
abstract member BindService : Android.Content.Intent * Android.Content.IServiceConnection * Android.Content.Bind -> bool

매개 변수

service
Intent

연결할 서비스를 식별합니다. 의도는 명시적 구성 요소 이름을 지정해야 합니다.

conn
IServiceConnection

서비스가 시작되고 중지될 때 정보를 받습니다. 유효한 ServiceConnection 개체여야 합니다. null이 아니어야 합니다.

flags
Bind

바인딩에 대한 작업 옵션입니다. 가능: <ul><li>0 <li li#BIND_AUTO_CREATE#BIND_DEBUG_UNBIND><<>li<#BIND_NOT_FOREGROUND>li><#BIND_ABOVE_CLIENTli>><#BIND_ALLOW_OOM_MANAGEMENT<#BIND_WAIVE_PRIORITYli>#BIND_IMPORTANT<li li><#BIND_ADJUST_WITH_ACTIVITYli#BIND_NOT_PERCEPTIBLE<><>#BIND_INCLUDE_CAPABILITIES/ul>

반환

true 시스템이 클라이언트에 바인딩할 권한이 있는 서비스를 가져오는 중이면 이고, false 시스템에서 서비스를 찾을 수 없거나 클라이언트에 바인딩할 권한이 없는 경우 입니다. 반환 값에 관계없이 나중에 를 호출 #unbindService 하여 연결을 해제해야 합니다.

특성

예외

설명

애플리케이션 서비스에 연결하여 필요한 경우 만듭니다. 이렇게 하면 애플리케이션과 서비스 간의 종속성이 정의됩니다. 지정된 <var>conn</var> 은 서비스 개체가 만들어질 때 서비스 개체를 수신하고 해당 개체가 죽고 다시 시작되는지 확인합니다. 호출 컨텍스트가 있는 한 시스템에서만 서비스가 필요한 것으로 간주됩니다. 예를 들어 이 컨텍스트가 중지된 활동인 경우 작업이 다시 시작될 때까지 서비스가 계속 실행될 필요가 없습니다.

서비스에서 바인딩을 지원하지 않는 경우 해당 android.app.Service#onBind(Intent) onBind() 메서드에서 반환 null 할 수 있습니다. 이 경우 ServiceConnection의 ServiceConnection#onNullBinding(ComponentName) onNullBinding() 메서드가 대신 ServiceConnection#onServiceConnected(ComponentName, IBinder) onServiceConnected()호출됩니다.

<p class="note"><b>Note:</b> 이 메서드<는>구성 요소에서 BroadcastReceiver 호출할 수 없습니다<>. BroadcastReceiver에서 서비스로 통신하는 데 사용할 수 있는 패턴은 전송할 명령이 포함된 인수를 사용하여 를 호출 #startService 하고, 서비스가 해당 명령을 실행할 때 해당 메서드를 android.app.Service#stopSelf(int) 호출하는 것입니다. 이에 대한 설명은 API 데모 App/Service/Service 시작 인수 컨트롤러를 참조하세요. 그러나 이 BroadcastReceiver의 수명은 다른 개체(등록한 #registerReceiver개체)에 연결되므로 에 등록된 BroadcastReceiver에서 이 메서드를 사용하는 것은 괜찮습니다.

이 메서드는 int 형식 플래그만 허용하여 긴 형식 플래그를 전달하고 대신 를 호출 #bindService(Intent, ServiceConnection, BindServiceFlags) 합니다.

에 대한 Java 설명서입니다 android.content.Context.bindService(android.content.Intent, android.content.ServiceConnection, int).

이 페이지의 일부는 만들고 공유하며 에 설명된 조건에 따라 사용되는 작업을 기반으로 수정됩니다.

추가 정보

적용 대상

BindService(Intent, IServiceConnection, Context+BindServiceFlags)

[Android.Runtime.Register("bindService", "(Landroid/content/Intent;Landroid/content/ServiceConnection;Landroid/content/Context$BindServiceFlags;)Z", "GetBindService_Landroid_content_Intent_Landroid_content_ServiceConnection_Landroid_content_Context_BindServiceFlags_Handler", ApiSince=34)]
public virtual bool BindService (Android.Content.Intent service, Android.Content.IServiceConnection conn, Android.Content.Context.BindServiceFlags flags);
[<Android.Runtime.Register("bindService", "(Landroid/content/Intent;Landroid/content/ServiceConnection;Landroid/content/Context$BindServiceFlags;)Z", "GetBindService_Landroid_content_Intent_Landroid_content_ServiceConnection_Landroid_content_Context_BindServiceFlags_Handler", ApiSince=34)>]
abstract member BindService : Android.Content.Intent * Android.Content.IServiceConnection * Android.Content.Context.BindServiceFlags -> bool
override this.BindService : Android.Content.Intent * Android.Content.IServiceConnection * Android.Content.Context.BindServiceFlags -> bool

매개 변수

service
Intent

반환

특성

적용 대상

BindService(Intent, Bind, IExecutor, IServiceConnection)

#bindService(Intent, ServiceConnection, int) bindService(Intent, ServiceConnection, int) ServiceConnection 콜백을 제어하는 실행기에서와 동일합니다.

[Android.Runtime.Register("bindService", "(Landroid/content/Intent;ILjava/util/concurrent/Executor;Landroid/content/ServiceConnection;)Z", "GetBindService_Landroid_content_Intent_ILjava_util_concurrent_Executor_Landroid_content_ServiceConnection_Handler", ApiSince=29)]
public virtual bool BindService (Android.Content.Intent service, Android.Content.Bind flags, Java.Util.Concurrent.IExecutor executor, Android.Content.IServiceConnection conn);
[<Android.Runtime.Register("bindService", "(Landroid/content/Intent;ILjava/util/concurrent/Executor;Landroid/content/ServiceConnection;)Z", "GetBindService_Landroid_content_Intent_ILjava_util_concurrent_Executor_Landroid_content_ServiceConnection_Handler", ApiSince=29)>]
abstract member BindService : Android.Content.Intent * Android.Content.Bind * Java.Util.Concurrent.IExecutor * Android.Content.IServiceConnection -> bool
override this.BindService : Android.Content.Intent * Android.Content.Bind * Java.Util.Concurrent.IExecutor * Android.Content.IServiceConnection -> bool

매개 변수

service
Intent
flags
Bind
executor
IExecutor

ServiceConnection의 콜백은 실행기에서 호출됩니다. ServiceConnection의 동일한 instance 동일한 instance 사용해야 합니다.

반환

에 설명된 대로 바인딩의 결과입니다 #bindService(Intent, ServiceConnection, int) bindService(Intent, ServiceConnection, int).

특성

설명

#bindService(Intent, ServiceConnection, int) bindService(Intent, ServiceConnection, int) ServiceConnection 콜백을 제어하는 실행기에서와 동일합니다.

이 메서드는 32비트 플래그만 허용하여 64비트 플래그를 전달하고 대신 를 호출 #bindService(Intent, BindServiceFlags, Executor, ServiceConnection) 합니다.

에 대한 Java 설명서입니다 android.content.Context.bindService(android.content.Intent, int, java.util.concurrent.Executor, android.content.ServiceConnection).

이 페이지의 일부는 만들고 공유하며 에 설명된 조건에 따라 사용되는 작업을 기반으로 수정됩니다.

적용 대상

BindService(Intent, Context+BindServiceFlags, IExecutor, IServiceConnection)

[Android.Runtime.Register("bindService", "(Landroid/content/Intent;Landroid/content/Context$BindServiceFlags;Ljava/util/concurrent/Executor;Landroid/content/ServiceConnection;)Z", "GetBindService_Landroid_content_Intent_Landroid_content_Context_BindServiceFlags_Ljava_util_concurrent_Executor_Landroid_content_ServiceConnection_Handler", ApiSince=34)]
public virtual bool BindService (Android.Content.Intent service, Android.Content.Context.BindServiceFlags flags, Java.Util.Concurrent.IExecutor executor, Android.Content.IServiceConnection conn);
[<Android.Runtime.Register("bindService", "(Landroid/content/Intent;Landroid/content/Context$BindServiceFlags;Ljava/util/concurrent/Executor;Landroid/content/ServiceConnection;)Z", "GetBindService_Landroid_content_Intent_Landroid_content_Context_BindServiceFlags_Ljava_util_concurrent_Executor_Landroid_content_ServiceConnection_Handler", ApiSince=34)>]
abstract member BindService : Android.Content.Intent * Android.Content.Context.BindServiceFlags * Java.Util.Concurrent.IExecutor * Android.Content.IServiceConnection -> bool
override this.BindService : Android.Content.Intent * Android.Content.Context.BindServiceFlags * Java.Util.Concurrent.IExecutor * Android.Content.IServiceConnection -> bool

매개 변수

service
Intent
executor
IExecutor

반환

특성

적용 대상