incentivelabs.de

Blog about nerd stuff, programming and related tools

Things every new Android Developer should be aware of

Published / by glethien / Leave a Comment

Walking through the world you can see mobile devices everywhere and if you are a developer or want to become one, you may come to the conclusion that development for mobile devices seems to be a great idea. You are right! But first make sure you know the following things, which I think are essential for every android developer!

 

Basic understanding of Android Architecture

If you start working on a new platform you should at least read one or two articles about the platform. This applies to android too. You can start with this tutorial which will give you a basic understanding. From my point of view this should be more than enough to know. With this knowledge you are able to understand what is happening and why something works as it is. This leads to better source code and more stable apps!

Java

As you will use Java for developing your apps, you will need a good skillset in Java. If you do not feel secure using asynchrous thinks, listener and other basic Java funcionalities, you should read about basic Java topics and gain confidence, so you can focus on the android related things.

Android Studio

You have the possibility to choose between Android Studio and Eclipse as you IDE. I highly recommend using Android Studio! Its based on IntelliJ and Google implenented a lot of nice features into Android Studio which will make your development much easier and enjoyable. Learn the shortcuts and where to find the important settings, files and make yourself known to the UI tools.

Activity and Fragment Lifecycle

Activites and Fragments will be your be your daily bread. Both of them have a slightly different lifecycle which you should know. The lifecycle is important to know when to load, when to unload or when to cancel open network connection as well as database handler. The official documentation for Android does have a very good description which you can read here. In short: When the system calls the onResume() you should open the database connection and when onPause() is called you should close the connection again (if you havent done before). This ensures that there is no leaked connection which can be abused.

Passing data between Fragments

There are a lot of ways to pass data between Fragments and I would say there are a lot of advantages and disadvantages for each method. Here is the one method I am using.

First I create the Fragement and in give it a static method.

  1. public static MyFancyFragment newInstance(final DataModel model) {
  2. MyFancyFragment instance = new MyFancyFragment ();
  3. instance.setArguments(new Bundle());
  4. instance.getArguments().putSerializable(“DataModelField”,model);
  5. return instance;
  6. }

The other important part is to parse the serializable back into the DataModel and store it in the fragment.

  1. public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  2. View view = super.onCreateView(R.layout.my_fancy_fragment_layout, inflater, container, savedInstanceState);
  3. dataMode = (DataModel) getArguments().getSerializable(“DataModelField”);
  4. return view;
  5. }

Thats it. If you want to create a new instance of the fragment, just call newInstance and pass the DataModel as parameter into the fragment. Your data will be available after onCreateView is called. As this is part of the lifecycle, this method is called for sure! This isnt the best way or the worst way, it is just one way to do it. I recommend to take a look at other approaches and adapt the one which fits most for you.

dp vs pixels

Pixels are the actual pixel on the screen. Pretty straight forward. Problem is that nearly every device has a different resolution. Using pixel it will be impossible to create a resolution independent layout. Therefore Android introduces dp. dp stands for Density-independent Pixels and is a fictional unit for creating UIs. 1dp is roughly 1px on a 160 dpi screen. For any other screen the actual amout of pixel for 1 dp is calculated by the device.

Debugging your app

Android proves the serveral methods for debugging. You have the full log in AndroidStudio, you get crash reports in you GooglePlay Console after youve released you app, but most important is to write your own log outputs. Luckily this is very easy as you just need to call the static method

  1. Log.d(TAG, “onCreate() No saved state available”);

You can set a specific TAG, which is maybe something like network, database, fancyShit or everything else. After that just add a filter for the logcat and you will only see messages with the specific tag. In addition AndroidStudio provides methods for CPU usage, GPU usage and finding memory leaks. You should make yourself familiar with those tools! It will save you a lot of time.

Googles Plans

Currently the process in the world of mobility is very fast, so as a professional android developer you should know what the next fancy stuff is and when it will be available, so you can make use of it. For starters you can checkout the android twitter account or the android developers Youtube channel. Once a year Google is host of the Google IO, a annual developer conference with focus on sessions and lesson about developing for mobile and web with Google.

Material Design guidelinbttes

Users expect a specific behaviour of an app and where to find what. Google tried to make a standart for the layout. I advise you to follow those guidelines, as it will improve the user experience. A coworker once said, that you must assume that the human cursor has at least a 1cm diameter. Image having tiny buttons close together Most likely you will never hit the right one and getting frustrated. You can find the material design guidelines here

Most likely: you wont be successfull

For each of you the most important point: YOU MAY WONT BE SUCCESSFULL

This sounds harsh but this might be the only truth you will need. Currently there are more than 2 million apps! Dont expect to publish one or two apps and land the next hit! This CAN happen and I would be very happy for you if it does, but dont relay on it. Maybe you idea isnt even new. Just take a look at how many clones of CandyCrush you can find on Google Play Store. With more than 2 million apps available, its very hard to find your app! Do it just for you! If you really want to have some more downloads, think about spending money into marketing your app!

Leave a Reply

Your email address will not be published. Required fields are marked *