[Library] BobEngine - Easy to use 2D game engine for Android - IDEs, Libraries, & Programming Tools

Hello, XDA!
I have created my own 2D game engine that utilizes OpenGL and sports many features to help make programming 2D games for Android as quick and simple as possible. I created this engine for use in my own projects but then I thought why no make it open-source? I think other people could benefit from this and input from other developers could help fine tune this thing so it's as good as it can be.
So I gave my engine the name "BobEngine" after my online alias and uploaded the first public release called "BobEngine 1.0 Thingama" to GitHub. That was months ago and now I've finished working on the next update: BobEngine 2.0 Shishka.
I've got a post on my website detailing what's new in update: http://www.bobbyloujo.com/2015/01/bobengine-20-shishka-update.html
BobEngine uses a similar structure to GameMaker games so if you've ever used that you may be interested in BobEngine. BobEngine uses a specialized BobView to display the content of Rooms. Rooms are collections of GameObjects which each have a graphic and attributes such as x and y positions, width, height, angle, frame, etc... Rooms and GameObjects also have step, newpress, and released events built in. The step event happens each frame, the newpress event happens when a new pointer is touched on the screen, and the released event happens when a pointer is lifted from the screen.
There are many other tools included with BobEngine and the best way to start learning how to use them is have a look at the examples that are included! In the GitHub repository you'll find an Android Studio project called "BobEngine". This project contains the "bobEngine" library module that you'll need to include in your own projects if you want to use BobEngine. Also in the BobEngine project are modules for each of the included examples. Currently there are examples that demonstrate the structure of a BobEngine game, how to use input from the touch screen, and how to manipulate the camera. I'll be creating more examples in the future to show off all the things you can do with this engine!
All the methods and data members in BobEngine are internally documented and the examples include a lot of internal documentation to help you out as well.
I'll keep updating the library with new things as I think of them. If there is anything you think should be added go ahead and post about it in this thread.
Benjamin Blaszczak
a.k.a. Bobby Lou Jo
@Bobbyloujo on Twitter
Edit: Forgot the GitHub link: https://github.com/Bobbyloujo/BobEngine

@Bobbyloujo
Thanks man will try this today and welcome 2 xda :highfive:

Thanks sir...pls give us some game template made from your lib

Great job man. It looks great.
I will try as soon as possible
Sylvain

Thanks man. Will surely try it out. good work.

Awesome, just what I've been looking for. Thanks!

nice work, and thanks for putting your time and effort into it.
Could this be used to recreate "biomenace" for android?

Thanks everyone!
@berlyshells Anything you want to see in particular? I could probably throw together a Flappy Bird clone real quick or something...
@verbuyst It certainly looks doable if you put the time and effort into it.

Bobbyloujo said:
..
Click to expand...
Click to collapse
im not really looking for anything in particular..probably any game source with comments (of the functions/what for is this code etc..) inside the code would be nice haha i just requesting but its you're choice sir im sorry im just a newbie
TIA

A new example has been added to the repository per @berlyshells request. This example is called Jumpy Bug and it is a Flappy Bird clone. It demonstrates what a full game programmed with BobEngine looks like.

Bobbyloujo said:
....
Click to expand...
Click to collapse
thank you very much sir..you are indeed a good hearted person..this is what i really love on xda

While working on my most recent project I made a few changes to BobEngine. The changes have been uploaded to GitHub.
Changes:
The extra functionality provided by BobActivity has been moved to a new class - BobHelper. A BobHelper can be used by any activity. When using a BobHelper, be sure to call its onResume() method from your activity's onResume() method. BobActivity still functions the same way it did before. BobHelper is useful for when you want to use some other kind of activity has your application's main activity but still want the extra functions from BobActivity. For example, if you want to use BaseGameActivity from the BaseGameUtils library for Google Play services.
SplashActivity has been totally changed because, frankly, it sucked before It is now an abstract class. Create your own activity for showing splash screens and extend SplashActivity. Implement the setup() and end() methods. In the setup() method, call addSplash(R.layout.your_splash_layout, time_in_ms) to add a splash screen to show as defined by an xml layout. You can add up to 10 layouts. Add them in the order you want them to show. The end() method is called after the last splash screen has been shown. In the end() method, start an intent for your main activity and then call finish() to close the splash screen activity.
Other small changes.

How many games have made using library? Looks cool)

Thanks..I tried AndEngine and it failed to import on my Android Studio.

Marshal3 said:
How many games have made using library? Looks cool)
Click to expand...
Click to collapse
Uhm... about three. There's Plane Popper, Crazy Taxi Driver, and I just finished Bounce the Beach Ball. Other than that, I've made a few examples that you can find in the repository - including a Flappy Bird clone. Also, I've been working on a platformer.
basil2style said:
Thanks..I tried AndEngine and it failed to import on my Android Studio.
Click to expand...
Click to collapse
Let me know if you need any help with BobEngine!

Hello again, XDA!
I've updated BobEngine again. This update brings the following major additions:
Gamepad support! You can now get input from any standard gamepad using BobEngine. A new example has been added to the Android Studio project that shows and explains how to use this new gamepad support. The example is called controllerexample.
Multiple quads per GameObject. Up until now, a GameObject consisted of a single textured quad (well, two triangles that form a quad). Sometimes it is useful to have many quads grouped together. If you use this, note that all the quads for each GameObject must have the same graphic. This is a very niche feature that I added for a particular purpose but didn't end up using myself. If you'd like an example of what can be done with this, let me know and I'll make one.
Some other miscellaneous stuff has been changed as well. It's been so long since I posted an update that I forget everything I changed! One useful change I made was to the camera features. Rooms now have their own camera values, meaning if you change the camera in one room, then switch to another and change the camera there, then switch back to the first room the camera will be where you left it in the first room.
BobEngine can of course still be found here on GitHub: https://github.com/Bobbyloujo/BobEngine
Here's a video showing off gamepad support: https://youtu.be/vRdaaaJnqGk
As always, if you have any questions feel free to ask. Also, if you've made anything with BobEngine I would love to see it! Whether it's something big or something small I'd love to see how others have used my engine
If you haven't already, please follow me on Twitter. My handle is @Bobbyloujo and I post updates about the games and things I'm working on there pretty frequently. Right now I'm working on something pretty big!

Another new update today!
Changes:
* TextDisplay object added! TextDisplay is a GameObject that can be used to output text! Text can be centered, aligned left or right. A new example has been added to show how this new object can be used.
* A new 'visible' attribute has been added to GameObjects. Setting gameObject.visible to false will cause the object to be hidden so it isn't drawn.
* The getAngle() function in Room.java was broken. It has been fixed so now getAngle() and getAngleBetween() both work properly.
* The getRatioX() and getRatioY() functions sometimes would not work properly on some devices. This has been fixed.
* When using multiple quads per GameObject, the performance has been increased. This was done by collecting vertex data from the quads in a way that does not require the concatenation of many arrays.
As always, the repository can be found here: https://github.com/Bobbyloujo/BobEngine
It'll really help me out if you follow me on Twitter: https://twitter.com/Bobbyloujo
And like my Facebook page: https://www.facebook.com/BobbyLouJo
If you have any questions or would like to report a bug, please leave a message in this thread or PM me on XDA, Twitter, or Facebook.
Have a great week!!

