Pro Android with Kotlin
CHAPTER 6: Content Providers
Download 5.42 Mb. Pdf ko'rish
|
@de android telegram Pro Android with Kotlin Developing Modern Mobile
99
CHAPTER 6: Content Providers fun openDocument(documentId: String?, mode: String?, signal: CancellationSignal?): ParcelFileDescriptor: Open and return the requested document. This should return a reliable ParcelFileDescriptor to detect when the remote caller has finished reading or writing the document. If you block while downloading content, you should periodically check CancellationSignal.isCanceled() to abort abandoned open requests. The parameters are documentId for the document to return. The mode specifies the “open” mode, such as r, w, or rw. Mode r should always be supported. The provider should throw UnsupportedOperationException if the passing mode is not supported. You may return a pipe or socket pair if the mode is exclusively r or w, but complex modes like rw imply a normal file on disk that supports seeking. The signal may be used from the caller if the request should be canceled. May be null. override fun queryDocument(documentId: String?, projection: Array Return metadata for a single requested document. The parameters are documentId for the ID of the document to return and projection for a list of columns to put into the cursor. Use the constants from DocumentsContract.Document. For a list, see the description of the method queryChildDocuments(). If you use null here, all columns are to be returned. Inside the file AndroidManifest.xml, you register the documents provider almost like any other provider. android:name="com.example.YourDocumentProvider" android:authorities="com.example.documents" android:exported="true" android:grantUriPermissions="true" android:permission= "android.permission.MANAGE_DOCUMENTS"> In the previous queries, we have seen that the Cursor object returns flags to indicate that recent documents and searching inside the tree should be supported. For this to work, you must implement one or two more methods in your DocumentsProvider implementation. override fun queryRecentDocuments(rootId: String, projection: Array This is supposed to return recently modified documents under the requested root. The returned documents should be sorted by COLUMN_LAST_ MODIFIED in descending order, and at most 64 entries should be shown. Recent documents do not support change notifications. |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling