Skip to main content

Samsung Galaxy S5 ringtone and notifications sounds not working anymore after upgrading to Android Lollipop

Your beloved Galaxy S5 ceased talking after the latest android update? Fear not, for this is a common problem due to one of the new features of Google operating system’s fifth installment: we’re talking about the improved Blocking Mode, featuring a new option not present in the previous versions. As you probably already know, the Silent Mode option blocks the ringtones and the notifications for all of your contacts, while placing a “no parking” icon to the upper left.

To make this feature even more useful Lollipop added a new Priority option, which gives the user the chance to activate the Blocking Mode while excluding the contacts present in the Favorite list. This means that your phone won’t react to any incoming call or notification, except those sent by our own priority list.




A very useful feature indeed, let alone the fact that it tends to auto-activate itself after many upgrades: that’s why many user have seen their device suddendly stop working, without giving any visual evidence of what is actually happening: the new feature’s icon, which resembles the favorite star, is also rather misleading and doesn’t really help to understand what’s going on.

Read More

Android: proportionally stretch an ImageView to fit the whole screen width while maintaining its aspect ratio

Proportional image resizing is a fairly common scenario while developing an Android app: there are a number of situations where you might want an image to stretch itself to horizontally fit the whole screen while keeping its original aspect ratio. You might think it should be easy: sadly, it’s not.

The problem

Achieving this result in HTML would be extremely easy: we just need to set our image width to 100% and avoid to set any height, letting the browser doing the whole proportional resize job. Unfortunately, Android wears a different pair of shoes: the ImageView element containing your drawable resource (or downloaded file) requires a width and an height: we can give a fixed number in px, dp or other supported units, use the parent width with the match_parent command or use the actual image width using the wrap_content command: as we can see, proportional resize is not an option. We can achieve some decent results by setting android:layout_widthandroid:layout_height and android:scaleType to make them adapt to the container layout in the following way:

These values could work in your specific scenario, but they tend to give inconsistant results among different devices and, most importantly, among different image sizes/ratios.

The solution

Why should we use a plain ImageView? We can start by taking a look to this interesting post on StackOverflow showing how to extend a View in order to achieve a very similar result: then we can use that knowledge to build our own ImageView extension class. Here’s an example of a ProportionalImageView which automatically scales its height according to its computed width keeping its original aspect ratio intact:


And this is how we can use it inside an XML layout:

Just remember to replace with your app namespace and you should be fine.

Happy coding!


Android SDK: when Eclipse hangs on “Resolving error markers” or “Android SDK Content Loader”

Any Android developers who chose to not adopt Android Studio and continue using Eclipse will eventually face the dreadful problem of the workspace not loading properly. The most common jobs who tend to get stuck are: Android SDK: Resolving error markers… and Android SDK Content Loader, which sometimes hangs at 0% or 100% of their completion and also tend to completely block the GUI when it’s the case.

The first thing to try when this happens is to run Eclipse with the -clean and -refresh command-line options enabled:

There is a fair chance that this simple method will solve the issue. Since it tends to happen a lot it would be advisable to put the trick in a batch file in the Eclipse root folder (i named mine eclipse.clean.refresh.bat):

There are, however, scenarios in which this method doesn’t work. When such situations arise we need to switch to a more aggressive approach, deleting the cache files built by the SDK in the .android folder which is located inside the current user profile files. Here’s the updated batch file to fullfill the task:

Before executing any of these commands ensure that the Eclipse process is properly closed, otherwise the files and the workspace will be locked: if you cannot do that gracefully, use the “Kill Process” option in Task Manager instead.

Allow the download of APK files within IIS (avoiding 404 errors)

When you’re developing an Android App you’ll most likely want to give someone – the customers and/or beta-testers, colleagues, etc – an URL pointing to an .APK file not (yet) present in the Google Store Market. Since the vast majority of web servers (including IIS) don’t natively support the .apk MIME-type, your URL will most likely give an apparently odd 404 – Page Not Found error response. In order to overcome the problem you need to add the proper MIME-type corresponding to .apk file in the following way:

  • Open the IIS Administration Panel (see picture).
  • In the left panel, click to the entry corresponding to your global IIS instance (pt. 1 in picture) so that each modification you’ll make will be applied to all your past, present and future web-sites. If you only want to handle the .apk MIME-type for a specific web site, click to the entry corresponding to it instead.
  • In the right panel, Click to the “MIME Types” icon. You will be presented with a listing of all currently supported MIME-types.
  • Click to the “Add…” button near the top-right corner (pt. 2 in picture) and add the following MIME-type (pt. 3 in picture):
    • Extension: .apk (be sure to include the dot)
    • MIME-type: application/

(click over the picture to enlarge)

Needless to say, this can be used to allow the download of any other file extension.

If you’re not using the IIS Management interface and/or if you want to work directly on web.config level you can achieve the same result by following the comprehensive instruction explained in the official IIS configuration page.

While you’re at it, if you’re willing to do the same thing with iOS .ipa files you can check this post and wrap it up aswell. If you also need to enable it for Windows Phone’s .xap files, check this post instead.