Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/216.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android,如何从Chrome浏览器(搜索Uri)中获取搜索关键词?_Android_Google Chrome_Android Contentprovider - Fatal编程技术网

Android,如何从Chrome浏览器(搜索Uri)中获取搜索关键词?

Android,如何从Chrome浏览器(搜索Uri)中获取搜索关键词?,android,google-chrome,android-contentprovider,Android,Google Chrome,Android Contentprovider,我可以通过以下代码从默认浏览器中获取搜索到的关键字 List<SearchRecord> searchList = new LinkedList<SearchRecord>(); ContentResolver resolver = this.getContentResolver(); Cursor cursor = resolver.query(Browser.SEARCHES_URI, Browser.SEARCHES_PROJECT

我可以通过以下代码从默认浏览器中获取搜索到的关键字

List<SearchRecord> searchList = new LinkedList<SearchRecord>();

        ContentResolver resolver = this.getContentResolver();
        Cursor cursor = resolver.query(Browser.SEARCHES_URI, Browser.SEARCHES_PROJECTION, null, null, null);
        cursor.moveToFirst();
        if (cursor.moveToFirst() && cursor.getCount() > 0) {
            while (cursor.isAfterLast() == false) {
                SearchRecord record = new SearchRecord();

                record.setKeyword(cursor.getString(Browser.SEARCHES_PROJECTION_SEARCH_INDEX));
                record.setDate(cursor.getLong(Browser.SEARCHES_PROJECTION_DATE_INDEX));

                searchList.add(record);
                cursor.moveToNext();
            }
        }
我在寻找Chrome的Uri,以便获得搜索到的关键词。你知道那是什么吗?谢谢

List searchList=new LinkedList();
List<SearchRecord> searchList = new LinkedList<SearchRecord>();

ContentResolver resolver = this.getContentResolver();
Cursor cursor = resolver.query(Browser.SEARCHES_URI, Browser.SEARCHES_PROJECTION, ***Browser.BookmarkColumns.BOOKMARK+ " = 0"***, null, null);
cursor.moveToFirst();
if (cursor.moveToFirst() && cursor.getCount() > 0) {
    while (cursor.isAfterLast() == false) {
        SearchRecord record = new SearchRecord();
        record.setKeyword(cursor.getString(Browser.SEARCHES_PROJECTION_SEARCH_INDEX));
        record.setDate(cursor.getLong(Browser.SEARCHES_PROJECTION_DATE_INDEX));

        searchList.add(record);
        cursor.moveToNext();
    }
}
ContentResolver解析器=this.getContentResolver();
Cursor Cursor=resolver.query(Browser.SEARCHES\u URI,Browser.SEARCHES\u PROJECTION,***Browser.BOOKMARK columns.BOOKMARK+“=0”***,null,null); cursor.moveToFirst(); if(cursor.moveToFirst()&&cursor.getCount()>0){ while(cursor.isAfterLast()==false){ SearchRecord记录=新的SearchRecord(); record.setKeyword(cursor.getString(Browser.SEARCHES\u PROJECTION\u SEARCH\u INDEX)); record.setDate(cursor.getLong(Browser.SEARCHES\u PROJECTION\u DATE\u INDEX)); 搜索列表。添加(记录); cursor.moveToNext(); } }
我认为这会很有帮助,谢谢Sanket,我以前看到过这个答案,但与我的问题无关。返回默认浏览器的书签。我正在寻找Chrome浏览器的搜索关键字。我不确定,但你也可以从那里获得搜索历史。是的,你是对的。但我需要再次解析字符串才能得到它。而类似于我的第一个代码的方式只是返回关键字.Browser.BookmarkColumns.BOOKMARK+“=0”粘贴到查询方法的第三个参数中
List<SearchRecord> searchList = new LinkedList<SearchRecord>();

ContentResolver resolver = this.getContentResolver();
Cursor cursor = resolver.query(Browser.SEARCHES_URI, Browser.SEARCHES_PROJECTION, ***Browser.BookmarkColumns.BOOKMARK+ " = 0"***, null, null);
cursor.moveToFirst();
if (cursor.moveToFirst() && cursor.getCount() > 0) {
    while (cursor.isAfterLast() == false) {
        SearchRecord record = new SearchRecord();
        record.setKeyword(cursor.getString(Browser.SEARCHES_PROJECTION_SEARCH_INDEX));
        record.setDate(cursor.getLong(Browser.SEARCHES_PROJECTION_DATE_INDEX));

        searchList.add(record);
        cursor.moveToNext();
    }
}