public class AVLoggerConnection extends Object
SystemCapability.Multimedia#MEDIA_LIBRARY| 构造器 | 说明 |
|---|---|
AVLoggerConnection(Context context,
AVLoggerConnectionClient client) |
A constructor used to create an
AVLoggerConnection instance. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
connect() |
Connects to the scanning service.
|
void |
disconnect() |
Disconnects from the scanning service.
|
boolean |
isConnected() |
Checks whether the scanning service is connected.
|
void |
onServiceConnect() |
Called when the application connects to the scanning service.
|
void |
onServiceDisconnect() |
Called when the application disconnects from the scanning service.
|
void |
performLoggerFile(String path,
String mimeType) |
Requests to scan a media file based on the path and type of the file.
|
static void |
performLoggerFile(Context context,
String[] paths,
String[] mimeTypes,
AVLogCompletedListener callback) |
Scans multiple media files at a time.
|
public AVLoggerConnection(Context context, AVLoggerConnectionClient client)
AVLoggerConnection instance.context - Indicates the context required for establishing a connection to the scanning service.client - Indicates the callback for receiving notifications from the scanner.IllegalArgumentException - Parameter invalid exception.public void performLoggerFile(String path, String mimeType)
path - Indicates the path of the file to scan.mimeType - Indicates the MIME media type. If this parameter is null, the media type will be
determined by the file name extension.IllegalArgumentException - Throws this exception if the file path is null.public static void performLoggerFile(Context context, String[] paths, String[] mimeTypes, AVLogCompletedListener callback)
context - Indicates the caller context required for establishing a connection to the scanning service.paths - Indicates the array of paths to scan.mimeTypes - Indicates the array of the MIME media types matching the paths. If this parameter is
null, the media types will be determined by the file name extensions.callback - Indicates the callback for receiving the scanned URIs.IllegalArgumentException - Throws this exception if any parameter is invalid.public void connect()
public void disconnect()
public boolean isConnected()
true if the connection is successful; returns false otherwise.public void onServiceConnect()
This callback will not be triggered if the application has already connected to the scanning service or the scanning service crashes during the connection. Do not directly invoke this callback. Instead, override this callback via a subclass to define an operation after the connection.
public void onServiceDisconnect()
The disconnect() method does not trigger this callback.
This callback is usually invoked when the process of the scanning service crashes or is terminated.
In this case, the application is still connected to the scanning service, and onServiceConnect()
will be invoked after the scanning service starts next time. Do not directly invoke this callback.
Instead, override this callback via a subclass to define an operation after the disconnection.