DJI SDK: Pause/Resume Waypoint mission when arriving on point? - android

I haven't found any info on this. I'd like to build a waypoint mission like this:
drone arrives at waypoint
whole mission pauses, notifies the user (is there a listener for waypoints?)
app goes to another activity to take photo
user comes back from photo activity
user presses button, mission continues to next waypoint.
I see the waypoint actions but it's not exactly what I'd like to achieve. I'd like to let the user control the mission manually, but have the option to do things like skip waypoints, but also to go to another activity while the drone is waiting at a waypoint.
Any tips on this?
Thanks

This answer pertains specifically to the android SDK, but similar concepts exist for the iOS SDK as well.
In Android, waypoint missions are created and controlled through the WaypointMissionOperator class. Instances of this class allow for setting a listener through the addListener method that will be called when updated aircraft state is available. The onExecutionUpdate method of the WaypointMissionOperatorListener that you pass to that method will receive a WaypointMissionExecutionEvent. This object has a getProgress method which will give you information on the state of the mission that you need (
targetWaypointIndex and isWaypointReached).
To pause the mission at a specific waypoint, you may want to add a hold at the waypoint. This allows your software running on the mobile device time to detect that the aircraft has reached the waypoint and send a mission pause command.
The rest of your question gets into a bit of design philosophy which is a bit out of scope for stackoverflow, but feel free to contact me directly.

Related

Improve Activity Recognition API, filtering false positives

Activity Recognition may throw quite a few false positives as you, no matter how high you raise the confidence level. So if, for example, I would like to throw a notification when the user is driving I would need build some sort of state machine.
For example:
When I get IN_VEHICLE updates with CONFIDENCE > 70 for 30 seconds, I send a notification
or
When I get 3 consecutive IN_VEHICLE updates with CONFIDENCE > 70, I send a notification
There are different issues when implementing it though. Sometimes you get very frequent updates (2nd fails) or you vet very rare updates (1st fails).
How do go about designing this so that you have smoother transitions between states?
I think this tutorial - How to Recognize User Activity With Activity Recognition will help you. And, as mentioned in the tutorial, making your application context-aware is one of the best ways to offer useful services to your users.
In Handling Activity Recognition:
In the onHandleIntent() method of ActivityRecognizedService, the first thing you do is validate that the received Intent contains activity recognition data. If it does, then you can extract the ActivityRecognitionResult from the Intent to see what activities your user might be performing. You can retrieve a list of the possible activities by calling getProbableActivities() on the ActivityRecognitionResult object.
Source files used can be found in GitHub - Android-ActivityRecognition.

Android: Detect if user is on a bus/train/tram/etc

I know this is a very open question, but does anyone know how I can determine if a user is on public transport? Ideally, I'd have a background service running such that only subscribers who are on public transport receive my alerts.
how I can determine if a user is on public transport?
You ask the user, "Yo! You on public transport?"
Perhaps a fusion of maps data and sensors?
You can use the activity recognition portion of the Google Play Services location API to determine if the user is in a moving vehicle.
However, there is no requirement for governments to collect, let alone publish, the GPS coordinates of all public transportation vehicles. Hence, there is no way for you to determine the location of all the world's buses, trains, trams, etc. And, as a result, you have no way to determine if the user is on one of those.
Every method of transportation has it's own move-characreristics. E.g. a train takes long time to speed up and down. A bus takes little shorter and stops more often. Analyzing these accelaration-characferistics should give a hint on the form of transportation.
Next, you could analyze the routes using map Information, if you can get it somewhere. May be you van gather it yourself: record a route, let user tell whether he/she is on train, bus, walking. Save this Information for later use, also for other travellers.
Lot's of possibilities. All are rather difficult.

Really Prefer Network: select my own network provider as soon as it is available (from code)

