I am making an app and the Google Maps API is a very depending part for me and I want to get a kind of light like this one: http://findicons.com/files/icons/1933/symbols/128/green_light.png
And when the Google maps API is down it changes to a red version of that picture.
greetings
First of all, I think it's safe to assume the Google Maps API won't ever be down. But, to answer your question:
Find the pictures you want to use
Add them as drawables to your app project (java/res/drawable)
Add ImageView to your layout
Add the android:src attribute to your ImageView (in the layout's .xml)
Example:
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/service_online" />
You can also change the ImageView's image source programmatically, more information on that here.
As others said, the Maps API should be present always, but anyway..
You can try to use any method from the API inside a try/catch block inside your app. A simple example:
mApiAvailable = true;
try {
mMapsApi.checkVersion(); // I made up the method name
} catch (Exception ignored) {
mApiAvailable = false;
}
Then for your ImageView (image names are also made up) set the appropriate icon:
mIndicator.setImageResource(mApiAvailable ? R.drawable.api_on : R.drawable.api_off);
You could listen for some location event if such event exists to check the availability again and update the ImageView.
Related
How do i show the standard PositionIndicator from the HereWeGo-App in my MapActivity?
This one:
When i use this Code:
mPositioningManager = PositioningManager.getInstance()
mPositioningManager.addListener(
newWeakReference<PositioningManager.OnPositionChangedListener>(MyActivity.this));
if (mPositioningManager.start(PositioningManager.LocationMethod.GPS_NETWORK_INDOOR))
{
mapFragment.getPositionIndicator().setVisible(true);
}
i get this Indicator:
Is there some other way to create the "HereWeGo-Indicator"? As i know if you implement the Indicator iOS you get by default the "HereWeGo-Indicator".
If you want to use image than do like below
Image img_current_location = new Image();
img_current_location.setImageResource(R.drawable.custom_img);
after that set on PositionIndicator.
Map.getPositionIndicator().setMarker(img_current_location);
And if you dont want to use image at all than create compass header. sample example can downloaded from the below link.
https://tcs.ext.here.com/sdk_examples/CustomPositionMarker.zip
some discussion can be found on this post.
It does not fit in your requirement but you can modify it.
I have just started developing an android weather app and I was wondering how to change activity background automatically. For example, in daytime it should show day time or in the night it should show night photos.
This is the app of Sony which has a feature (mentioned above)
Check the screenshots.
Okay Credit goes to SteD;so for you check this(beginner's guide)
Follow this
//set an ID for Relative Layout in content_main.xml(Android Studio)
RelativeLayout rlayout=(RelativeLayout)findViewById(R.id.rlayout);
if(something){Drawable drawble=getResource().getDrawable(R.drawable.your_image);rlayout.setBackgroundDrawable(drawable);}
//If it works,destroy the upvote
The only automatic way is the newly released (Day/Night theme for android app)
For finer control you check the condition yourself and call the normal Java methods, like this:
if(something) {
getWindow()
.setBackgroundDrawable(ContextCompat.getDrawable(this, R.drawable.image));
}
of if you don't care about the newly introduced context themed styling, you just call the deprecated method (which will keep working without issues for all the foreseeable future)
if(something) {
getWindow()
.setBackgroundDrawable(
getResources().getDrawable(R.drawable.image));
}
In the HERE SDK user guide there is a screenshot showing the next maneuver. See:
https://developer.here.com/mobile-sdks/documentation/android-hybrid-plus/topics/map-guidance.html
Is this something that is provided by the SDK or is the developer expected to render this manually?
Here is the navigation code I am using:
Route route = list.get(0).getRoute();
map.setMapScheme(Map.Scheme.CARNAV_DAY);
map.getPositionIndicator().setVisible(true);
map.setTilt(45);
map.addMapObject(new MapRoute(route));
manager.setRoute(route);
manager.setTrafficAvoidanceMode(NavigationManager.TrafficAvoidanceMode.DYNAMIC);
manager.setRealisticViewMode(NavigationManager.RealisticViewMode.DAY);
manager.setMap(map);
NavigationManager.Error simError = manager.startNavigation(route);
if(simError != NavigationManager.Error.NONE) {
Log.e(LOG_TAG, "Error" + simError);
}
Maybe a bit late, but for the others who are having the same question,
You can use the HERE Mobile SDK UI Kit (MSDKUI) which provides a highly customizable user interface components that can be used on top of the HERE SDKs.
Here is the repo on Github:
https://github.com/heremaps/msdkui-android
Some things are rendered automatically by the HERE SDK, mainly things that are directly tied to the map rendering (like navigation arrows on the street when doing guidance), but most UI things you have to do on your own since most users want to have their own look&feel and UI.
So, yes the maneuver icons are something you have to provide and render in your UI manually (or the other way around: you have the full freedom to decide how it should look like).
I am using UMP example provided by Google, I have not made any change in my code, even I have not tried anything out of the box, I just imported your project into my work-space and checked it on my device, and found that I am not getting Thumb with Genres (Songs by genre) and List of Genres...
Whereas I supposed to get Thumb from our JSON, here is what I have tried (but no success) -
holder.mImageView.setImageBitmap(description.getIconBitmap());
UPDATE # 1 AS PER SUGGESTED BY #NageshSusarla here
holder.mTitleView.setText(description.getTitle());
holder.mDescriptionView.setText(description.getSubtitle());
AlbumArtCache cache = AlbumArtCache.getInstance();
Bitmap art = cache.getIconImage(url);
if (art == null) {
cache.fetch(url, new AlbumArtCache.FetchListener() {
#Override
public void onFetched(String artUrl, Bitmap bitmap, Bitmap icon) {
if (artUrl.equals(url)) {
holder.mImageView.setImageBitmap(icon);
}
}
});
} else {
holder.mImageView.setImageBitmap(bitmap);
}
holder.mImageView.setImageBitmap(description.getIconBitmap());
and getting Cannot resolve symbol 'url'
The icon bitmap may not have been set. It's best to use the AlbumartCache to fetch the icon and then set it on the imageView. The url to be passed to AlbumArtCache.getInstance().fetch(url,..) is description.getIconUri().toString()
The reason you may not be seeing it in uAmp is because of the tint being applied to it. You can remove the tint from media_list_item.xml to try out the changes.
Aside: This is indeed by design and the icon is only shown at the bottom when a user selects the item to be played.
This is by design. To keep the navigation cleaner, we decided to not
show the MediaItem icon on the local browsing UI. Other browsing UI's
may show it, like Android Auto and Android Wear.
I think you should check it in issues of android-UniversalMusicPlayer. Take a look at comment given by mangini here.
If you want to change uAmp to show the MediaDescription.getIconUri,
set the holder.mImageView at this.
I'm making an app on android, using webview to load google map (using this url for my webview: http://gmaps-samples.googlecode.com/svn/trunk/articles-android-webmap/simple-android-map.html).
but i can't put a marker on that webview, can't somebody tell me how?
http://maps.google.com/maps?saddr=37.423156,-122.084917
The above simply shows the directions screen with missing destination field. If you want the pin to show on a simple map screen do this instead:
http://www.google.com/maps?q=37.423156,-122.084917
Clearly lots of ways to skin a cat - but I am loving the Google Static Maps API.
It generates a standard image (of desired size) and you can add points/lines/polygons all from a URL.
Whilst I haven't checked the terms, it is clearly possible to cache/store the result.
Documentation: http://code.google.com/apis/maps/documentation/staticmaps/
Example: http://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=14&size=512x512&maptype=roadmap&markers=color:blue%7Clabel:S%7C40.702147,-74.015794&markers=color:green%7Clabel:G%7C40.711614,-74.012318&markers=color:red%7Ccolor:red%7Clabel:C%7C40.718217,-73.998284&sensor=false
http://maps.google.com/maps?saddr=NJ
load URL like this pass address where you want to put the pin