B4A Library ML Kit Language Identification

Original library: https://developers.google.com/ml-kit/language/identification
Usage: https://developers.google.com/ml-kit/language/identification/android
Supported languages: https://developers.google.com/ml-kit/language/identification/langid-support

With ML Kit's on-device language identification API, you can determine the language of a string of text.
Language identification can be useful when working with user-provided text, which often doesn't come with any language information.




Add this to manifest:
B4X:
AddPermission(android.permission.ACCESS_NETWORK_STATE)
AddPermission(android.permission.INTERNET)
AddPermission(${applicationId}.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION)
AddManifestText(<permission
        android:name="${applicationId}.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION"
        android:protectionLevel="signature" />)
        
AddApplicationText(<provider
            android:name="com.google.mlkit.common.internal.MlKitInitProvider"
            android:authorities="${applicationId}.mlkitinitprovider"
            android:exported="false"
            android:initOrder="99" />

   <service
            android:name="com.google.mlkit.common.internal.MlKitComponentDiscoveryService"
            android:directBootAware="true"
            android:exported="false" >
            <meta-data
                android:name="com.google.firebase.components:com.google.mlkit.nl.languageid.bundled.internal.ThickLanguageIdRegistrar"
                android:value="com.google.firebase.components.ComponentRegistrar" />
                <meta-data
                android:name="com.google.firebase.components:com.google.mlkit.common.internal.CommonComponentRegistrar"
                android:value="com.google.firebase.components.ComponentRegistrar" />
                 <meta-data
                android:name="com.google.firebase.components:com.google.mlkit.nl.languageid.internal.LanguageIdRegistrar"
                android:value="com.google.firebase.components.ComponentRegistrar" />
        </service>
 
      <activity android:name="com.google.android.gms.common.api.GoogleApiActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:exported="false" />
    )
 

Attachments

  • MlKitLibrary.zip
    6.1 KB · Views: 77
  • MlKitExample.zip
    3.3 KB · Views: 87
Last edited:

Jerryk

Active Member
Licensed User
Longtime User
B4A Version: 12.20
Parsing code. (0.00s)
Java Version: 11
Building folders structure. (0.09s)
Compiling code. (0.02s)
Compiling layouts code. (0.00s)
Organizing libraries. Error
Maven artifact not found: com.google.auto/auto-common
Source: MlKitLanguageId

on SDK not found to install com.google.auto/auto-common

how to resolve this?
 

Jerryk

Active Member
Licensed User
Longtime User
I deleted SDK and resources files and copied new one from www.b4x.com. Installed SDK writen on post#1. When compiled error showed:

B4A Version: 12.20
Parsing code. (0.01s)
Java Version: 11
Building folders structure. (0.08s)
Compiling code. (0.06s)
Compiling layouts code. (0.01s)
Organizing libraries. Error
Maven artifact not found: androidx.lifecycle/lifecycle-livedata-core-ktx-lint
Source: MlKitLanguageId

any idea?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…