Programming and general geekiness.

Posts tagged ‘java’

Update to Keep Calm

I updated Keep Calm on Google Play today to version 2.2.5. This new update fixes a couple of bugs and makes poster generation a lot more efficient which should, in theory, mean that the app is a lot less likely to crash – an error reported due to a memory error.

The reason that the app had been crashing for some users (especially those with older phones with less RAM and older versions of Android) was because the background of the poster was being regenerated every time something was changed on the poster. This was a necessary because Keep Calm Pro allows for a greater variety in the backgrounds (solid color, linear gradient, radial gradient and an image) however was completely unnecessary for Keep Calm and therefore lead to an unnecessary Bitmap object hogging up memory.

The two apps share the same class to generate the poster (its called Dunkirk and the majority of variables, functions and classes in the app get their namesake from various WWII battles to keep me entertained whilst coding) so an extra function has been added to this that generates higher quality posters. I also adjusted the resolution the preview as rendered at – by default it is 600 by 900 (this is the export resolution) however if the screen resolution is lower than that it will be rendered at the lower resolution.

Hopefully this update has fixed any bugs that were in Keep Calm which is now within in three/four days of 50,000 downloads :).

Keep Calm on Google Play

Prerequisites for Android Development

I really like doing Android development and over the past few months I’ve done quite a bit of it but I found at the beginning that some things didn’t seem to be entirely logical that were quite important despite the fact that I already had a vast programming knowledge. Here is a list of things I reckon are useful for learning Android development:

  • Java experience: I don’t think that you need to know loads of Java to develop Android apps but I would say it is important that you at least know the syntax and roughly how to do things. Experience in a similar language like C# or C++ would probably get you by, just so long as you know the difference between a package, class and that kind of thing
  • Experience in another object-orientated language: Some experience in another language would also be useful because despite the fact that most Android development is in Java it is useful to understand how other languages do things because a lot of the Android specific Java has had influence from C++
  • An understanding of how apps work: This would probably come with programming experience but you really aren’t going to get anywhere if you don’t get how the most basic apps. Reading a few tutorials can help fix this
  • Experience creating user interfaces via code and and a visual designer: Android uses both XML layouts and pure Java code to create User Interfaces so provided that you have done something in both before you’ll probably be fine. I should imagine that it would probably be OK if you’ve done JavaScript DOM and HTML
  • Basic knowledge of XML and SQLite: You won’t need to know how to do these perfectly but so long as you can create XML documents and edit them. I wouldn’t say SQLite knowledge is vital but it would be good to have some database knowledge
  • A basic understanding of other mobile platforms: I had done a tiny amount of iOS and Windows Phone development before starting Android which probably helped me a tiny bit because it gives you some knowledge of design. Windows Phone development is probably more different to Android than iOS, so even if you’ve just created a calculator in iOS you’ll be in a good position to start Android development
  • Good resources for testing: The emulator is good but I’ve found that it always useful to either have at least one Android device for testing. I also recommend setting up a few different devices in the emulator with different screen sizes and versions of Android because that will give you a chance to test in loads of different environments
  • You’ve read some stuff on Android development: It is worthwhile reading up on Android development before you get started. Android Design and the Android Guide are both good places to start and reading some blogs will probably help develop your ideas. If you get stuck, make sure that you go on Stack Overflow.

Once you are fairly confident with all of this I recommend going over to Lars Vogel’s site which has some great development tutorials.

Get Java Swing to use the Operating System style

Java Swing is an incredibly easy way of designing a user interface however there’s a major problem with it: the default style is disgusting. The default style that shows up is really horrible because it is designed to be a mix of the designs of Windows, Mac and Linux so that a button is recognizable as a button but not as nice as the default style. Thankfully there is a really easy way to change an app from looking like the one on the right to the default OS style on the left. It is worth noting (as demonstrated by the position of the Next button) that this doesn’t always work brilliantly but that it does look better.

All you have to do is make sure you have imported javax.swing.UIManager and then add the following code before you create the interface:

try 
{
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} 
catch (Exception e) { }

This will fetch the OS’ default style allowing you to easily use it in your application. On Mac this application’s menu should display at the top rather than in the window itself, thus allowing your application to look nice on all platforms.