Registering the Fritz JobService in your Android Manifest

I already mentioned that your app will download the model files when deployed in the fritz cloud server. To do that, Fritz has implemented a service named FritzJob. This service will be running in the background and when it finds a new model deployed in your web console, it will try to download it when the device is connected through the WiFi network.

To log into your cloud account, your app requires some credentials. For that, fritz is supplying an API key. To enable this, we need to add a meta-entry to your Android manifest XML file, as follows:

<meta-data
android:name="fritz_api_key"
android:value="e35d2b5bbba84eca8969b7d6acac1fb7" />

The value of the Fritz API key you need to replace with yours that you got from the previous dialog in the browser when you clicked SDK INSTRUCTIONS.

We need to declare the Fritz job, as follows:

<service
android:name="ai.fritz.core.FritzJob"
android:exported="true"
android:permission="android.permission.BIND_JOB_SERVICE" />

As our app needs to connect to a cloud server through WiFi, we need to mention the internet access permission for that:

<uses-permission android:name="android.permission.INTERNET"/>

And we need to add the following lines:

<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="21" />
<uses-feature android:name="android.hardware.camera2.full" />
<uses-permission android:name="android.permission.CAMERA" />

In Android, the camera handling mechanism has been changed to the camera2 package, and the preceding line specifies which camera2 feature to use. To learn more about this, check out https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL. So, to access the camera, we are adding camera permission also.

Now, my whole manifest file will look like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.avinaas.imagelabelling">

<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="21" />
<uses-feature android:name="android.hardware.camera2.full" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="fritz_api_key"
android:value="e35d2b5bbba84eca8969b7d6acac1fb7" />
<service
android:name="ai.fritz.core.FritzJob"
android:exported="true"
android:permission="android.permission.BIND_JOB_SERVICE" />
</application>

</manifest>
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset