I am starting to develop Android applications and I would like to know if there are any tips for creating lightweight applications. This is my first attempt to write applications on a mobile platform but I hope that my experience in programming will help.
I have in mind the "Better, Faster, Lighter Java" book, but will this be "the" answer to my question? Are there any tips specific for the Android Platform that will allow me to build lightweight applications?
A good place to start would be the Designing for Performance and Designing for Responsiveness documents in the Android Developer Documentation.
Realize that you are coding for a platform with limited memory, so try not to allocate memory unless you absolutely have to. The last thing you want is for the garbage collector to kick in and start eating CPU cycles. Also, quite often "performance" is synonymous with "user experience" so if you have to do anything CPU intensive, do it in the background and out of the UI thread.
Here is some additional information that you might find useful:
Turbo Charge Your UI
Coding for Battery Life
Related
I have build a pinball game in unity 3d for android and for some low mobile devices it is running slowly. I was thinking about hiring a unity expert to lighten up the code so it would run better on all devices.
But I wonder if this is possible. Can you make a game preform better by changing the code? I have to add this was my first unity project and it's very messy.
Thanks for helping
Absolutely, there are plenty of ways that changes to code could yield significant increases in performance, depending on how you're currently doing things.
One of them is object pooling when dealing with frequent creation/destruction of objects, another is caching component references when they are used often every frame. And if you're still using OnGui for your interface, probably avoid it in favour of the new (as of 4.6) GUI system. But you haven't included your code in your question, so I can't give a definite solution for optimizing your code.
Chances are though, not all of your code is problematic, just key scripts. My suggestion is to take a look at the Unity Profiler to determine which areas in your code are slowing down your game the most, then take steps to try reducing the execution time. You should also take into consideration non-code problems (eg. With lighting, geometry, materials, textures). Take a look at the guide Unity provides for ideas on how to address those
If you're still having problems, then you can bring that specific code to StackOverflow and see if it can be further improved. Hope this helps! Let me know if you have any questions.
I'm new to android and i started to develop a game, I thought about memory management when loading images and using them for animations, I want to know how to manage it properly so it wont damage the game's smoothness, How could i proceed with this?. And while I'm asking about game development is it a good idea to start with a new framework for all the calculations,physics and graphics?
If you want to start gaming development on Android, I recommend you use a game framework built on top of OpenGL-es
Look into LibGdx, it s a great starting point, so you don't reinvent the wheel and get productive right away:
http://libgdx.badlogicgames.com/
When it comes to memory management in Android, the thing to keep in mind is that Java has automatic garbage collection. So, as long as you don't maintain a reference to images and animations after they're no longer needed, they will get garbage collected and removed from memory as needed.
The Android Developer docs contain much information related to memory management and performance: http://developer.android.com/training/best-performance.html
Another thing to keep in mind is that the complexity of your layouts has a dramatic effect on app performance. Try to keep your layouts as flat as reasonably possible. This is explained here: http://developer.android.com/training/improving-layouts/optimizing-layout.html
If you are new you definitely shouldnt start off by making your own framework bro, its just way too ambitious.
Go for OpenGL or a library like that as the other answer said for a game with 3D graphics, or even no graphics framework if its a very simple game that doesnt need that. It really depends on the kind of game you have in mind.
Check this for memory management tips: https://www.youtube.com/watch?v=McAvq5SkeTk
What will matter the most though is optimizing the animations for smoothness, check this for tips on this and general guidelines for what you want: http://developer.android.com/guide/topics/graphics/overview.html
Personally, I enjoyed using Unity3D to develop mobile games. It will handle those types of memory issues for you.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed last year.
Improve this question
Is it really important to know algorithms to build mobile applications? I have strong understanding of development tools and design pattern as well as strong knowledge of OOP and MVC.
So, is it required to know hardcore algorithms to become a good mobile application developer?
I can understand that if you want to create games then YES it is obvious that we must know all the AI related algos to be competent. But I am asking for just simple data driven application building.
Every computer program you write implements an algorithm or a set of algorithms. If you are concerned with the quality (deliberately vague term) of your programs then you have to be concerned with the quality of your algorithms.
For example, if you want your program to be fast (which is a quality that a program might have) better choose a fast algorithm than a slow algorithm for the same problem. If you want your program to fit into a small amount of RAM (another quality factor) best choose an algorithm which operates in a small amount of RAM rather than one which gobbles it up by the GB.
So, critical knowledge for a software developer includes the knowledge of how to analyse an algorithm for speed, memory usage, and all the other quality factors you might be interested in optimising. One way of analysing an algorithm is, of course, referring to texts which tell you what you want to know.
I conclude with the assertion that yes you do need to know hardcore algorithms to be a good developer, I don't see any reason to modify my belief when it comes to mobile applications development. Of course, I don't expect you to know all about all the algorithms there might be, but the principal ones found in all the basic text books, and the ones which are specific to your application domain, hell yes you gotta know those rascals !
I think it's irrelevant being for the mobile area or not. You should always try to achieve the best possible solution (there aren't perfect ones). In the mobile area, particulary, performance is very important, because we are talking about small devices, that although in recent years have been getting a major hardware boost, you should always take special care. I always use memory leaks to check if something is wrong with what I do. I also check the heap memory to see if there is something consuming too much memory. Battery is also a concern and you should also test if your application is using too much.
At the moment I am really focusing on the architecture of the application, a working application in the current standards (at least on my owns) is not enough. Knowing patterns is a powerful tool, and you should read about those (one of the best is this one). Maintenance's costs are a major factor these days, and you should try to achieve the maximum code reusability and cleanness. Always assume that the client will change spec and always keep in mind that someone else in the future will maintain your code, so avoid long methods and over complex code (unless you have to do it). Also remember to leave comments, even if something is really simple, be humble... In a month you might not now what that "simple" stuff did. Those things are fairly easy to achieve when you are starting a project from scratch but a pain when you need to start thinking about those when the project is going to production in one week..
So as for your question: is it required to know hardcore algorithms to become a good mobile application developer?
My answer is: No, it helps, but there are others important parts when developing, besides algorithms.
Good algorithms can have a direct impact on battery consumption for your phone as well as how much of a memory footprint it has. Every developer should strive to use the best algorithm possible, but that doesn't mean it is absolutely necessary.
The smaller and more resource constrained your platform the more important it is to know algorithms. So on mobile it would be even more important.
Just curious. I am already a Java android guy but am interested in the new app inventor beta for android.
I was wondering what "real" developers are thinking. A lot of people want to develop an android app but don't really have programming skills. Seems like a lot of apps could be written with app inventor - not sure since I haven't tried it yet.
Hopefully this clears up some things for people that are still just hearing about App Inventor. (Keep in mind App Inventor is extremely beta right now, so all of this is subject to change.)
If you're interested in playing around with some of the features it offers and haven't had the time or interest to get involved with the full Android SDK, then App Inventor is probably a good fit for you.
The interface of App inventor offers some unique features you won't find in the Android SDK and is pretty easy to get the hang of (make sure to look at the shortcuts for the Blocks editor, or it might start to feel tedious real fast). It has live debugging and live edits to both the interface and the supporting logic. That alone cuts down on time and frustration if you aren't quite sure about the proper way to do something yet and is probably my favorite feature of the whole system. New developers will especially find it rewarding to actually see their changes implemented on their phone without waiting for things to compile and run. It is a huge time saver and much easier to get used to than the traditional compile and wait process you face if you are trying to learn things through the SDK.
It is also quite handy if you have been playing around with the Android SDK and simply want to try something new out that App Inventor supports that you haven't had the time or aren't quite sure how to approach yet. So long as you keep things focused on features that App Inventor supports, this can provide valuable insight into understanding a problem by getting your phone doing something you can see and use in a matter of minutes. That's something even seasoned developers are likely to appreciate.
The real problem is more when you start hitting walls. Walls that you simply can't climb. And you quickly realize that the limits of this tool must be understood or you will probably spend a lot of time trying to do something that just isn't currently possible. Sooner or later your going find yourself in this position if you use App Inventor very much.
All coding is graphical.
Look at some of the demos or screen shots of what's available through the Blocks editor if you don't understand what that means. Setting values in those big colorful blocks is as close to code as you will get with App Inventor, for better or worse.
If you have any previous development experience, you are going to find yourself longing for the ability to do some simple coding to supplement what you are doing. Or at least the ability to export your project and pick up where you left off in Java. Sorry, this isn't that kind of tool.
Your only options when you get to this point are to pick up and start all over in code or forget about it, at least until the desired feature gets added to App Inventor (which may be never). That right there likely to irk a good number of people and turn them off to it.
If you are looking at getting into Android development, I see no problem with starting out with App Inventor. It might even save you hours of effort that might otherwise be spent trying to wrap your head around some concepts that are simple to understand when you do them, but a bit confusing if you are building them for the first time.
If you are a seasoned developer, or looking to make money or gain Android experience beyond just the concepts, this isn't your end destination by a long shot. If you are a student that is new to programming, this is probably a good environment with sufficient challenges and room to play around in to keep your interest for a decent amount of projects.
Despite it's current limits, I still see App Inventor as valuable resource to learning new concepts and as a playground for trying out new ideas. It is proving to be an awesome tool for introducing someone to Android development, and would probably do as good a job as you could ask for when introducing someone to programming in general.
I have been playing with it for a bit and my thoughts are that is is great for:
An introduction to programming. It is not something people can pick up and develop great programs with straight away, it does still require a lot of thought and logical thinking, but it doesn't require people to learn the correct code syntax
Prototyping. As it is relatively quick and easy to develop with (and has live debugging on the Android device), it allows you to prototype and see/interact with it in real time
Quick coding. If you want to develop a program quickly, this might be the simplest tool
As the tool develops, it will allow more feature-rich applications (it already allows integration with other back-end programs, etc.). The screen design right now is very basic, but will be improved soon.
Overall, I think that if you know Java for Android, then you will be able to pick up Google App Inventor within an hour and start making some functional apps. You might find it more suitable for building some apps, or you might prefer to stick with your current tools.
For people looking to start programming, I think it is an excellent introduction. They can concentrate on logic and program design, instead of setting up their IDE, code structure and syntax. Plus they will see results as they code.
To answer your question 'Should I learn it'. I would suggest that you play with it for an evening - that is all it will take you to get a good feel of it.
It probably won't make you a better developer, but all knowledge is good, so it can't hurt :)
I plan to play around with it anyway.
The generic answer to any "Should I learn ..." question is usually "Yes, it can't hurt to know things." From a practical standpoint, I would skip it. These sorts of things are usually nice ideas that never catch on. Sure this might be a neat way for non-programmers to build very simple applications and perhaps a real programmer could build a compelling application with it but it looks like if you are a programmer the benefits to using App Inventor don't seem that compelling.
I haven't checked it out, but I think it might be worth a look to help in UI development. Most software engineers are good at really solving problems with software or coming up with cool ideas for apps, but when it comes to UI design we find a lot of obstacles. At least myself, I've always been used to working with UI Designers.
I honestly don't like tools that generate code, (except WSDL to java or java to WSDL) but pretty much anything else I find myself spending more time trying to trouble shoot an issue when it comes up than the time I would've spent writing the app from scratch...
Appinventor is so easy to learn, I would suggest go for both options.
Concentrate most of your time on your main Dev environment and learn AppInventor, in the background, to give yourself a break.
The advantage of Appinventor is you can put together reasonably complex apps
in a relatively short period of time.
It's also pretty forgiving, for example, if you have a numeric variable, you can treat it either as a string, or a numeric value, meaning you can put together
prototypes pretty easily and quickly.
If you want an app putting together, quickly, Appinventor might be the better
option, if you need something more powerful, more control over you UI etc, then
a more sophisticated Dev environment might be called for.
With Appinventor being so easy to use and learn, you're giving yourself more options.
Considering Eclipse seems to introduce errors I can't find and can't remove--even after using Project-Clean, I'm looking forward to any alternative.
Are there pitfalls or the points to remember while programming for Android? I think the list will include topics on Multithreading, Persistent Storage, etc.
There are many things that could be said here.
The Android videos from Google I/O 2009 cover most of the aspects that should be kept in mind, when programming on Android. In fact, the http://android-developers.blogspot.com/ articles are the source, on which these presentations expand, and seeing them explained from some of the best Google engineers (and as a bonus you'll get a Q&A section) is a must for every Android developer, IMO.
Some of the things that could be mentioned:
Don't use floats, when you can achieve similar results with integers, because Android doesn't have native support for floating point values.
Use the debugging tools extensively, to optimize both performance and maintainability, and to avoid common pitfalls like ViewGroup redundancy in UI design, or unnecessary multiple calls to heavier methods (View.inflate(), findViewById(), setImageResource()).
Bundle your background service calls, otherwise you are waking up the OS unnecessarily and too often, while risking other services piggy-backing your call (which results in severely reduced battery life)
Prefer SAX-parsers over DOM-parsers, you lose time while implementing them, but you win time in your app's performance (and your device's availability)
Keep your UI manipulations on your UI thread, because the interface toolkit is not thread-safe
Keep in mind that orientation change destroys and creates your Activity again (I learned that the hard and painful way - this is how I started to follow the android-developers' blog)
...and many others.
Android Developers has good post about avoiding memory leaks due to keeping Context references. There are a lot of other interesting posts there too.
I wouldn't call them pitfalls per se, but always remember to take into account that this is not a computer that's plugged into a wall that can just be upgraded in various ways. You have an upgrade cycle of about every 2 years (the length of a standard mobile contract these days) and the hardware is (A) not the fastest and (B) static during that time.
Things to take into consideration:
1) How does the things your app does affect battery life? Are you splashing bright graphics all over the place? Running a lot of threads in the background? Services?
2) How much space does your application need to take up on the device? Is the information something that can be kept on a server and transmitted to the device for temporary use only when it's needed?
3) In regards to #2, is your app tolerant of bad/nonexistent network/mobile connections? How does it perform on the EDGE network vs 3G?
I'm sure you can come up with more but this is what I keep in mind while I'm writing my apps.