I live near the border and work in another country. So I have selected my own network provider as the favorite. However, I notice that it sticks with the provider for as long as it can. So when I start from my country I keep my network even when I am across the border, however, when I go the other way around, it will keep the foreign network even when my favorite network is already available. I know this, because when I want to manually select it, it is available from the list.
Now, I would like to create an application that would automatically search for my preferred network when it is roaming, each time it connects to another cell tower.
Now I understand, that previously I could have listened to Cell Location changed with a broadcast receiver, but that is now impossible. (Which is a pity)
And I read from this:
Programatically connecting to another Network operators
That it seems that I would be unable to select another provider from an application for security reasons. (At least with documented api calls).
However, I don't care about public api or not, because I don't intent to distribute this in the Android Market. It is just an app to make MY life easier, will probably open up the source code, so other people can use it if they want to.
I could use some hints, to get this working though.
So maybe there are other things that are broadcast for which I can listen to, like signal strength or something, this would start my code to check if I can switch network.
I would prefer this to work as a Broadcast Receiver, I also have read that when using Cell location from a Service that I won't get updates when the screen is turned off, which in this case defeats the purpose.
And then, I would greatly appreciate some hints/pointers as for how to search the Android source for stuff that I can use to select the network automatically.
Since it sounds like you might be traveling on a predictable path between the networks, have you considered using the ProximityAlert capability of the LocationManager? You define a circle around some location, and when your device enters/exits that circle, a broadcast is issued to your receiver.
I wrote a section on this in Pro Android 3, chapter 17. There's a sample application on our web site:
http://www.androidbook.com/projects
Click on the link for the project zip files, then look for ProAndroid3_Ch17_Maps.zip
There are instructions for downloading and importing from the link above. The project inside the zip is called ProximityAlertDemo. It's very basic, just to show the Proximity Alert itself, but it shouldn't be too hard to incorporate it into an app or a service. I'm afraid I don't have an answer for you on how to switch the networks from code though. The suggestion to launch into the Settings screen seems to be your best bet at the moment.

How to get an event in a service when the screen is touched?

I would like to implement a service in Android that basically should monitor the time elapsed since the user didn't touched the screen. For example the user opens Internet or Adobe Reader, starts reading and don't interact anymore withe the touchscreen.
I want that my running service know the time since the user didn't touched the screen.
How can I do this ?
I'm thinking at two approaches:
1. The better one : After the time is elapsed (the service is set that after 2 or 5 or 10 minutes to check if the screen was or not touched) the service query some system object for this information.
2. The not so better one (I think this could have an impact on performance) At every touch of the screen the service to be notified.
Please help. Thanks.
How can I do this ?
You don't.
After the time is elapsed (the service is set that after 2 or 5 or 10 minutes to check if the screen was or not touched) the service query some system object for this information.
There is no "system object" that will tell you when the user last touched the screen.
The not so better one (I think this could have an impact on performance) At every touch of the screen the service to be notified.
There is no way for a service to be notified about the user touching the screen.
You can't do this, because it requires access to data that an app could use to scrape data from other parts of the system that it otherwise wouldn't have access to. It's a security issue; the API doesn't provide a means to do it to avoid nefarious uses. The user would have to be using a modified ROM.
In any case, event listeners are bound to View objects; your own application's View objects are the only things you can watch for touch events on. Also, while we're at it--Services aren't meant for UI interaction (though apps can send signals and data to them while they're running).

Is there a Dropped Call Listener

Does the Android SDK have the ability to to trap a Dropped Call event? If so, what is it called? I've been prowling the documentation looking for it.
Is there a difference between a hang up, and a dropped call?
Does the Android SDK have the ability
to to trap a Dropped Call event?
No.
Is there a difference between a hang
up, and a dropped call?
To humans, yes. To Android, no.
Just a bit of additional information.
The Android system does know when a call is dropped for what ever reason, i.e. Congestion, No Circuit Available etc. However none of this information is parsed through to the sdk. In the source at some point android basically mashes a whole bunch of telephony related information into a few, excruciatingly vague sdk calls. For example - the only indication we get of a call end is the changed in a PhoneStateListener from OffHook to Idle. Which literally encompasses every single reason for a call ending.
Even different states of the call are mashed together. Where as we should be able to get information like whether the phone is alerting the b party or actually has an active connection, this is reduced to the three states available, offhook, idle and ringing - note ringing is only when your device is ringing, not when the person you are calling phone's ring.
Sorry to be another bearer of bad new, but alas. all we can hope for is better support at a later stage

Categories

Resources