抱歉,我找不到那个频道试着说“给我看电视指南”

hrysbysz  于 2021-09-13  发布在  Java
关注(0)|答案(0)|浏览(166)

我一直在安卓电视台工作,可通过频道提供商进行搜索。我在通过我的应用程序搜索一些关键词时遇到了问题,比如索尼max、hbo、kantipur等。在这种情况下,不会调用查询函数。但一些关键字,如电影名、演员名工作得很好,并且正在调用查询函数。
这是我的密码,

class SearchDatabase : ContentProvider() {

    val PROVIDER_NAME = "com.genius.channelprovider"
    val URL = "content://$PROVIDER_NAME/channel_suggestion "
    val CONTENT_URI = Uri.parse(URL)

    private var db: SQLiteDatabase? = null
    val TABLE_NAME = "search"

    class DatabaseHelper internal constructor(context: Context?) :
        SQLiteOpenHelper(context, "livetv", null, 2) {
        override fun onCreate(db: SQLiteDatabase) {
            db.execSQL(
                " CREATE TABLE channel" +
                        " (${VideoDatabase._ID} INTEGER PRIMARY KEY AUTOINCREMENT, " +
                        " ${VideoDatabase.KEY_NAME}  TEXT NOT NULL, " +
                        " ${VideoDatabase.KEY_DESCRIPTION}  TEXT NOT NULL, " +
                        " ${VideoDatabase.KEY_ICON}  TEXT NOT NULL, " +
                        " ${VideoDatabase.KEY_DATA_TYPE}  TEXT NOT NULL, " +
                        " ${VideoDatabase.KEY_IS_LIVE}  TEXT NOT NULL, " +
                        " ${VideoDatabase.KEY_VIDEO_WIDTH}  TEXT NOT NULL, " +
                        " ${VideoDatabase.KEY_VIDEO_HEIGHT}  TEXT NOT NULL, " +
                        " ${VideoDatabase.KEY_AUDIO_CHANNEL_CONFIG}  TEXT NOT NULL, " +
                        " ${VideoDatabase.KEY_PURCHASE_PRICE}  TEXT NOT NULL, " +
                        " ${VideoDatabase.KEY_RENTAL_PRICE}  TEXT NOT NULL, " +
                        " ${VideoDatabase.KEY_RATING_SCORE}  TEXT NOT NULL, " +
                        " ${VideoDatabase.KEY_PRODUCTION_YEAR}  TEXT NOT NULL, " +
                        " ${VideoDatabase.KEY_COLUMN_DURATION}  TEXT NOT NULL, " +
                        " ${VideoDatabase.KEY_ACTION}  TEXT NOT NULL);"
            )
        }

        override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
            db.execSQL("DROP TABLE IF EXISTS zenocx")
            onCreate(db)
        }
    }

    override fun insert(uri: Uri, values: ContentValues?): Uri? {
        val rowID = db!!.insert(TABLE_NAME, "", values)
        /**
         * If record is added successfully
         */
        if (rowID > 0) {
            val _uri: Uri = ContentUris.withAppendedId(CONTENT_URI, rowID)
            context!!.contentResolver.notifyChange(_uri, null)
            return _uri
        }
        throw SQLException("Failed to add a record into $uri")
    }

    override fun query(
        p0: Uri,
        p1: Array<out String>?,
        p2: String?,
        p3: Array<String>?,
        p4: String?
    ): Cursor? {
        Log.d("query_search",p3?.get(0))
        Log.d("query_search",p2)
        Log.d("query_search",p4)
    }    

    override fun onCreate(): Boolean {
        val context: Context? = context
        val dbHelper = DatabaseHelper(context)
        db = dbHelper.writableDatabase
        return db != null
    }

    override fun update(p0: Uri, p1: ContentValues?, p2: String?, p3: Array<out String>?): Int {
        TODO("Not yet implemented")
    }

    override fun delete(p0: Uri, p1: String?, p2: Array<out String>?): Int {
        TODO("Not yet implemented")
    }

    override fun getType(p0: Uri): String? {
        TODO("Not yet implemented")
    }
}

searchable.xml文件

<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
    android:hint="@string/search_for_livetv"
    android:includeInGlobalSearch="true"
    android:icon="@drawable/abc_vector_test"
    android:searchMode="queryRewriteFromText"
    android:label="@string/search_for_livetv"
    android:searchSettingsDescription="@string/settings_description"
    android:searchSuggestAuthority="com.genius.channelprovider"
    android:searchSuggestIntentAction="android.intent.action.VIEW"
    android:queryAfterZeroResults="true"
    android:searchSuggestIntentData="content://com.genius.channelprovidder/channel_sugguestion"
    android:searchSuggestPath="search"
    android:searchSuggestSelection=" ?"
    android:searchSuggestThreshold="3">

</searchable>

在manifest.xml文件中

<application android:banner="@drawable/banner_logo"
        android:icon="@mipmap/ic_launcher"
        tools:replace="android:icon">
        <activity android:name=".SplashActivity">
            <meta-data
                android:name="android.app.searchable"
                android:resource="@xml/searchable"
                />
            <intent-filter>
                <action android:name="android.intent.action.SEARCH" />
                <action android:name="android.intent.action.MAIN" />
                <action android:name="np.iptv.nettvprime.intent.action.WATCH" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

我已经阅读了android文档并按照建议进行了尝试,但我找不到解决方案。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题