Problem using IKeyManager in JAVA
CompletedHello,
I am developing a mobile app in JAVA with the msdk v5. I want to get information about a lot of sensors of the drone and show them to the user: battery percentage, altitude, speeds...
I have done it with the distances of the obstacles, and it was easy. This is what I have done in order do get those sensors:
public class SensorsViewModel extends ViewModel implements ObstacleDataListener {
(... code here ...)
@Override
public void onUpdate(ObstacleData obstacleData) {
objectsAboveLiveData.postValue(obstacleData.getUpwardObstacleDistance());
objectsBelowLiveData.postValue(obstacleData.getDownwardObstacleDistance());
objectsInfrontLiveData.postValue(obstacleData.getHorizontalObstacleDistance().get(0));
objectsBehindLiveData.postValue(obstacleData.getHorizontalObstacleDistance().get(1));
}
(... code here ...)
I can't do it with the IKeyManager. How do I do the same in order to get information about Battery, FlightController....?
I have also explored the sample code, but I can't manage to convert the examples from kotlin to java.
Thank you
-
Thank you, I managed to do it, it was something like this:
KeyManager.getInstance().listen(KeyTools.createKey(BatteryKey.KeyChargeRemainingInPercent), this, (oldValue, newValue) -> {
batteryPercentageLiveData.postValue(newValue);
});
KeyManager.getInstance().listen(KeyTools.createKey(BatteryKey.KeyBatteryTemperature), this, (oldValue, newValue) -> {
batteryTemperatureLiveData.postValue(newValue);
});One more question. Can't I use the DJI Mini 3 Pro on the simulator?? I know that I can simulate values in the sample code, but I really want to fly it in the simulator.
-
-
It is possible to open the simulator in MSDK, but if you want to use dji-assistant-2 to open the simulator, you can contact **support@dji.com** to give feedback on your needs
Please sign in to leave a comment.
Comments
5 comments