Android – major version 51 is newer than 50, the highest major version supported by this compiler

By: Kevin | August 21, 2014

If you have ever seen this warning while trying to build an Android project and wasn’t sure what to do to fix it, let me save you some time.

“Major version” means Java version. Java 7 = 51 and Java 6 = 50. The code is written for Java 7, and that is something that Android’s dex supports.

 

The simple fix takes you into your project setting and change the version of Java you’re compiling against.

 

 

Of course you need to have Java 7 installed. If you don’t just do a quick google search and install and try the above again.

 

Cheers!

Android colors.xml with transparency

By: Kevin | July 8, 2014

While working on a project I found the need to use transparency in my colors.xml resource file. To add transparency just throw the below Hex value in front of your normal color.

ie. For 50% white you’d use #80FFFFFF. This way the Alpha channel is utilized and you get the desired transparency.

  • 100% — FF
  • 95% — F2
  • 90% — E6
  • 85% — D9
  • 80% — CC
  • 75% — BF
  • 70% — B3
  • 65% — A6
  • 60% — 99
  • 55% — 8C
  • 50% — 80
  • 45% — 73
  • 40% — 66
  • 35% — 59
  • 30% — 4D
  • 25% — 40
  • 20% — 33
  • 15% — 26
  • 10% — 1A
  • 5% — 0D
  • 0% — 00

 

Cheers!

Converting an immutable bitmap to be mutable in Android

By: Kevin | June 11, 2014

I ran into this error while I was working with a custom view that allowed users to draw on a image using their finger.

java.lang.IllegalStateException: Immutable bitmap passed to Canvas constructor

I found the quick fix is to just make a copy of the original bitmap and pass a true boolean which is the flag to make the copy mutable.

Bitmap immutableBitmap = coming from where ever your source is....
Bitmap mutableBitmap = immutableBitmap.copy(Bitmap.Config.ARGB_8888, true);//<--true makes copy mutable 
Canvas canvas = new Canvas(mutableBitmap);

Easy peasy!

 

Documentation here.

ImageButton not displaying drawable correctly – Android 4.4.2

By: Kevin | March 29, 2014

While working on a project running 4.4.2 I ran into a strange behavior from ImageButtons. I was using standard images from the Android Icon Pack and found that, what appeared random, some images would not display with the correct colors when running on my Moto X. I was developing on my Mac using IntelliJ’s Community Edition 13.0.3 and the images would render with the correct colors from the IDE however when ran on my device I got this.

android icon greyscaled - McGilln.com

I found this really strange. I double and tripple checked that I had put the correct images in the drawable folders. I cleaned the IDE, restarted, deleted the images and re-inserted, nothing worked. Giving up for the weekend I came back to the issue and found what is a very simple fix. I noticed that all images in the Android Icon Pack have the naming convention “ic_some_action.png”. I changed the names of all my images to single words, all lowercase, with no underscores (“_”). So, “ic_new_image.png” became “newimage.png” and “ic_camera.png” turned into just “camera.png”. For some reason this did the trick, the next time I ran on my device I got this.

android icon greyscaled - McGilln.com

I still don’t know why this happens however I now rename all my images to single words before putting them in there respective drawable folders.

Cheers!

Android Tablet – Google Play – your device isn’t compatible with this version

By: Kevin | March 11, 2014

After a year of having my Android app, on the Google Play Store I decided it was time to up the anti and redesign the app to make use of new API’s and in particular tablet optimization.

After all the coding was finished it was time for the easy part, publishing to Google Play. I had developed and tested the app on a Samsung Galaxy Tab 7.7 (SCH-I815) I went ahead and published to the store. Once active I opened the store and noticed I could not find my app while on the tablet but I could on a phone. I opened a direct link and found the message “Your device isn’t compatibly with this version”.

This obviously is wrong. I developed all the tablet specific features on the same tablet, clearly it has worked. After Google’n my heart away I finally came across a section in the developer console talking about optimization and that I should develop my app for tablets. This struck me since I thought I had already done this. I was directed to which goes over hardware requirements. Then this line hit me with light bulb status.

…here’s the proper way to declare a dependency on android.hardware.telephony, such that you can still distribute the app broadly, even to devices that don’t offer telephony:

<uses-feature android:name="android.hardware.telephony" android:required="false" />

BINGO!! YOU NEED TO EXPLICITLY STATE IN THE MANIFEST YOUR APP DOESN’T NEED TELEPHONY TO OPERATE CORRECTLY I already had been using the below and thought that covered my bases however you need to explicitly say phone operation is not needed.

<uses-permission android:name="android.permission.CALL_PHONE" android:required="false" />

Keep in mind that

uses-feature

and

uses-permission

are different! I thought by setting my CALL_PHONE to false I was done. Really this is asking “Can I have permission to place a phone call” where as the option is saying “It doesn’t if this device has phone hardware because I won’t need it anyway”.

So why could I test and develop the app without having the in the manifest this whole time. Because the Android system doesn’t look at these tags at all. These tags are put in there for filtration purposes to be used with Google Play and other distribution stores. By adding

<uses-feature android:name="android.hardware.telephony" android:required="false" />

to my manifest simply told Google Play it was ok to let devices without phone hardware to download this app. A bit long winded but now my app is available to tablets on the play store!

New Features Coming to ARL of IA Android App

By: Kevin | March 29, 2013

Dear Android Faithful,

I’m going to come clean with you, I feel like the Android version of the ARL of IA app has gotten the short end of the stick. As I’ve mentioned in a previous post my first smartphone was an Android based phone however for nearly the last two years I have been using an iPhone for my everyday tech companion.

 As result I have the latest and greatest unpublished versions of the ARL of IA app on my device at all times. I am constantly improving things and noticing things that could be better (little things make a big difference). For this reason I think you Android users have sort of gotten the shaft. BUT, good news! A friend of mine recently upgraded their phone and gave me their old Motorola Droid Bionic with Android 4.0.4 (My last Android had 2.2).

I am taking it upon myself to deliver the best version of the of the app yet! I have decided the only way I can accomplish this is to carry an Android with me on a daily basis. The Droid Bionic will soon be my main device so I can credtequic the Android version of the app as I get to on the daily for the iOS version.




Here is what’s “in the works” for ARL of IA 1.4 for iOS soon to be published. These features along with subtle other changes will also be added to Android.

  1. Favorites List: Every animal can now be ‘Favorited’ which will save the animal to a list which can be edited (ie. reordered, deleted, ect). Although the favorites list can’t guarantee the animal will still be available when your ready to take him or her home it will let you know if he or she is still available. In the event an animal that is saved to your favorites is adopted, the Favorited animal will still appear, greyed-out, in your favorites list and inform you that the animal is no longer available (No more wondering where it went).
  2. All Animals List: Like browsing all the animals? Now you can from a consolidated list. 
  3. Searching: If someone ever tell you to look up “Izzy the cat,” your only option is to scroll through the entire list of cats (unfortunately, always the longest list). You can now search by Name, Gender, Breed and Age. I admit the search option isn’t perfect, but it is a nice improvement.
             Search Tip: If you search by age, make sure you search how ages are show in the pet profile. ie. If you are looking for a two year old cat, go to the cats list, click on the search bar, and type “2 years”. If you try to search by typing “Two years” the results won’t be what you intent.
  4. Performance and bug fixes: I found areas of code that were not as efficient as they could be and I’ve updated it. Hopefully you notice that the app is a little snappier when your navigating.
  5. Save Images: Added the ability to save animal images directly to your Camera Roll. Click the “Share” button in animals details page and click “Save Image”

iPad optimization, Favorites list, search and other features coming soon!

By: Kevin | March 12, 2013

If you’re anything like me, then you’re probably tired of looking through the list of adoptable animals, finding one you like, only to check back later to find that its no longer on the list! You’re in luck! As my iOS knowledge continues to grow, the ARL of IA app gets even more awesome!

Here is what’s “in the works” for ARL of IA 1.4 for iOS:

  1. Favorites List: Every animal can now be ‘Favorited’ which will save the animal to a list which can be edited (ie. reordered, deleted, ect). Although the favorites list can’t guarantee the animal will still be available when your ready to take him or her home it will let you know if he or she is still available. In the event an animal that is saved to your favorites is adopted, the Favorited animal will still appear, greyed-out, in your favorites list and inform you that the animal is no longer available (No more wondering where it went).
  2. All Animals List: Like browsing all the animals? Now you can from a consolidated list. 
  3. Searching: If someone ever tell you to look up “Izzy the cat,” your only option is to scroll through the entire list of cats (unfortunately, always the longest list). You can now search by Name, Gender, Breed and Age. I admit the search option isn’t perfect, but it is a nice improvement.
             Search Tip: If you search by age, make sure you search how ages are show in the pet profile. ie. If you are looking for a two year old cat, go to the cats list, click on the search bar, and type “2 years”. If you try to search by typing “Two years” the results won’t be what you intent.
  4. Performance and bug fixes: Ever notice if you scroll really fast occasionally an animals image will  appear on the wrong row? Well I have, and I’m happy to report I have found the source of the problem and corrected it. I’ve also found other areas of code that were not as efficient as they could be and I’ve updated it. Hopefully you notice that the app is a little snappier when your navigating.
  5. Save Images: Added the ability to save animal images directly to your Camera Roll. Click the “Share” button in animals details page and click “Save Image”

iPad Optimization

My beautiful bride bought me an iPad mini for Christmas (Score!!!). Naturally the first app I downloaded was ARL of IA! It was nothing new, worked the same as on my iPhone. Great right? Not for me, the “2x” button to blow up the size of the app bothers me.  After using my iPad awhile and seeing all the apps that were made specifically for the iPad, it became abundantly clear that I had to built an iPad version of ARL of IA. All the features mentions above are included in the iPad version as well.

Testing
Both ARL of IA for iPad 1.0 and ARL of IA 1.4 are currently being tested. Once final bugs are worked out I will submit both apps to the App Store.

I hope you enjoy all the hard work I have put into this project.

I would like to thank my bride for her patience for all those nights and weekends I have spent coding, researching and in general not paying attention to her because I was working on these apps. LOVE YOU!!!

Rounded images on Android

By: Kevin | January 28, 2013

I’ve decided it’s time for an update to change some things that have bugged me. Like many things, there is more than one way to do just about everything, but here is what I ended up with.

The first thing I’ve changed was was the annoying “Loading” pop up when you start the app. You still need to wait for the information to download from cyber space (aka the server) but the benefit of this is if the information is already in your device’s memory, then it doesn’t block you from getting on with your business and the info will update as you browse.

Secondly, If you close the app, then open it up more than 10 mins later, the app will automatically refresh the animals for you (but not block the screen). Nice little update, right?!

The next thing I wanted to do was customize the app a little, make it look pretty. My first smart phone was an Android and my 2nd (as of this post) is an iPhone 5. There are things I love about both but I must say the #1 thing I like about iOS is the attention to detail and beauty. I must admit I am very impressed with Android 4.0+ and the improvements since I had mine (2.3). Anyway, one thing I love about iOS is how all images, and views in general, never have 90 degree angels. Images are almost always nicely rounded.

I researched how to round image corners in Android and it came down to two options. One being via XML, which amounts to being basically an optical illusion. The XML approach turned out to be to hard and not because of implementation, but because of the amount of different devices. If the screen size was larger then the rounded images didn’t work and things didn’t look right.

The second option is what I ultimately went with. In this option, I actually manipulate the pixels of the image itself. I searched sites like stackoverflow.com and other blogs and I typically found methods like this: (PS. I did not write this)

  //THIS METHOD ROUNDS THE IMAGES CORNERS  
    public static Bitmap getRoundedCornerBitmap(Bitmap bitmap) {
    Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),bitmap.getHeight(), Config.ARGB_8888);
    Canvas canvas = new Canvas(output);
    final int color = 0xff424242;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
    final RectF rectF = new RectF(rect);
    final float roundPx = 25; //tells you how round to make the image
    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
    paint.setXfermode(newPorterDuffXfermode(Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);
    return output;
    }

This piece of code’s ONLY purpose in life is to round images.

Basically, I used this method on each and every image you see on the app. It sees how big the image is and then chops off the 90 degree corners. SUPER NEAT!

I hope you enjoy the all the updates. Feel free to leave comments.

Hello Cedar Valley Humane Society!!!

By: Kevin | December 10, 2012

My first Android app (ARL of IA) has been a great success!! To keep the momentum going, I looked for another project I have hooked up with the Cedar Valley Humane Society (CVHS or CVHumane) in Cedar Rapids, IA.

My cat, Kibby, adopted from the Cedar Valley Humane Society August 2009.

Like my first app, I’ve donated my time creating this app for the CVHS. My knowledge continues to grow and this time I decided to take on a new challenge.

My goal for the CVHuane app was to learn something new, while more importantly, making a simple user interface for potential adopters to browser available adoptables for the Cedar Valley Humane Society. The app will work with Android 2.2 and up.

Screen shot from Galaxy S III

 

Download the CVHumane Android App today!

ARL of IA Android app experiencing server issues

By: Kevin | September 11, 2012

UPDATE: 9/11/2012 3:15pm CST- the server appears to have gone back up. App should be working normally now. Happy tails!!!   

Around 11 am (CST) today, 9/11/2012, the server supplying adoptable animal information went down. As such the ARL of IA Android app crashes at launch. The server issue is being diagnosed and hopefully a fix will be resolved shortly. In the mean time both Android and iOS ARL of IA apps will be unavailable. Sorry for the interruption and thanks for your patience!

Thanks, kev.

Next Page »