Pro Android with Kotlin
Download 5.42 Mb. Pdf ko'rish
|
@de android telegram Pro Android with Kotlin Developing Modern Mobile
175
CHAPTER 8: APIs The arguments sent to the query() method by the search framework can be tailored extensively by various search configuration attributes. Now, however, we refer you to the online documentation and continue with extracting the information from the first uri parameter. How to build Cursor objects is described in Chapter 6 ; for this example, we use a MatrixCursor, and instead of returning null, we could, for example, return the following from inside the SearchableActivity: override fun query(uri: Uri, projection: Array selection: String?, selectionArgs: Array sortOrder: String?): Cursor? { Log.e("LOG", "query(): " + uri + " - projection=" + Arrays.toString(projection) + " - selection=" + selection + " - selectionArgs=" + Arrays.toString(selectionArgs) + " - sortOrder=" + sortOrder) val lps = uri.lastPathSegment // the query val qr = uri.encodedQuery // e.g. "limit=50" val curs = MatrixCursor(arrayOf( BaseColumns._ID, SearchManager.SUGGEST_COLUMN_TEXT_1, SearchManager.SUGGEST_COLUMN_INTENT_DATA )) curs.addRow(arrayOf(1, lps + "-Suggestion 1", lps + "-Suggestion 1")) curs.addRow(arrayOf(2, lps + "-Suggestion 2", lps + "-Suggestion 2")) return curs } This example provides only silly suggestions; you can write something more clever to the MatrixCursor. As a last modification, you can make your search suggestions available to the system’s quick search box. All you have to do for that is add android:includeInGlobalSearch = true to your search configuration. The user must allow this inside the settings for this connection to take effect. Location and Maps Handheld devices may track their geographic position, and they may interact with map services to graphically interfere with a user’s location needs. Geographical position is not only about latitude and longitude numbers but also about finding out street addresses and points of interest. While it is certainly an important ethical question how far apps can go to track their users’ personal life, the possibilities for interesting apps and games are potentially endless. In this section, we talk about the technical possibilities. Just be cautious with your user’s data and be transparent with what you are doing with them. |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling