ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

android-GBoard键盘GIF贴纸集成

2019-10-13 15:25:23  阅读:251  来源: 互联网

标签:android keyboard gif gboard


我正在尝试在我的应用程序中支持GBoard.我希望用户能够从GBoard中选择GIF.我的onCommitContent看起来像这样:

@Override
public void onCommitContent(InputContentInfoCompat inputContentInfo, int flags, Bundle opts) {
    try {
        if (inputContentInfo != null){
            if (inputContentInfo.getContentUri() != null){
                Log.v(inputContentInfo.getContentUri().getPath());
            }
            if (inputContentInfo.getLinkUri() != null){
                Log.v(inputContentInfo.getLinkUri().getPath());
            }
            Log.v((String)(inputContentInfo.getDescription().getLabel()));
            imageURI = "content://com.google.android.inputmethod.latin" + inputContentInfo.getContentUri().getPath() + inputContentInfo.getLinkUri().getPath();
        }
        Bitmap bitmap = MediaStore.Images.Media.getBitmap(activity.getContentResolver(), Uri.parse(imageURI));
        imageView.setImageBitmap(bitmap);
    } catch (Exception ex) {
        Log.v(ex.getMessage());
    }

}

但是我收到以下异常.

No content provider: content://com.google.android.inputmethod.latin

请帮忙.

解决方法:

您需要实施该方案:

URI Syntax Diagram

内容:// schemeIETFBCP35”中进行了说明,该目录将指导您查看IANAUniform Resource Identifier (URI) Schemes”,在其中进行说明:

URI方案|模板|描述状态|参考|笔记

内容| prov/content |内容|临时| Dave_Thaler | –

该链接将您引至以下信息:

“(last updated 2012-09-23)

Resource Identifier (RI) Scheme name: content
Status: provisional

Scheme syntax:
content://provider/

Scheme semantics:
Accessing an Android content provider.

Encoding considerations:
Unknown, use with care.

Applications/protocols that use this scheme name:
Performs a query on an Android Content Provider

Interoperability considerations:
Unknown, use with care.
May be unsuitable for open use on the public internet.

Security considerations:
Unknown, use with care.

Contact:
Registering party: Dave Thaler
Scheme creator: Open Handset Alliance

Author/Change controller:
Either the registering party or someone who is verified to represent
the scheme creator. See previous answer.

References:
07008,
07009

(file created 2012-09-23)”.

有关更多信息,请参考最后一个URL“ Android Developers > Docs > Guides > Content providers”:

“Content providers can help an application manage access to data stored by itself, stored by other apps, and provide a way to share data with other apps. They encapsulate the data, and provide mechanisms for defining data security. Content providers are the standard interface that connects data in one process with code running in another process. Implementing a content provider has many advantages. Most importantly you can configure a content provider to allow other applications to securely access and modify your app data …

A number of other classes rely on the 070011 class:

  • 070012
  • 070013
  • 070014

If you are making use of any of these classes you also need to implement a content provider in your application. Note that when working with the sync adapter framework you can also create a stub content provider as an alternative. For more information about this topic, see 070015.

从:Creating a stub content provider

Add a stub content provider

To create a stub content provider for your app, extend the class 070011 and stub out its required methods. The following snippet shows you how to create the stub provider:

在科特林:

/*
 * Define an implementation of ContentProvider that stubs out
 * all methods
 */
class StubProvider : ContentProvider() {
    /*
     * Always return true, indicating that the
     * provider loaded correctly.
     */
    override fun onCreate(): Boolean  = true

    /*
     * Return no type for MIME type
     */
    override fun getType(uri: Uri): String?  = null

    /*
     * query() always returns no results
     *
     */
    override fun query(
            uri: Uri,
            projection: Array<String>,
            selection: String,
            selectionArgs: Array<String>,
            sortOrder: String
    ): Cursor?  = null

    /*
     * insert() always returns null (no URI)
     */
    override fun insert(uri: Uri, values: ContentValues): Uri? = null

    /*
     * delete() always returns "no rows affected" (0)
     */
    override fun delete(uri: Uri, selection: String, selectionArgs: Array<String>): Int = 0

    /*
     * update() always returns "no rows affected" (0)
     */
    override fun update(
            uri: Uri,
            values: ContentValues,
            selection: String,
            selectionArgs: Array<String>
    ): Int = 0
}

Declare the provider in the manifest

The sync adapter framework verifies that your app has a content provider by checking that your app has declared a provider in its app manifest. To declare the stub provider in the manifest, add a <070018> element with the following attributes:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.network.sync.BasicSyncAdapter"
    android:versionCode="1"
    android:versionName="1.0" >
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
    ...
    <provider
        android:name="com.example.android.datasync.provider.StubProvider"
        android:authorities="com.example.android.datasync.provider"
        android:exported="false"
        android:syncable="true"/>
    ...
    </application>
</manifest>

请参考上述URL,以获取完整的文档以及此简短答案中未包含的其他链接.

标签:android,keyboard,gif,gboard
来源: https://codeday.me/bug/20191013/1908727.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有