Registering the FritzJob service 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 service, which will be running in the background. When it finds a new model deployed in your web console, it will try to download it when the device is connected to the Wi-Fi.

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

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

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.

And 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 Wi-Fi, we need to mention the internet access permission for that:

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

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="org.packt.fritz.samplefritzapp">

<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="6265ed5e7e334a97bbc750a09305cb19" />
<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