Version 3.0 Bobsled
It's been a while, but in the time since my last update I've added a lot of new things to BobEngine. Since it's such a big update, I'm giving it a new version name: v3.0 Bobsled. Here goes:
RoomCache - In BobView.java you will find a new static class called RoomCache. As the name implies, RoomCache is used for storing and retrieving instances of Rooms. The nice thing about RoomCache is that you can call getRoom(Class roomType) with any class type that inherits Room and the function will return an instance of that room type, even if you haven't manually added a Room of that type to the cache. The function getRoom(...) will search the cache for an instance of roomType and return it if one is found OR it will create a new instance of roomType using reflection and return that. You'll also notice that there is a getRoom(Class roomType, Object... args) function. If you have created a room type that takes parameters other than (BobView view) like a default Room does, you can use this method to pass the required arguments to initialize a new instance of that room type if need be. The cache holds a specified max number of Rooms. When the cache is full and a new Room is added, the oldest Room is removed. You can make your own RoomCaches, but each BobView has it's own cache with an initial size of 3. To access it from your BobView, just call getRoomCache().
Along with RoomCache, BobView has received two new goToRoom overrides: goToRoom(Class roomType) and goToRoom(Class roomType, Object... args) for switching to rooms retrieved from the RoomCache.
Input events (newpress, released) are now handled on the main thread (same thread as step event). Handling game logic on the separate input thread was causing a lot strange glitches in my games when values were being changed when I was not expecting them to be changed. Now, input will be handled on the same thread just before the step event.
For even more convenience and even quicker game development, a new constructor has been added to GameObject: GameObject(Room room). This will automatically assign an instance ID number AND add the object to the room. What typically looked like this before:
Code:
GameObject object = new GameObject(room.nextInstance(), room);
room.addObject(object);
Now looks like this:
Code:
GameObject object = new GameObject(room);
So simple! The old constructor is still there and behaves the same way for those who want it and for backwards compatibility.
Setting GameObject.visible to false will now hide all Quads belonging to that GameObject. This will not change the Quad.visible field for any Quad. Also, similarly to GameObject, Quads are now added to the GameObject when initialized.
Animations can now be played once and looped for a limited number of times. animationFinished() will return true when an animation has finished playing.
Animation class - a new class has been added to GameObject.java. This class can be used to predefine animations with a start frame, end frame, fps, and loop times.
Previously, I was using 3 coordinates for each vertex. I learned it's possible to use only 2 in OpenGL. Since the 3rd vertex is not needed, I changed the code to use only 2 vertices. I'm not sure if this actually caused any performance improvement.
Graphic.Parameters class - A new class in Graphic.java allows you to predefine Graphic parameters to use with GameObject.setGraphic(Graphic.Parameters params). Useful for when you want to switch between graphics on a GameObject often.
A new method in the Graphic class called setDimensions(int width, int height) allows you to set the height and width of the DPI level image you want to use for setGraphic(Graphic g, int x, int y...). Previously, you would have to use setPreciseGraphic(...) if you had different sized images for different DPI levels that have multiple graphics on them.
Set the color intensity of all GameObjects on a specific layer using Room.setLayerColor(int layer, float r, float g, float b, float a).
Graphics management (this is a big one):
The Room, Graphic, and GraphicsHelper classes have been updated to improve and simplify management of graphics for large games. A new GraphicsHelper.cleanUp() method makes it easy to manage graphics. You can choose points in your game to call cleanUp(). When called, Graphics that have not been used recently will be unloaded and removed from the GraphicsHelper. Graphics have a new public field called 'persistent' which when set to true will cause the graphic to remain loaded when cleanUp() is called. All non-persistent Graphics will survive through a set number of cleanUp() calls before they are removed. If a Graphic is removed but then a GameObject tries to use it again, it will automatically be re-added to the GraphicsHelper and reloaded.
You can also manually call:
Graphic.load() to load a graphic after is has been added to the GraphicsHelper.
Graphic.unload() to unload a graphic
Graphic.remove() OR GraphicsHelper.removeGraphic(Graphic g) to unload and remove a Graphic from the GraphicsHelper.
OKAY, I think that's just about everything. I actually had to look through the changes in the GitHub commit to remember all the things I've changed xD There are a few other small changes but I didn't think they were important enough to list. Now I want to ask you guys something:
Is there any interest in a full-blown tutorial series for BobEngine?
I could start with the basics, then explain more advanced features like graphics management. I could also take requests for certain tutorials. I could even cover general game development topics and how to implement them with BobEngine. Doing this would be a lot of work so before I dive in I really want to gauge the level of interest in BobEngine. So far, it's been difficult to tell how many people are interested because I haven't gotten an overwhelming amount of replies here but every once in a while I get a PM or email asking for help. So if you're using BobEngine raise your hand!
And of course: if you've made anything with BobEngine I would love to see it! I've seen a few things and it makes me happy to see you guys using getting some use out of my engine.
Thanks for your time! If you have any questions, just ask. You find any issues with BobEngine, post them here or on GitHub and will fix them. Also don't forget to let me know if you're using BobEngine!
Once again, the repo can be found here: https://github.com/Bobbyloujo/BobEngine
Thanks again,
Ben a.k.a. Bobby Lou Jo
Twitter: https://twitter.com/Bobbyloujo
Facebook: https://www.facebook.com/BobbyLouJo

you are great and i should more from you
I am a new man in the electronic area, and you have developed your own staff, you set a good example for me.

Jackiefire said:
I am a new man in the electronic area, and you have developed your own staff, you set a good example for me.
Click to expand...
Click to collapse
Thanks! Your support means a lot.

Related

Kinetic Scrolling Demo **Updated** KListControl with source

