It all started here. In short: I want to create a library for Android Wear Watchfaces.
Erel was so kind to post the source of the LiveWallpaper library.
This is a great starting point since the structure of LiveWallpapers and Watchfaces are very similar.
My current problem is that the livewallpaper library will only work with one service. With this limitation I think watchfaces would be restricted to one per app.
The cause is that the B4A service name is somewhat "hardcoded" into the library:
The other thing is that you configure the wallpaper/watchface service in the manifest:
The question now is how to make this dynamic so that I can have several services (one for each watchface).
My idea was to #Extend the B4A service module so I can create as many services (and watchfaces) as I want. Now Erel said this should be possible otherwise but I can't see how.
Erel was so kind to post the source of the LiveWallpaper library.
This is a great starting point since the structure of LiveWallpapers and Watchfaces are very similar.
My current problem is that the livewallpaper library will only work with one service. With this limitation I think watchfaces would be restricted to one per app.
The cause is that the B4A service name is somewhat "hardcoded" into the library:
B4X:
@Override
public void onCreate() {
super.onCreate();
try {
Intent i = new Intent(this, Class.forName(getPackageName() + ".wallpaperservice"));
startService(i);
} catch (ClassNotFoundException e) {
Common.Log("WallpaperService not found.");
throw new RuntimeException(e);
}
}
The other thing is that you configure the wallpaper/watchface service in the manifest:
B4X:
AddApplicationText(
<!-- ******** Add the internal service declaration - you can change android:label ******* -->
<service
android:label="My Livewallpaper"
android:name="anywheresoftware.b4a.objects.WallpaperInternalService"
android:permission="android.permission.BIND_WALLPAPER">
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
</intent-filter>
<meta-data android:name="android.service.wallpaper" android:resource="@xml/wallpaper" />
</service>
)
The question now is how to make this dynamic so that I can have several services (one for each watchface).
My idea was to #Extend the B4A service module so I can create as many services (and watchfaces) as I want. Now Erel said this should be possible otherwise but I can't see how.