Get Google Maps Navigation Instructions - android

I'm looking for a way to get the instructions from Maps Navigation.
Currently I think the only possible way is to read the notification data that is placed at the top by Maps Navigation. My reason for beleving that this is the only way comes from this post.
I tried getting the data with the OnNotificationPosted method, but i cant find directions data in the StatusBarNotification object...
Does anyone have a solution or better idea on how to achieve this

You can implement a NotificationListenerService in order to retrieve the content of google maps route direction. Unfortunately Maps is not using the common attributes within the StatusBarNotification. However maps uses RemoteViews to display content.
You can send this data via Broadcast to the activity and eventually add the content to an existing view:
RemoteViews remoteView = intent.getParcelableExtra(id);
if (remoteView != null) {
ViewGroup frame = (ViewGroup) findViewById(R.id.layout_navi);
frame.removeAllViews();
View newView = remoteView.apply(getApplicationContext(), frame);
newView.setBackgroundColor(Color.TRANSPARENT);
frame.addView(newView);
}

Related

How to detect user interaction with graphstream?

I am investigating the use of GraphStream on Android using
api 'com.github.graphstream:gs-ui-android:2.0-alpha'
api 'com.github.graphstream:gs-core:2.0-alpha'
I have managed to construct and display my Graph fine,
However I cannot see how to listen for user interactions on the nodes within my graph.
I need to display a Dialog when any node is clicked on by the user and display the specific nodes information.
I've tried setting a Listener on the org.graphstream.ui.android_viewer.AndroidViewer, however I never received any callbacks
I can drag the displayed nodes around the screen so I know there are default listeners, how to I add my own listeners though?
You can implement ViewerListener with the ViewerPipe like this :
ViewerPipe pipe = fragment.getViewer().newViewerPipe();
pipe.addAttributeSink( graph );
pipe.addViewerListener( this ); // this or any class which implements ViewerListener
pipe.pump();
You can get an exemple here : https://github.com/graphstream/gs-ui-android-test/blob/master/app/src/main/java/ui/graphstream/org/gs_ui_androidtestFull/Activity_TestArrows.java
And here to understand how ViewerPipe works : http://graphstream-project.org/doc/Tutorials/Graph-Visualisation/

How to implement first person view in android google map?

In my android application i want to implement first person view. Please check following URL for first person View -
Google First Person View
I found one link which redirects to first person view please check -
Google Maps Navigation - Using Google Navigation in Android Application
But in it we don't have control over navigation view or first person view. It redirects to google's default first person view. I want to implement it manually. Means in which we can pass latitude and longitude dynamically(from Server)
Is there any way to implement first person view Pro-grammatically, in which we have command over view ?
Thanks in advance!
Don't know exactly, how to achieve that view, but you can do one thing, that is whatever orientation's value you are getting from your server or any gps device , pass it into bearing() method of CameraPosition and set tilt also, like following -
CameraPosition cameraPos = new CameraPosition.Builder().target(latlng)
.zoom(zoomvalue).bearing(orientation).tilt(tiltvalue).build();
googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPos), null);
by doing this your map will be rotate according to value of orientation. and if you pass value of orientation into rotation(orientation) method of marker then your marker will rotate according to value.
Hope it'll help you.

How to place Multiple MapViews v1 inside a ViewFlipper

Objective- I want to show slide shows of different Map Activities which show data according to database, using view flipper(or something similar).
Issues:
View Flipper can't be added to an Activity that is not a MapActivity if flipper contains a mapview.
View Flipper does not allows adding multiple mapviews as one MapActivity can have only one map view.
What I wish to implement
Want to show slide show of multiple MapActivities which show markers,route etc based on database data.
Want to refresh these MapActivities also new data is fetched periodically and database is updated.
I'am unable to find a solution to my problem. I have gone through the following links but they provided no relevant solution:
How can i Implement SlideShow in android?
Can a MapView be placed inside a ViewFlipper somehow?
Please help and suggest what is the best approach for this problem.
Thanks!
I did not find standard solution to my problem as view flipper could not be used.I did the following to implement mapview slide show. Its more of a hack than a proper solution but I had no choice.
In a while loop, I kept re-rendering the same map view in the async map task.
2.After 1st map is loaded I called thread.sleep(10000).
3.I cleared the mapview of all routes and markers.
4.I re rendered the 2nd map view.
5.And the steps were repeated continuously.
#Override
protected Void doInBackground(Void... params) {
final Drawable marker_inBetween;
marker_inBetween = getResources().getDrawable(R.drawable.blue_pin);
marker_inBetween.setBounds(0, 0,
marker_inBetween.getIntrinsicWidth(),
marker_inBetween.getIntrinsicHeight());
helper = new DbHelper(getApplicationContext());
// show slide show
while (true) {
ArrayList<String> IdList =showAllPeopleOnMap();
util.haveASleep(slideShowInterval);
showEachPersonRouteOnMap(IdList);
resetVariables();//resets lists,routes,removes markers etc
}
}
return null;
}
Thanks.

Google Maps Version 2 - Updating information windows

As we know in google maps android version 2, a custom information windows, is a view that converts to an image. Actually google aftre you return you view converts the view to a image an then show it to the info windows.
But I want to show images downloading from internet to my infowindow. Actually, I want that before that download complete show an progress bar to my infowindows and after it compeleted update info windows, by this mechanism how I can do this?
Have a model object that contains int for progress and Bitmap for actual image.
Start some kind of background operation started (e.g. AsyncTask) to download image.
Update model's progress from AsyncTask.onProgressUpdate.
Update model's image from AsyncTask.onPostExecute.
Have an observer for model (see Observer partern).
If you keep AsyncTask (or any other kind of Thread in Activity context, don't forget to cancel it and you may also skip observer pattern.
Save reference to marker showing info window inside InfoWindowAdapter.getInfoWindow. Call it markerShowingInfoWindow.
When you are notified of progress update,
call:
if (markerShowingInfoWindow != null && markerShowingInfoWindow.isShowingInfoWindow()) {
markerShowingInfoWindow.showInfoWindow();
}
To force InfoWindowAdapter.getInfoWindow call and create ViewGroup containing ProgressBar and ImageView from progress and image values inside model.
As always, translate this into C# world.

How do I pass custom data to Google Maps v2 InfoWindowAdapter?

I am trying to take advantage of an InfoWindowAdapter to provide custom content for the InfoView. I'm pulling down a JSONArray from my web service and adding the Markers but I'm not seeing how to pass the detail to the call back via a Marker.
#Override
public View getInfoWindow(Marker marker)
In the Javascript API I was able to just set arbitrary marker info. I want to be able to pass info that can be used as conditionals for the custom content, example a marker.status string. So something other than title etc. The view will need a number of custom fields I need to pass in.
perhaps try adding your info or object to the marker as explained here:
http://bon-app-etit.blogspot.be/2012/12/add-informationobject-to-marker-in.html
Edit: I also made a post that continues the previous to use the InfoWindowAdapter.
Check it out here!

Categories

Resources