Hi
New around these forums..
I've posted a in-progress of a project I'm working on. It's a kinetic scroller (you know that flick scroll effect). Remember this is a demo it doesn't actually do anything useful apart from amuse me!
Not as fluid/cool as iContact, but it's my first PPC application. The grand plan is to turn it into a library based MP3 player with a decent looking interface.
It's written in CF .NET so if you really need the source reflection is your friend.
Tested on a WM6 blueangel device @ 400Mhz. Runs in the WM2003 emulator
----
I've updated with source. No license, do whatever you want with it. Although a mention somewhere would be nice
Chad get this media player out the door now!
-------
New optimized demo released, source now updated.
Removing old source as the file name is confusing.
Thanks for all the comments.
-------------------------------------------------
**************************************
UPDATE:
gingercat has done some fantastic work loosely based on the original source and created a user control. Unlike my old code it doesn't use one big bitmap and just better written in every aspect. I'll leave my old source up just for reference as to how /not/ to write a kinetic scroller
I can't try it right now because I don't have my device, but it's nice to know that at least a few people still support WM2003/SE...
jackbnymbl said:
I can't try it right now because I don't have my device, but it's nice to know that at least a few people still support WM2003/SE...
Click to expand...
Click to collapse
...especially on wizard..
LOVELY! Why don't we work together to bring your scrolling routine, into my existing mp3 player "Melody". I've got playback and that sort of thing sorted out. Please PM me if you're interested.
anyone care to post a vid plz
slow scrolling and not as responsive as other scrolling software out there... but the idea is there ... i would also love to see smtg similar implemented in chad's media player (just my simple opinion)...
thundershadow14 said:
LOVELY! Why don't we work together to bring your scrolling routine, into my existing mp3 player "Melody". I've got playback and that sort of thing sorted out. Please PM me if you're interested.
Click to expand...
Click to collapse
Thanks for the offer! This is a hobby project and I'd like to work on my own.
However I'm now going to release the source so you can use it..
Kinetic scroller, officially a part of Melody.:
http://forum.xda-developers.com/showthread.php?t=325223
Development
Hi
I was just wondering, how long will it take for you to make your product compatible to play Mp3 Songs, because I'm tierd of waiting for a Music Player, which is easy to use and fast. And by the way, I think your player is so far the best, it just has to get a litle better UI!!!
Well, here I am with release 002 of my kinetic scroller demo.
I've added alot of optimizations and its silky smooth on my 400Mhz device! It even runs great underclocked at 200Mhz.
Source to follow (once its cleaned up, probably tommorrow)
Thanks for this! Once again shows how it just takes one person to come up with a great idea (apple (or whoever initially came up with smooth scrolling)) then we all wonder how we lived without it!
I've just been reflecting over it and note that you are relying on .NET garbage collection to clean up e.g. all the graphics and brush objects you create - you need to be careful about this because this isn't deterministic and you can quickly run out of resources before it gets round to cleaning up. I know you say you're going to clean up the code anyway, but just thought I'd add my tip!
The holy grail would be if we can figure out how to hook mouse events, because then mouse movement can be processed independently of the form (and any other items on it). Unfortunately, CE doesn't support this (that I know of). The form approach only works if everything is semi-custom drawn.
This new version scrolls as good as or better than iContact, so you can remove that message on the first post.
on the other hand, the version currently implemented in melody v0.6 doesn't seem as good as this one.
btw, once you upload the new source, i'll see if i can make it stop selecting the first touched item when you are trying to scroll.
when thundershadow and i were making our own one we found the way to do this was to do something like listbox1.selectedindex = -1
it should be pretty easy to do.
also, something like this instead of the random number generator could get a list of the files in the current dir:
Code:
string[] r = System.IO.Directory.GetFiles(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase),".mp3");
klist = new KList(0, 20, screenX, screenY, "All Tracks");
for (int i = 0; i < r.Length; i++)
{
KItem ki = new KItem(i + ". " + r[i] + ".mp3");
klist.addItem(ki);
}
dunno if that is accurate or not.. haven't used c# that much.. but it should be easy todo.
Source is now up.
I've starting playing around with MP3 playback but please ignore it (Using the FMODCE .NET wrapper)
dosfan said:
Source is now up.
I've starting playing around with MP3 playback but please ignore it (Using the FMODCE .NET wrapper)
Click to expand...
Click to collapse
if you're intending on making it a practical-use app,
probably the best way to go about it is using the shell execute function to open the mp3's in whatever player they associated mp3's to (cos people will want features they prefer than other media players).
and then later on you can add an option to customize the command so the user can use it with a different media player without changing the associations.
so they'd have to make something like: "\SD Card\TCPMP\player.exe /open %mp3path%".
then the app just has to replace "%mp3path%" with the variable for the path to the selected mp3, and launch everything before it to shell.
you'd also need to add something like the code in my last post to get a list of the mp3's (tried it on my ppc and it doesn't work, so it needs to be fixed up though).
chrismrulz said:
if you're intending on making it a practical-use app,
probably the best way to go about it is using the shell execute function to open the mp3's in whatever player they associated mp3's to (cos people will want features they prefer than other media players).
and then later on you can add an option to customize the command so the user can use it with a different media player without changing the associations.
so they'd have to make something like: "\SD Card\TCPMP\player.exe /open %mp3path%".
then the app just has to replace "%mp3path%" with the variable for the path to the selected mp3, and launch everything before it to shell.
you'd also need to add something like the code in my last post to get a list of the mp3's (tried it on my ppc and it doesn't work, so it needs to be fixed up though).
Click to expand...
Click to collapse
Yes, that something I was already considering.
To be honest, I'm not impressed with FMOD's performance. Even just initalizing the library is causing performance issues (without even playing a MP3, does fmod.init() spawn a thread or something???)
I'm looking for a port of MAD that I could interop with. If anyone knows of a libmad.dll for ARM WINCE point me in the direction!
dosfan said:
Yes, that something I was already considering.
To be honest, I'm not impressed with FMOD's performance. Even just initalizing the library is causing performance issues (without even playing a MP3, does fmod.init() spawn a thread or something???)
I'm looking for a port of MAD that I could interop with. If anyone knows of a libmad.dll for ARM WINCE point me in the direction!
Click to expand...
Click to collapse
afaik, performance-wise fmod would be the best library to use.
but the problem is that most people would rather use their own player like tcpmp or wmp that does what they want,
rather than just a basic player with a third-party library in .net cf.
New UserControl version
Hi dosfan,
I have modified the source to create a new KListControl which is a UserControl you can add to any .NET form. All the scroll functionality required is all contained within the new control.
This control doesn't pre-render everything up-front, so should be less memory hungry (especially with long lists) at the slight expense of some speed (runs fine on my hermes).
Each item is now custom drawn, and only needs to support an IKListItem interface - this enables each item to draw whatever it wants, whenever it wants (well, by nicely asking its parent to invalidate it when visible). I have created a basic KListItem object that supports string name, object value (and has the same functionality you provided).
I also updated the project to still compile with the new source, so (if you like the changes) you can continue work from there.
Updates I will still make are:
Better use of statics incase multiple lists are used (currently the background selection image is static)
Common timer between multiple instances of the control (for performance).
Hope you don't mind my changes!
Chris.
i've just modified gingercat's version to launch the selected mp3 using the windows shell.
to test it out you need to create a directory called "\\SD Card\\My Music", or change the variables in form1 and the klistcontrol to where your music dir is.
if the directory doesn't exist it will browse for mp3 files in the app's directory, then grab the folder of the one selected.
this is not a practical idea, and it won't change the variable in the klistcontrol,
so it wont be able to launch it through shell if you use the browsing method.
a better way would be to make it a folderbrowser dialog instead of a file one,
then make the folder variable in form1 a global variable, and the klistcontrol just grabs it from form1.
that still wouldn't work for subdirectories though.
for that you'd need to tag each klistitem with it's full file path or directory when it's being added.
also it should be pointed out that gingercat's version scrolls a bit too fast.
it's smooth so there aren't any performance issues.
it just goes too far with the tiniest tap up or down.
is there any way to capture all mouse events of the system?

Lets Built OpenSource Projects for PPC. 6 Projects Posted. Updated 7th Feb 2008.

NOTES:
The projects if developed will become a generic code baseline for each and every developer seeking codes.
This means projects in this thread is just to give everyone a basic working conceptual code which can be used anywhere in similar projects.
Just think people has great ideas to work on, but they dont have baseline code from where to start as most of them might be learning.
So this thread should help them out giving a working base code..
Any1 interested in building couple of OpenSource Projects for PPC? Ill post concepts.
Lets built next generations of applications together as open source which people can use to learn things as well.
The reason open source is so that everyone can contribute code for a project, and work together to built the best.
Anyone Interested???
------------------------------------------------------------------------------------------------------------------
Project 1: File Indexer for PPC [FIndexer]
Not Sure if it exists or already available.
Added:
01 Feb 2008
Description:
To index each and every file on PPC with custom options on indexing.
Purpose:
In todays world where 1gb,2gb,4gb cards are available, we store tons of file on our PPC like ebooks, songs, music, videos.
Many times it is not possible to search using a search utility as it may consume battery and we need to wait till file is being search.
This is the place where this FIndexer comes in to picture, where we index our file either manualy or scheduled.
And then searching a file will just take 1 second to return the results.
Language:
C++ is best language for this kind of project because of speed.
Database:
Not sure, but either SQL or Access DB.
Type:
Open Source
------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------
Project 2: File System for PPC [PFS (Pocket File System)]
Not Sure if it exists or already available.
Added:
01 Feb 2008
Description:
Idea came from Microsoft new file system WinFS.
Correct me if i am wrong, this File system is a file table itself where it keeps track of each and every files in details in Real Time.
Purpose:
In todays world where 1gb,2gb,4gb cards are available, we store tons of file on our PPC like ebooks, songs, music, videos.
Many times it is not possible to search using a search utility as it may consume battery and we need to wait till file is being search.
This is the place where this PFS comes in to picture.
Why use any indexing software also?, let this File system handle it in real time.
Language:
C++ is best language for this kind of project because of speed.
Database:
Not sure, but either SQL or Access DB.
Type:
Open Source
------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------
Project 3: Tic Tac Toe (x & 0) Game (BlueTooth Enabled)
Not Sure if it exists or already available.
Added:
01 Feb 2008
Description:
This is a game which we always played for fun in good old days and still we play.
We might have wasted good amount of papers to play this game. Classic X & 0
Purpose:
We hardly see any bluetooth enabled games for PPC. Thats the purpose to built a very basic game with 2 players mode on bluetooth.
This may be a good code for all the developers round here who wants to start with some bluetooth code.
Language:
C++ is best language for this kind of project because of speed.
Database:
Not sure, but either SQL or Access DB or XML
Type:
Open Source
------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------
Project 4: Multipurpose Single Line Marquee Scrolling Today Screen Plugin [Like Stock Tickers]
Not Sure if it exists or already available.
Added:
01 Feb 2008
Description:
A today plugin which scrolls like a stock ticker in 1 or 2 lines, and provides useful configurable information like battery info, world time, live money rates, notifications, one liner quotes, jokes, appointments, bluetooth status, and much more, in 1 or 2 scrolling lines.
Purpose:
Many might have noticed too many of today plugin gives a scroll bar to your today screen which dont look good.
This is where this plugin comes in to picture.
This should be completely customizable right from scrolling speed to colors to information to flashing colors speed, bold and much more.
Language:
C++ is best language for this kind of project because of speed.
Database:
Not sure, but either SQL or Access DB.
Type:
Open Source
------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------
Project 5: Application Specific Backup Tool (Can be a great tool)
Not Sure if it exists or already available.
Added:
04 Feb 2008
Description:
There are several backup tools which takes backup of PPC as a whole and can be restored easily, but:
How many times you feel that you had installed tones of applications and had taken a backup of those, and now when you get a new PDA, you feel like you dont want to again install all the applications installed previously due to certain reasons. By restoring the backup you end up again with all unrequired applications again.
This tool will help you to eliminate those problems by taking backup of each and every application configurations seperately with version informations. Yes now you can backup configurations of your games, your theme managers, your music player configurations and everything and have choice to restore them back again seperately as required.
Yes people who develope tools with configurations involved may have to coporate to tell us where they save the data of their application so we coders can add a plugin code to backup that particular application.
You can say that this tool has a builtin database information of most of the application to backup the configs.
Purpose:
Description above says it all
Language:
C++ is best language for this kind of project because of speed.
Database:
Not sure, but either SQL or Access DB or XML
Type:
Open Source
------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------
Project 6: Application data which synchronizes with Web Services.
Not Sure if it exists or already available.
Added:
07 Feb 2008
Description:
Again this is an application which most coders are going to like who are learning mobile codings. This application mainly shows how to communicate with mobile device application with web service to keep data in sync. Data can be either contacts, games scores, or any text based details.
Yes a today screen plugin would be nice to show some information on sync or other details.
Purpose:
To provide generic code to each coder seeking this kind of communication.
Language:
C++ is best language for this kind of project because of speed.
And either .Net or Java for Web Services.
Database:
Not sure, but either SQL or Access DB or XML
Type:
Open Source
------------------------------------------------------------------------------------------------------------------
All Projects should be easily skinnable by anyone.
People willing to part of this project, than please post your details as follows:
Name:
Skills:
Comments:
Once we have a team than we will go ahead and create documents like
RUD (Requirement Understandings Document)
SRS (Software Requirement Specifications)
What do you guys say??
Wanna work together as one, and built a new world for everyone?
Wait for everyone's view, either good or bad.
I am not sure how good above to projects are, but this thread mainly wants every coder, designer, tester to work together and built something.
List of Contributers (Coders, Designer, Tester, Others)
This place will list all the Contributers (Coders, Designer, Tester, Others)
Screen Design for each Projects goes here
Screen designed by contributers goes in this post.
NOTE:All screens designed will be copyright of the designer and should not be distributed or used without a permission.
Attached a Screen for an idea for Project 4
Notice the first Plugin in Yellow border.
Created by me.
List of Features and Request for Features and Suggestions
List of Features and Request for Features and suggestions goes in this post whomsoever wants. Then the team can make it happen.
Builts / Releases
Builts / Releases Goes in this section.
Technical Disscutions
Important Technical Disscutions will be posted and collected in this post.
Intentionally kept blank 1
Intentionally kept blank 1
Intentionally kept blank 2
Intentionally kept blank 2
Intentionally kept blank 3
Intentionally kept blank 3
Intentionally kept blank 4
Intentionally kept blank 4
Intentionally kept blank 5
Intentionally kept blank 5
zbop has done something similar to what you are looking for in number 4. You place info in reg. keys and then update that info via Mortscript (or however you want) and then it gets scrolled on a today screen line. Check out http://discussion.treocentral.com/showthread.php?t=141375 post #269 for the latest version.
more than 600 views but just 1 reply!
I wonder how does open source developers meets and work together
I decided to give this initiative a fighting chance so I am going to 'sticky' this thread for one week.
If there are no takers I will 'unsticky' it.
Unfortunately, I do not currently have time to take part in this project my self as I am learning to program for Linux and OpenMoko specifically.
greenhacks said:
more than 600 views but just 1 reply!
I wonder how does open source developers meets and work together
Click to expand...
Click to collapse
They don't, they start by making something, small, runnable, interresting, then share it, with the source.
This is more than i could expect from this forum. Thanks a lot.
This is a try to bring many great people in this forum and to develop something great for the forum.
Projects mentioned in this thread is just for start.
People can give their own new ideas so all work together and make something great for all the forum users.
i have no other intentions to start this thread other then bringing all together.
Starting this thread i thought i will also put my skills to help new guys.
Thanks again, and i hope this works out.
Here's a project idea that came up in the herald forums - use your touchscreen as a psudo-wacom tablet while tethered. Yes it would only be on/off and wouldn't sense pressure differences, but would still make for a cool project.
Heared of Android?
I guess you have heared about android,an all open-source linux based platform.And about the total of 10M bounty by Google as an award for the top 50 applications tha will be developed for the platform.So I'm guessing any developers with the skills to do such projects will have their hands full.
After all it sould be reasonably easyer to programm for an all opensource platform than for WM,a closed source platform.
Just my 2 cents.
nstamoul said:
I guess you have heared about android,an all open-source linux based platform.And about the total of 10M bounty by Google as an award for the top 50 applications tha will be developed for the platform.So I'm guessing any developers with the skills to do such projects will have their hands full.
After all it sould be reasonably easyer to programm for an all opensource platform than for WM,a closed source platform.
Just my 2 cents.
Click to expand...
Click to collapse
Count the number of applications developed in this forum by everyone for so called 'closed source platform of wm6'
I do agree with your thoughts and dont say you are wrong, but hey thats a whole different ball game.
Always remember
When a company runs out of concepts, then company organises a competition with great prices. At the end company gets thousands of new concepts. winner gets the price, company gets new product.
same thing happens in open source world as well as close sourced.
If all think in this direction then i can bet, xda will run out of members.
not trying to defend, but this is something which simply cannot be debated or this is not a right place.
tene said:
They don't, they start by making something, small, runnable, interresting, then share it, with the source.
Click to expand...
Click to collapse
Then lets make something small, runnable, interresting, and share with the whole world!
It was very dificult to find this kind of groups, thats the reason internet became so famouse, where we can find different people with great skills from different country and make things possible.

Under Dev - CAD application for Android

My team has been vigorously working on a CAD application for android. I will post some screenshots of the tool if anyone is interested, so please let me know.
It's currently being tested and developed using a Motorola Droid running 2.0.1. Although we can run the emulator and test different screens using it, we find great difficulty in knowing if the "feel" is nice on a smaller screen.
Anyway - current features that are working:
Objects: Line, Circle, Ellipse, Rectangle, 3 Point Arcs, Text Areas
Drawing Modes: Orthographic (including 45s), Grid On Off, Snap Mode On Off (Endpoints, Centerpoints, Midpoints, Quadrants)
Other Things: Undo, Redo, Erase, Modify (reshape & move), Pan, Layering System, Linetypes, Colors & Text Sizes.
In The Works: Zoom (Option for Pinch), Configurable Toolbar (Add/Remove Tools), Export to DXF & Linetypes.
We are looking for a few people that would be willing to get in on a "PRIVATE Beta" to assist us with the continued development. We have our day jobs, so this is a project that when we have time to work on, we do. However, we do spent quite a bit of time working on it .
Anyway - We want to be picky about the testers, simply because we need to have a nice round group of people. Not plumpy, just round. We need a couple guys that are good with input, finding problems, etc. And we also need a few that dont know anything about CAD and can help us to see if the average joe can figure it out.
We also need a couple good mathmeticians or programmers. Or even one would do. We are having some trouble computing certain boundaries (ellipses to be more precise) that we need to understand so that we can build in other commands like Trim or Extend. (Plus our select option on ellipses is a bit hokey, but knowing how to find an ellipse will solve that for us)
For now, the only assistance I can give you is through the board here, and help you get started. The tutorial will come soon, once we get the basics figured out as to how we want to make it really work.
Anyway - To make a long story even longer - let me know if you might be interested. I would be more than happy to post some screenshots if you like of its current state. So let me know if you are interested.
Thank you very much for sticking through the long a$$ read, or even for skipping through to the "thanks" is enough for me.
That being said - LMK! Thanks!
A capacitive touch screen doesn't seem a good candidate for controlling a smooth CAD experience. However on second thought, when coupling together this technology with a trackball, the possibilities really open up. Harness these well and I know you'll be onto something here.
Post some screens to show everyone the progress of your development and I'll let you know if I'd be interested in testing.
Cheers
Well if your looking for anyone with CAD knowledge, I have a degree in engineering with CAD, and Pro Engineer. I don't have much time to devote to beta testing, but I do have time every now and then. I run a ION with 1.6. Good luck on your software!
(Unfortunately - my account has not been enabled for posting outside links or images - so this is the best i can do for you until that is enabled)
talon-designs.net/android/andcad/11.jpg
Above is a screen shot with a couple drawn elements, and the right side of the toolbar tools.
talon-designs.net/android/andcad/09.jpg
Above is a screen shot with a couple drawn elements, and the left side of the toolbar tools.
There are a handful of more screenshots posted up on my site, the links are as follows:
talon-designs.net/android/andcad/01.jpg - Layer select screen
talon-designs.net/android/andcad/02.jpg - File Operations
talon-designs.net/android/andcad/03.jpg - Display Settings
talon-designs.net/android/andcad/04.jpg - Samle Help Screen (Line)
talon-designs.net/android/andcad/05.jpg - Snap Settings
talon-designs.net/android/andcad/06.jpg - Color Picker
talon-designs.net/android/andcad/07.jpg - Snapping to Midpoint
talon-designs.net/android/andcad/08.jpg - Selection of Ellipse
talon-designs.net/android/andcad/10.jpg - Text Input Screen
That should be plenty of screens to keep interest.
@Lancealot - Thank you very much, and I completely agree, that when we started this, there was some doubt as to how precise you could actually be using a "touch based" screen. The good news, through playing with it, and given ability to set tolerances based on the size of your "touch area" as well as snapping options, we found that you can actually be quite precise.
Ill fiddle with it a little today, put together a drawing and give you a nice example of something that can be made with this.
Keep in mind, this is a work in progress, and although much of the functionality that is currently built into the tool, is at a "finished" state, there is certainly room for input and comments from others that may find use in this tool.
Anyway - here are the screenshots as promised, let me know if you have any further questions.
(Again - sorry about the inconvenience on the links)
(edit to update image types to jpg instead of png)
@zul8er - we are certainly interested in your input. Check out the screenshots and let me know if you are still interested. We dont need a huge commitment, but anything that you might be able to provide would certainly be a big help.
Android 1.6 is the minimum OS currently supported. We need to do some work on the graphics to go as far back as 1.5 to compensate for screen size, and we intend on doing so.. Just not at this current time.
I would be interested in trying out your CAD program. I've been doing CAD for ove 10 years now, started with AutoCAD but have been using Solidworks for the last 8 years.
In addition to using the touch screen for input, will you be able to enter X and Y coordinates using a keyboard or virtual keyboard?
What format will it save the files? DXF, JPG, or what?
Noob Squared said:
I would be interested in trying out your CAD program. I've been doing CAD for ove 10 years now, started with AutoCAD but have been using Solidworks for the last 8 years
Click to expand...
Click to collapse
Seems there are more and more of us creeping out of the woodwork on a daily basis
Noob Squared said:
What format will it save the files? DXF, JPG, or what?
Click to expand...
Click to collapse
Currently the file format is a proprietary format. But we are currently (today actually) working on saving out to a DXF format to be able to reload your files into AutoCAD or other supported softwares.
The ability to import is also in the works, but will require some massaging on the users end to make sure the DXF file is not binary etc. (MTEXT may not be supported either)
Noob Squared said:
In addition to using the touch screen for input, will you be able to enter X and Y coordinates using a keyboard or virtual keyboard?
Click to expand...
Click to collapse
We have toyed with the idea of being able to put in specific dimensions on objects, and also work with x/y coords, but at this time, it only supports point to point drawing. We arent completely sure if we intend on building a "FULL ON CAD" application, or an application for people to use to simply get an idea of what they need to do for a job. The other key, is to keep the application at a price range that is reasonable for people. Most "PocketCAD" applications run around 50 bucks a copy - and rightfully so. To keep the tool at a reasonable range (below 10 or 15 dollars) it may need to be a bit lighter weight than those. Most people cringe at a 2.99 app..
IF we could devote our time 100% i am sure we could build a really nice full blown cad app Unfortunately as with most of us, the day job prohibits some of that time.
Its a WIP I'll put you on the list. Thanks for the input.
Are you looking for beta testers?
Hi, are you looking for beta testers. I'm a long year CAD user, and I'm sure I can help with the app development.
[email protected]
Have you tried using some of the java based cad software as a source for your project? There are many and some might be open source.
http://sourceforge.net/projects/ycad/
Yeah I am still interested. It will be neat to play with and see how it works. The coordinate input is a good idea, also, ever play with Pro Engineer? They have a cool way of building an initial drawing. You just sketch, regen, and then input your dimensions to make the object to your liking. Makes things a lot faster and easier to edit a shape if changes need to occur.
I dont know how in depth you want to go, or if that idea can be used.
My email is [email protected]
Nice
Give me a couple more days to get a good product out for you guys to test. Currently we are cleaning up a few little "we'll get that later" issues, and should be good to go by mid/late next week.
Thanks for providing the contact info, I will shoot you a message through email shortly.
Thanks agian for the interest.
@zul8er: nice. Look forward to hearing how you like the feel of it. I havent had a chance to play with ProE, as AutoCAD has been my forte for the last couple decades. Ill see if i can any kind of demo for ProE, and get an idea of how it works. Who knows Anything to make it easier for everyone is a good thing.
But yah - the indepth thing is the issue. We keep tossing with ideas and putting them "on the list" in case people start asking for them. I guess it just depends on how people really want to use this tool. (and of course, how much time we can continue to devote to it) - bah i hate day jobs
I enjoyed the screen shots that were posted. Any idea whether you guys will support rendering/raycasting, or physics with inverse kinematics? Either way it looks great; Sign me up!
haha Not sure if we are going to go the IK way. Maybe as a different project, something more suited to 3D, but for this app, we are only intending on running the 2D route.
My lack of knowledge about the OpenGL portion, really limits us with regards to 3D implementation. I spent a good 3 days just trying to get ahold of loading in a 3D model.. Still never got there (or would have probably released a 3D model viewer first).
At any rate, its hard to say where this will go. It mostly depends on the overall interest i suppose. Its certain that the sky would be the limit, if time were as available as the sky
But cool.. Glad I was able to keep your interest.
Currently (as I type even) I am finishing up all of the help documentation for the app, the inline tutorial, and what not.. A couple more days on the file handling (DXF in particular) and should be set to go for a BETA run. ('couple more days' - like we all havent heard enough of that)
@lancelot - can you send me your email address via private message? That way I can do the BETA communications through there (link to files etc). You are welcome to email me as well:
support AT talon-designs.net
cheers!
Hey, I'm a high school student that has just started learning CAD, does that count as average Joe? I'd love to help beta test, I really want android to overpower iPhone 3.0 lol. My e-mail is [email protected] I use g1 with cyanogenmod 1.6...so idk if that qualifies. But anyways, Good luck!
This really sounds promising. In the last few weeks, I really had the need for a good drawing software on my mobile device. But my Tytn II lacks of power. As I soon will get the Desire, I will hopefully have a quite powerful device for all day use (my Tytn II really sux atm). And because I have the re-occurring need of a drawing app, this could be it.
I mean I don't need it for simple drawing, but for constructing things CAD style and on the go Graphics of furniture or something with measures and all that stuff.
Hey guys.. just wanted to pass you an update on status (which is so much more than I seem to be getting from Verizon on the 2.1 update).
Small rant, but its done now.
Ok - status..
DXF Export is working now, supporting layers, linetypes, colors, and elements throughout the drawing. Am having some issues with getting ellipses to export via DXF (and im not alone - faulty specs are at fault), and that combined with the other issues regarding the math behind finding ellipse edges, we decided to comment out the ellipse alltogether for now. Not that it wont be back, but having so many rules with "you can do this to anything - except an ellipse" left us with no other choice.
It's coming back, just not right now.
We have saving and opening completed (simple proprietary ascii format, but it works for what we need it to do).
Zoom is currently partially working (difficult to complete the recalculation on the elements, but its really close) touch events for zoom are coming up as well. Maybe a pinch zoom even, considering that all devices are getting the 2.0+ upgrade - but we will see.. We dont want to keep anyone excluded from being able to use the tool.
@Balrog82 - we have definately taken this tool a long way since its initial conception. We hope to be able to bring more features that are more "CAD Specific" to the application, and will if it becomes a tool that gets used. We want to release it initially as a "basic" drafting tool, and see what kind of input we get. If we see that a lot of people are using it, and would like the ability to put in dimensions the same way that cad does (within limits) we will certainly look into it.
That being said - I hope the tool is still something you would be willing to try out. I find a lot of enjoyment with working with a tool at its early conception (started using paint shop pro at version 1.42) and now its on to version 14 or something and owned by corel. I just kinda get into that sort of thing, and hope that you all will do.
Good thing is, we hope its a draw to the tool, we plan on releasing it at the market both as a free version (no saving abilities) and a full version at a low price. As the tool grows, the price may increase a bit.. Keeping of course the original buyers at a place that they can keep updating the software at no cost to them. We think that will help the advancement and development of the tool quite a bit.
Anyway - It is right around the corner for initial testing. Please to all interested - send me a PM with your contact information (just an email would be great) I am going to see if i can start a private discussion here to invite you all to as well.
@Lancealot - i got your PM.. Am very happy that you are interested in helping. Expect to hear from me again soon..
Until we can see a working model of this app, I thought I would throw out an app that has some great drawing capabilities. The paid was is called "Picso" by Tiki Move, but I used the free version to try out; it's called "Picso Lite".
It's not a CAD app, but it's different from the other Paint apps on Android in that it has tools the other ones don't. It has the usual tools a CAD user would need, such as Rectangles/Squares, Circles/Ellipses, and Lines. You can change the colors and widths of these entities.
What I like about your program is that it has snaps, and the tools are on the bottom of the screen so they are easy to get to: /talon-designs.net/android/andcad/07.jpg
A feature Picso needs is a Zoom tool so you can zoom in to an area and draw whatever you need to and then be able to zoom full screen. It also needs a text tool. Since there is no dimension tool, you could put a text for the dimension.
P.S.,
I want to try your app, but I am only posting this to show how someone else has put these tools on their app and also to have a comparison on ease-of-use. One other thought, you mentioned the files your CAD app will create will be proprietary file types. Will you be able to save-as .jpg or .png so you can email or text-message a sketch to someone? That way if your on-site you will be able to send someone back at the office whatever it is to explain your ideas, and also they would not have to have an Android phone to view it.
Idea sounds great. Good luck with it!
Sorry for being away for so long.. but we had something going on that we had to attend to..
http://developer.att.com/developer/index.jsp?page=event&id=6.3_v1_9700324
More news as it allows.
Android Category Winner
Talon Designs, AndCAD
This application allows users to create simple geometric shapes, combined with notes, to describe plans associated with the art, architecture, engineering and manufacturing industries. Many of the tools familiar to CAD users are incorporated into this utility, meaning that fluent CAD users will feel right at home using this tool. However, the interface for this tool is simple enough for even the most novices of users to understand. This enables certain users (Contractors, etc) to be able to take notes while on a job site and associate them with vector elements within the drawing.
talondesigns said:
Sorry for being away for so long.. but we had something going on that we had to attend to..
More news as it allows.
Click to expand...
Click to collapse
AT&T Open Call-Apps for All! Contest
Thank you to all the participants in the 2010 AT&T Open Call—Apps For All! Contest. This year's contest was filled with many great entries. AT&T reviewed over 90 applications this year ranging from games to business applications. The winners from each category will receive $10,000 and co-marketing opportunities with AT&T.
Click to expand...
Click to collapse
Did you get $10,000?

Changes in SDK 1.x -> 2.x

Hi there
not THAT much threads here related to development questions. Now it's absolutly ironic that I ASK this, cause Im no dev and coded the last small tools in C some 10 yrs ago. I'm a complete and definite noob in C++ ... bada SDK is my first contact with C++. I though it's interesting to try some first steps in bada.
Started in SDK 2.0.2. I found out that code examples in Internet relate to bada SDK 1.x and things seem to have changed here and there. After 3 days I was able to understand structurally what I collected together or found in help.
Question: What did you guys face as difference in 2.0 compared to 1.x?
I wasn't able to invoke the app "terminate()" command. What do I need to include/declare? I'm puzzled. this is the most difficult exit function of all languages I know
I had trouble to insert a photo as the splash screen. You guys have difficulties too?
More philosophic question: What do you think of Samsung, that they gave you SDK 2.0 and even started a competition, while there's STILL NO bada 2.0 device ready? So you can only test in Emulator or Remote ... is it normal in this industry that you don't have access to the target platform while creating an app?
Oh, just want to mention: I'm no competition - I'm too uneducated to code - and no time for a serious app.
Ray
Its simple, alot of things gone easier.
CustomList, GroupedList, SllidableList, IconList, ... all collected to two types
ListView and GroupedListView, they both are using SimpleItems (Image, Text, Option) or a CustomItem as we devs them wish. GroupedItems are in GroupedListView and saying itself what they does, both lists have a fast scroll option and automatically relocating on need their items. The best autoscroll for bigger text in elements and of cousre the behind Context menu for each item which can be changed in different ways if user slides left or right and so on. Finally to update the list, only UpdateList() is needet not after every change every item as i used in badaSI before.
Than we have the powerfull Gallery that provides all featuers to show pictures as you all saw it in badas Gallary App.
Then header and footer, very nice, devs can so made a good basci gui that looks good integreted to the os, the best function of them are the back button option with its listener, it reduces a lot of time.
My pesonal favorit is the extension for animation class, there you can make every thinkable animation for forms, panels, controls and other stuff, with some code lines. So the UIx is improved and no extra code is needet.
I would rather say that the 2.0 sdk makes c++ a lot of easier to use also for beginners, the api itself is self explaining for what it stands, so it is not like old c++ stuff bada SDK makes many things alot of easier than people think. And of course it has more oportunities than other ... and so on.
Push Notifications and some old unaccessable System Privilegs are now free to use for every developer. Auto resolution takes a lot of work from us all devs.
PThread is addet so porting applications from other oses like ios are much easier, in my oppinion useless cause i am not porting i am writing from scratch.
In a whole overview of the new sdk, a lot of new stuff that makes everything easier, and the old stuff is still in there to support older applications. so no visible changes are there if you see an custom list or a listview in voluntas as example, but the behind things made it a lot of easier and better for memory.
And so on....................
ah, so push noti was there before, but only to priviledged partner dev's right?
Lari, you list is your favourites? What of them will help most often? Header/Footer? Auto Resolution to unite higher and lower lever Waves? Let's see if there's still two separate bada versions for the 2 familys.
Ray
So finally I got the Terminate() function up and running ...
In the form.cpp I had to add these:
#include "<myappname>.h"
... to get declaration of my app name
using namespace Osp::App;
... to enable the Terminate function (don't know if the include makes this unnecessary now ... in "<myappname>.h the public Osp::App::Application,
is used as class
<myappname>::GetInstance()->Terminate();
... only with this the function worked.
Is this standard in C++? Help didn't show me this way, and it seems quite complicated for me as a former ANSI C amateur
Ray
hello? zehn zoicha kaesdreck!

[GUIDE] Best Practices for Android Java

During recent development of my app (see my signature) I focused a lot on how to optimize the already working code further in order to make it smoother without loosing quality or using too much memory. Well I came across some mistakes I had made in my early days of developing Android so I figured it might help the beginners and intermediate developers. So here I collected my suggestion of common mistakes and best practices in Android. Let me start by making you familiar with a motto which you might know if you have developed Perl before.
TIMTOWTDI
There's more than one way to do it, in short TIMTOWTDI is a well known aspect of the Perl language, which aims at giving programmers the freedom to choose their way of doing things. It “doesn't try to tell the programmer how to program.” Well it does have various disadvantages such as possibly messy code and barely readable code, but it offers programmers to use their preferred style.
The only reason why I'm bringing this up here is because it helped me a lot to think that way, since TIMTOWTDI sometimes applies to Java as well and a way somebody else is preferring might not be better than your own way. But it is never bad to have a look at how others code the important tasks and sometimes the performance or readability gain is tremendous. So I'm not telling you to exactly use my way, but advice all beginners to perhaps rethink their code .
Tweaking Android Apps
The first step is always to look at what the awesome Android documentation says about performance, so I can more than advise you to read this straightforward article about what to do and not to do on Android. It covers some very important performance issues like the expensive object creation and method invocations. It is crucial to follow those basic rules while trying to develop fast Android apps. I will cover and further explain some of their suggestions here, but will try to also look at them from a developer's perspective who cares about readability and simplicity.
Now onto the code, let's start with some basic Java practices and then move on to some more Android specific styles and improvements.
Looping wisely
Often it doesn't matter if you write slow code and lose 1 or 2 milliseconds but especially in loops and everything that can be called once a frame you suddenly loose a lot of time. Thus it is crucial to especially pay attention to those repeated parts of your code like the onDraw() method in your custom view implementation (see last section) and start optimizing there. Let's take a look at what kinds of loops we have, the slowest first and the fastest ones towards the end:
while
The while loop is probably the first complex programming structure you learned, and just writing
Java:
success = false;
while (!success) {
trySomething();
}
is extremly readable but can potentially run forever or longer than you need it to. One aspect which is often overlooked is that the condition inside the parentheses will be checked on every run of the loop! So even a simple string.length() call can be optimized (if the String won't change) saving its length as an int and then using that in the condition block.
Its unpredictability and lack of possible tweaking done by the JIT makes the while loop a tool that needs caution but is sometimes crucial to complete the task. Just make sure you only use the while loop if there is no way to predict when your condition is false. For almost all other cases, you can do some calculations and use one of the iteration loops:
for (traditional)
This one is widely used like this:
Java:
for (int i=0; i<getSize(); i++) {
doSomethingWithIndex(i);
}
Even though this is more predictable, consider how the program will run: Before every execution of the block, the condition i<getSize() has to be checked, so getSize() is called (and an Android, method calls are expensive!). You could now think, alright, we'll just cache our size upfront like we did with in our while loop, but examine the following fast example of iterating through an array:
Java:
for (int i=getSize()-1; i>=0; i--) {
array[i] = getNewValue(i);
}
The trick is starting at the last value and then iterating backwards until 0 is reached. This may not work at all times, where the order of the blocks may be important or it is redundant due to having a fixed end value, but it saves both method calls and memory usage needed to get the last value before going into the loop.
But that is hardly readable and you often have to rethink because of looping backwards, so we can do better can't we?
for (iterator-based: “foreach”)
Dealing with an array, List or other collection of data you can easily do something for every part in that collection using the foreach loop:
Java:
for (Object item : objects) {
doSomething(item);
}
That is the fastest way you can iterate through any kind of iterable collection because it can be heavily optimized by the compiler and is also simplistic and readable. The only problem here is that you don't have the index of the item you're getting and you can't write data to the collection. To accomplish that one of the slower for loops must be used.
Keywords do matter
This is a minor one that is overlooked often. Beginners in Java mostly don't use keywords and access modifiers like “private”, “public”, or “final”. That is fine since we all love simplistic code don't we? And an honest word, if you don't write a library or work on your code with a big team, you don't have to know much about the access modifiers, but if you want to, there is always the Java documentation. But the “final” identifier is actually pretty important to both the ones reading the code and also the compiler, since it can just insert its value into the references. That means, that whenever you declare an instance variable, think about if it is likely to change or if you can declare it as final. Within methods, making use of the “final” keyword does not really change much for the compiler, but it sometimes helps you make a clearer design so you directly get a compiler warning whenever you're trying to change a final variable's value.
A side note on making “static” variables and fields – I wouldn't recommend that on Android unless you know what you're doing or you're using it together with “final”. A “static final” instance variable is the best way to declare constants in Android because the compiler can replace it fast and ART can replace it during the install of your app!
Strings are special
Let's talk about something that is fundamental to Java – the String object. Well it's not a real object since it is actually immutable. That means a String can only be created or collected by the garbage collector, it can't be changed (which is very important since object creation is god damn expensive in Android so it would make our apps pretty slow)! Wait, then what happens if I call one of the awesome methods in the String class like substring() or replace()? And here comes the downside: These methods have to create new Strings and the old one is collected by the garbage collector. While this might be totally alright if you're just parsing some basic user input, if you need to perform some heavy String operations like many substrings, a whole lot of unused garbage and overhead is created. This doesn't only mean that you are temporarily using a lot of memory, with the garbage collector needed to kick in it also affects your performance.
So how do we get around this problem? Luckily there is a Java class which can do almost the same as the default String implementation, the StringBuilder. This class will hold a char array with all the chars you had in your String. The class can take care of managing that array like initializing it with a default length of 16 and creating a larger array once you have more characters that would fit into it. Take a look at the constructors as well – with new StringBuilder(length) you can directly make that array as long as it needs to be and with new StringBuilder(string) the array is instantly filled with the string. The big advantage the StringBuilder is that it can modify the array instead of having to create new Strings every time. If you're finished with the heavy modifying, just call toString() to get the String back.
If you want to read more about it, here's a nice article.
Android-specific tips
Bundling is better than trundling
Let me explain this with an example: Let's say you are dealing with some data concerning persons so you are saving their name, age and gender. In any object oriented language like Java you would create a wrapper object holding that data:
Java:
public class Person {
private String name;
private int age;
private boolean isMale;
public Person (String name, int age, boolean isMale) {
this.name = name;
this.age = age;
this.isMale = isMale;
}
// additional getters and setters go here.
}
Of course you could do that in Android as well, but you will encounter this problem: What if you need to save your Person array or need to pass a specific Person to another activity? Well, you have a few options available:
You could override the toString() method in Person so it contains all its data and parse your array into a String array manually. Then another constructor will be needed to get the data back from the String using our beloved String operations. But there is still the problem that when you want to add data to the person like height later, you have to reconsider the toString() method and it's constructor counterpart.
Alternatively, wanting to integrate it better into the system, you might want to implement Parcelable in the Person class. That way you can directly put person extras to your Intent or save it to SharedPreferences. But that seems like more work if you want only a simple container for your data. Once you need have a more complex class it might be advisable to make it Parcelable (perhaps using the Android Studio plugin, thanks @nikwen), but let's start with an easier apporach here.
This is how I do it: I use a Bundle instead of a person class to store all the needed data. The Bundle class already implements Parcelable and and simplifies adding data for you. What is more, you are probably already familiar with it since you get one calling getExtras() on the starting Intent of your activity! Now back to the example, this is how it would be done:
To not get confused about all the keys you need, let's create a class containing some static final keys:
Java:
public class Person {
public static final String NAME = “person_name”; // will contain a String
public static final String AGE = “person_age”; // will contain an int
public static final String ISMALE = “person_ismale”; // will contain a boolean
}
While this is only needed for consistent keys, here is how you would create the Person:
Java:
public Bundle getPerson(String name, int age, boolean isMale) {
Bundle person = new Bundle();
person.putString(Person.NAME, name);
person.putInt(Person.AGE, age);
person.putBoolean(Person.ISMALE, isMale);
return person;
}
Similarly, you can get one or more stored values of the Bundle using one of the person.get...() methods. Furthermore, instead of creating an array of Persons you can now create a Bundle of persons using bundle.putBundle()! You just need to find the right key-scheme, here you could either provide an id for each person or just use their names as key (although the key array has to be passed seperately). And what do we get from all this? Well we can now just call intent.putBundleExtra(person) and voilà, we've passed it to another app component.
Resourcing is not outsourcing
One of Android's big advantages is its exceptional resource system. The fact that all your Strings and values are saved in a separate xml file makes your app not only easier to translate, but also keeps your code cleaner and lets you have a complete overview of what amount of constants you use. But you can go further than that. The resources allow for entirely different configurations depending on screen size, resolution, orientation, location and api-level! To learn more about how this can be done, head over to the Android devoper guides.
One thing I wanted to highlight is that it used to be quite hard to make a consistent interface and still support Android 2.1 and above. That is not the case any more since we now the the continuously improving AppCompat library. It is even useful for apps targeting only ICS and above because it contains bugfixes and improvements for those versions as well. Using this library is the best way to get the holo theme and its ActionBar in your app, although if you could also try ActionBarSherlock to accomplish the latter.
Click to expand...
Click to collapse
Think D.I.P
So what's this strange thing they call dip? And why do we even bother using it, we have had pixels (pix) since the beginning of programming. First things first, try to avoid pixels on Android. On almost every other platform using the smallest unit that's available is a great thing in layouts, but not so much on Android where apps can run on devices as small as a smartwatch up to 2k tablets. The problem is that you can't be sure if a single pixel is as small it can barely be seen or as large as a few millimeters. That is why we have the standard-sized density-independent-pixels (dip or dp in short) where 48 dips are roughly equivalent to 9mm, the convenient size of a touchable area (e.g. a Button). Great, then how many dips is my screen wide/high? That is not an easy question since it varies as well. Phones usually have around 320dips (at the smallest width) but larger screens can fit more so on tablets you have 600dips or more. Try to understand this documentation and don't be confused with the abbreviations dp, dip and DPI – dp and dip are the same and DPI is dots per inch (similar to pixels per inch), the screen density!
The reason why I'm bringing this up here is advice you to understand and always think in dips, never in pixels. Even on a Canvas, where there is only methods for pixels, don't think “ok I draw my text 20 pixels from the left edge and 50 from the top so canvas.drawText(“text”, 20, 50, myPaint);”. Start to think in dips: “I have to draw it 16dip from the left edge and 24dip from the top!” But how to convert it to pixels so it can be actually drawn onto the Canvas? It really is a shame there is no method in the Context class to directly convert dip to pixels, so here's the one I use:
Java:
private DisplayMetrics displayMetrics;
/**
* Converts a given dip (density independent pixel) value to its corresponding pixel value.
* @param dips The dip value to convert, as float.
* @return The pixel value, as int.
*/
private int dipToPix(float dips) {
if(displayMetrics == null)
displayMetrics = getResources().getDisplayMetrics();
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dips, displayMetrics);
}
And a side note on sp, that is the scale-independent text size. Try to use it as far as you can, for instance in layout resources. But just in case of needing the actual size, use the same method because sp is computed almost the same as dip.
Hyperthreading is not that complex
An app's UI (or “main”) thread is its beating heart, and we don't want to slow down what's powering us if there are other options available, right? If you don't follow the rule of not performing any time consuming tasks in the default thread you'll end up with what all developers fear: The “App is Not Responding” dialog – in short ANR. When users see this, they can get really mad, from just force closing your app and uninstalls to 1-star ratings everything is to be expected. Because it is crucial to know about Threads (and Processes), carefully read the guide in the Android docs about it, pay special attention to the two simple rules in Android threading:
1. Do not block the UI thread
2. Do not access the Android UI toolkit from outside the UI thread
Click to expand...
Click to collapse
Let's take a look at the first one, what are you going to do instead if you need to accomplish an expensive task like web requests, complex calculations, Bitmap operations, database queries and I/O management?
Well the answer is not as simple as it may seem since it depends on what and how often you will be doing that task. A task that is performed once per activity launch is almost always wrapped into an AsyncTask, a class which is heavily optimized and integrated into the system. If you know how it works it is a very powerful tool since it does most of the heavy lifting for you, so let me show you how to do it:
You start by extending the AsyncTask class like so:
Java:
private class MyAsyncTask extends AsyncTask<Param, Progress, Result> { //...
Usual stuff, except for the weird <Param, Progress, Result> thing. It is actually not that hard, these are all just type declarations of variables your methods want to use. Thus, the first one is the type of starting parameter you want. Think of it as if you wrote your task in a separate method without access to any instance variables, what data would it need to work (what params would you pass to it in the parentheses). The second one is actually often unused and is needed if you want to return a var indicating progress on the task so it can be published e.g. in a ProgressBar. Lastly, Result is (you may have guessed it) the type of variable you want your task to return, to be published in the UI as well. A typical configuration would be <Uri, Integer, String> for a task reading a file. Note that these have to be objects, so for primitives you'd have to use their respective Java classes like Integer or Double. But that also means that a Bundle can be used as well so we know how to pass multiple parameters now! And there is another way as well, look at the overridden methods:
Java:
protected Long doInBackground(Uri... uris) {
// do your expensive work here, it runs on a separate thread!
}
protected void onProgressUpdate(Integer... progress) {
}
You'll notice the three dots after Uri and Integer. To keep it simple, treat it as an array, so to access your value call uris[0] and progress[0], respectively. The reason for it being an array is that you can start the same AsyncTask with multiple parameters of the same task:
Java:
new MyAsyncTask().execute(uri1, uri2, uri3, uri4);
This is extremely useful in this case to read multiple files at the same time (don't be confused with the configuration in <> above, the param(s) passed to execute() are joined together in the Param array).
A side note on progress here, if you want to publish progress during your doInBackground(), just call publishProgress(Progress) and override onProgressUpdate() to publish the changes in the UI. Similarly with onPostExecute(), you'll probably want to override that method as well to show your awesome result to the user.
What you need to keep in mind is how AsyncTask is handled internally, read the section “The 4 steps” in the AsyncTask documentation carefully. In fact, doInBackground() is method you need to think about the most since it is encapsulated in a separate thread with no access to the UI or methods in your activity.
Because AsyncTask is limited to one operation and should only run up to a few seconds, there are a couple of other ways to do tasks in the background like a second Thread and helpers such as Handlers. The Handlers are needed to access the UI from the worker threads, still following the second rule above. If you want to read more here's an awesome Vogella tutorial about it.
Fragment-tation
This next one is really a good style of development and can save a lot of work if you provide layouts for both phones and tablets (which you definitely should). The basic theme of using Fragments is to follow the divide and conquer technique, which dates back to ancient time in Babylonia. Thus, the idea is to have one large problem (a user interface and its data for both tablets and smartphones) and split it into multiple simpler ones (in this case having one or more Fragments for each screen on phones). Especially in multi-pane layouts, for instance in the settings app, Fragments are a wonderful tool to avoid the use of two different activities, one for phones and one for tablets. The steps to implement them in your app are pretty simple and there are already some neat guides like the one in the documentation and Vogella's one. An additional use-case for Fragments is to retain an AsyncTask when rotating the screen. You would create a Fragment without layout in the UI and call setRetainInstance() on it. Any expensive AsyncTask can then be started inside that Fragment and is not stopped when the activity is recreated during an orientation change.
Memory-zing is unneeded
But it is not only performance, layout and style which can be improved, think about memory usage for a second. It goes hand in hand with performance since an app which consumes unnecessary memory (garbage) will be slowed down by the garbage collector (GC) thrown in from the system, trying heavily to free some RAM. On Android this is extremely important, since a garbage collector running intensely on a single or dual core processor can really slow down the device's performance. That is also why method calls and object creation are so expensive and have to be used with caution – the overhead they produce bumps up the memory usage. And there is one specific case where you can really have a problem with your memory, a so-called memory leak. What this means is that some part of your app is holding on to a very large object like a Resources or database one or even a whole Activity or Fragment. The problem is that the GC can only collect objects which aren't referenced from an active part of your app so this means it can't be collected and ends up blocking all your available memory. Such a leak is something you want to avoid at all times and there are some awesome tools to find out if you have one. All you need to know about that and memory optimizations in general is covered in this amazing I/O talk, so I advice you to watch that!
Most of the time there is no real need for reducing method calls and object creation because the GC is fast enough. But there is one step where it is crucial to avoid it, methods which are called on every redraw like the onDraw() method of a View, which I'll cover in the following.
Optimizing performance? onDraw!
In your custom views the most important method to think about is the onDraw() method since that is where everything that is visible to the user is rendered. A lot can be gained (or lost) in that crucial step, so try to follow the performance guidelines posted earlier as close as possible. Especially, pay attention to the object creation, creating a few objects in onDraw() might not seem expensive, but the memory footprint and the garbage collector usage will be tremendous. When drawing on a Canvas for instance, a common pattern would be to check if the paint instance variable is null before drawing:
Java:
if(paint == null) {
paint = new Paint();
paint.setColor(drawingColor); // ...
}
That code would typically be placed in the surfaceCreated(), but could also be in the onDraw() if you are lazy and want to keep it in one place. . While object creation is not the only thing you can improve performance-wise, just try to apply the aspects I wrote about in the beginning, especially those loops!
One thing I have to point out about performance before moving on to some links that might help you is that before trying to optimize your app in some arbitrary way (and totally destroying readability) measure upfront. That means use the tools mentioned in this great I/O talk covering graphics and performance to get a sense whether your app is really driving close to that 16 millisecond threshold to get the desired 60 frames. Additionally, it might be a good idea to not only test it on the high end devices (#Nexus5) but also those with a high “resolution/processing” value such as the first tablets with 1080p resolution. Thus, only start tweaking performance if you know you take too much time, then try to nail down the time consuming methods. And always try to improve readability and simplicity, not only for us when posting pieces of your code here but also for yourself: it helps getting into the flow if you see that your code is readable and nice .
Additional resources
If you can spare some time and want to know more about how to build awesome apps and UIs, check out the Android sessions at Google I/O 13, especially the Android UI design talk and the Android Protips 3 (but the first and second Protips were great as well as the beginner's talk from 2010). There is also the Android developers blog and the Vogella tutorials. As usual, the Android developers page is always a great resource and Google is still your friend (use “android dev” together with your question to get better results). For more info about general Java performance improvements, I found this nice pdf outlining how you can improve your code even further.
Click to expand...
Click to collapse
</guide>
Anyway, that's about it. It has really become a way too long collection of links and videos so I hope it was useful and perhaps made you rethink your code . If you've got any comments or suggestions feel free to post them here, helps a lot.
This guide was featured on the portal on February 4th (thanks eagleeyetom!)
To be continued...
One Thanks isn't enough!
Great writeup! Thanks!
Wow man such a good information muchly appreciated great job!
Sent from my Nexus 4 using Tapatalk
Wow, great collection of tips and tricks. Much appreciated!!
Handy tips
awesome job dude.was really helpful!!!!!:good:
Great article! Please keep going. :good:
Simply awesome...great work.
Sent from my SAMSUNG-SGH-T989 using Tapatalk
Thanks for this great writeup! The android specific tips are really interesting.
Great guide (again). :good:
Just one thing I want to add: I still prefer wrapper classes which implement Parcelable. In fact, it's not that difficult and you should be able to do it in a few minutes. Have a look at the example code here: http://developer.android.com/reference/android/os/Parcelable.html That's it.
I've also found an IntelliJ plugin for that purpose (but I haven't tried it yet): https://github.com/mcharmas/android-parcelable-intellij-plugin
That wasn't meant to degrade your work though. It's an amazing guide.
nikwen said:
Great guide (again). :good:
Just one thing I want to add: I still prefer wrapper classes which implement Parcelable. In fact, it's not that difficult and you should be able to do it in a few minutes. Have a look at the example code here: http://developer.android.com/reference/android/os/Parcelable.html That's it.
I've also found an IntelliJ plugin for that purpose (but I haven't tried it yet): https://github.com/mcharmas/android-parcelable-intellij-plugin
That wasn't meant to degrade your work though. It's an amazing guide.
Click to expand...
Click to collapse
Good point and thanks!
Having a closer look at it, implementing Parcelable is not that much work and it would definetely be the more advanced way. Bundle is basically just another layer that makes things a bit easier for the start (and no typecasting) and I found that it can really shine with a singleton class holding the keys and the getters and setters (which have an additional param, the Bundle). For a beginner who just wants to save some values (possibly keeping the keys in the activity or even hardcoded) using the Bundle is a lot easier. Yet again, TIMTOWTDI
Thank you!
Hey Simplicity, after few years there is something you would change? Maybe dagger2, kotlin, rxjava changed the game, as really open question what do you think about?
The question might be a bit off topic, i am working on a root app development but i am pretty confused that how should i get the busbox commands to run on button press, i have given the path and everything but how am i supposed to create a busbox file in data/data/package/files.
This part is confusing me I am not able to create that file, should i keep it in res while creating the app ? And also one last question, from where can i get that busbox file with all its command. Please help, I'm sorry if this is the wrong forum I'm new to posting questions and also to app development .

Categories

Resources