Need help with decision on Cross-platform development - Android Q&A, Help & Troubleshooting

I'm developing an app for iOS and android that identifies songs. We have a matching engine in c++ that works well, but my question is about the rest of the app. We have a user interface design that allows the user to record, match and save, as well as share, edit, and see their recordings.
I'm not a coder - just a designer- and I'm getting conflicting advice about how to implement. One person wants to do the majority of the functions in c++ with just a thin native GUI skin, while the other says we should write in native IOS (swift) and Android and only have the engine in c++.
The argument for c++ is it will be a single code base to maintain - it would include doing the sharing, storing history, displaying sonograms, etc. The argument against is that in fact it will not be easier to maintain, and will also create a lot of problems making calls, for example, between the interface and the function modules. For example, we currently have a function for sharing (email, facebook etc) entirely in C++ which the interface calls to, and I'm not sure if that's the best way to do things.
Hope this is clear - it's a very hard thing for me to assess as ignorant as I am! Any advice would be greatly appreciated.

I'd have the engine being c++ only, and then code in the native language for the specific platform.
Here is why:
-Maintaining UI design in c++ is terrible, which can be bad for potential customers
-Not good for load times, you want your app to be as fast as possible
-While it is good for future support (one dev can handle both the engine and the UI, less devs = less spent money), leaving it all on one dev can; have terrible documentation for the code, which will make it harder for new recruits to begin.
-IDE support (no I am not joking), android studio can do the UI pretty darn good, and adding c++ will just make it either look old or ugly.
Those are just my 2 cents

Related

[Q] learning how to develop apps

i want to start making apps for android but dont know where to stat i have the sdk on my desktop but thats about it. If someone could please help me or push me in the next step please do so.
Just go to the dev guide on the Android website to start making your first Hello World app. As for language, Android (I could be wrong) uses Java. Again, I could be wrong.
Sent from my GT-I9000M using XDA App
Indeed, Android uses Java. I'd suggest learning it before attempting to program for Android or else you'll feel like it's gonna be too difficult. There's plenty of books on Java, and some powerful Google searching will lead you to step-by-step guides to learning Java.
Also, go through the Android Dev Center for a lot of information. There's plenty of guides there on things like 'how to design your app to flow with the overall android feel' and 'designing icons to fit general android homescreen look'.
You're gonna want to download Eclipse for Java Programming. It's a free Java development environment much like Dreamweaver and Visual Studio are for web development.
Oh, and PLAN! Like any good development project, your project will not get anywhere if you don't know where to start and when to end it.
Plan first. Then plan the planned elements. Java is object-based programming, and just like building a house each object needs to be solid or else it'll crumble to pieces.
Same here. Thx for the advice.
elindemann said:
Indeed, Android uses Java. I'd suggest learning it before attempting to program for Android or else you'll feel like it's gonna be too difficult. There's plenty of books on Java, and some powerful Google searching will lead you to step-by-step guides to learning Java.
Also, go through the Android Dev Center for a lot of information. There's plenty of guides there on things like 'how to design your app to flow with the overall android feel' and 'designing icons to fit general android homescreen look'.
You're gonna want to download Eclipse for Java Programming. It's a free Java development environment much like Dreamweaver and Visual Studio are for web development.
Oh, and PLAN! Like any good development project, your project will not get anywhere if you don't know where to start and when to end it.
Plan first. Then plan the planned elements. Java is object-based programming, and just like building a house each object needs to be solid or else it'll crumble to pieces.
Click to expand...
Click to collapse
Actually, you're doing things the hard HARD ...HARD way....
if you want to develop apps for android, Titanium Mobile (appcelerator.com) is the best way to go. It takes far less time to learn JavaScript , CSS and HTML then it does to learn pure JAVA, and then learn to implement Android's API.
There are a few things that Titanium Mobile can't do, but they are always working on it to make it better. And of course - it's free
I've made a few apps using it. Including an HTML eBook reader, Chinese Flashcard App, and a Simple Chat Client.
Their JavaScript API takes a bit to get used to, but after that, you can easily spit out a simple app in about a day or so.
I have a web-app Template that lets me dump a Web-app (html/css/js) into a project, and spits out a nice new shiny Android app ready for the market.... I also wrote code that lets you access the Menu Button on android too. So it's not like using PhoneGap where it's just a Browser session with an icon on your phone.
PM me if you're interested, and i'll show you everything i learned about Titanium Mobile so far (i'm still learning actually). Or if you want an app done, i can do it for you... free if it's easy enough
DaoMingJin said:
Actually, you're doing things the hard HARD ...HARD way....
if you want to develop apps for android, Titanium Mobile (appcelerator.com) is the best way to go. It takes far less time to learn JavaScript , CSS and HTML then it does to learn pure JAVA, and then learn to implement Android's API.
There are a few things that Titanium Mobile can't do, but they are always working on it to make it better. And of course - it's free
I've made a few apps using it. Including an HTML eBook reader, Chinese Flashcard App, and a Simple Chat Client.
Their JavaScript API takes a bit to get used to, but after that, you can easily spit out a simple app in about a day or so.
I have a web-app Template that lets me dump a Web-app (html/css/js) into a project, and spits out a nice new shiny Android app ready for the market.... I also wrote code that lets you access the Menu Button on android too. So it's not like using PhoneGap where it's just a Browser session with an icon on your phone.
PM me if you're interested, and i'll show you everything i learned about Titanium Mobile so far (i'm still learning actually). Or if you want an app done, i can do it for you... free if it's easy enough
Click to expand...
Click to collapse
Wow, I'm very interested. I might check it out.
sent from my pimp hero running Froyo CM6 and the XDA app
If you know the C or C++ language you could try out MoSync, depends what you like, some programmers like the level of control and speed you get from C++. If your content with simpler apps then maybe phonegap or appcellerator for you.
I guess that when mobile apps get more sophisticated javascript programs will be just as complex as C++ programs.
Thats my view, but then I like C++ better.
/Tony
MoSyncTony said:
If you know the C or C++ language you could try out MoSync, depends what you like, some programmers like the level of control and speed you get from C++. If your content with simpler apps then maybe phonegap or appcellerator for you.
I guess that when mobile apps get more sophisticated javascript programs will be just as complex as C++ programs.
Thats my view, but then I like C++ better.
/Tony
Click to expand...
Click to collapse
It really depends on how much control and you really need. If you're going to write games, then you do need speed that C++ and the Native Application Development API on android can give you. If you're writing a social networking app, the speed of C++ would really be an overkill.
As far as i've read, PhoneGap still has a lot of issues. And the build process is a bit more complicated than on Titanium Mobile.
If you're just using the regular Android API to write apps, i don't notice a lot of difference in speed execution between writing it in pure Java, or using Titanium mobile (using native code and UI elements - i don't mean putting everything into a WebView).
The current app that i'm writing now i don't think can be written using Titanium Mobile or PhoneGap (unless i added some native functions and did my own fork of PhoneGap).
More or less, i'm writing an App for Android and JRE/Linux systems that will allow me to enumerate, and access USB status bits, and USB data frames of a given USB device, and then allowing that USB device to be accessed through a TCP or UDP connection.
I might be able to do this with Titanium Mobile, but i don't think i can. As the only files you're allowed to access are on the SD card, application data directory, and temp directory.... i think there's one other place you're allowed to access too, but i never used it. However later today i might just try to see if i can access the /Dev/DSP01 (aka sound card) on an android device. If i can, i think i could write it using titanium mobile. I'm already halfway done with this app in pure java, so i wouldn't actually rewrite it in Titanium Mobile now.
DaoMingJin said:
if you want to develop apps for android, Titanium Mobile (appcelerator.com) is the best way to go.
Click to expand...
Click to collapse
Thanx mate!
If you looking a book or something to teach you the basics Beginning Java Programming for Dummies and Android Application Development in 24 Hours are good reads.
I'd rather not fill the forum with more threads so I'm just going to ask my question here. What is the best way to read the android dev guide on the device itself? Just going to the site directly? Ideally I'd like a pdf or something designed to be read on a small screen. The site can have formatting issues when read on a small screen.
Sent from my SPH-D700 using XDA App
I've been developing for a long time (nearly 30 years), and whenever I need to learn a new language I start with the Sams range, "Teach yourself whatever language in X days/hours". They're pretty good and this is available for Kindle, which is great if you use the Amazon Kindle app...
http://www.amazon.co.uk/Teach-Yours...1_fkmr2_2?ie=UTF8&qid=1287485537&sr=8-2-fkmr2
It obviously costs, but I really do rate those books as brilliant starting points. The rest is google and friends on here.
Hope this helps - good luck mate.
Personally, I've been coding in Java for what... four years now? I'm feeling dwarfed here by johncmolyneux but honestly, the best way to learn is to not use an IDE like Eclipse, but to use something that you have to hand-code everything yourself, such as Geany! You learn fairly quickly after writing a few applications.
If you are thinking "titanium", "mosync" or "phone gap" it is worth doing a bit of background research. There are several extremely powerful tools out there that can help you build cross platform apps - these are among the top ones.
bit more discussion about this here: http://forum.xda-developers.com/showthread.php?p=16703287#post16703287
There are a few useful reports comparing them - check out ours by googling "triballabs cross platform"
The Google App Inventor makes it pretty easy to create your own Android apps. Best part is you don't need to learn any programming languages. You won't be creating anything too complicated like a video game for example, but it's a good start nonetheless.
http://appinventor.googlelabs.com/about/
If you want to learn the basics of Java, then please check out a book called as "Head First Java". They really explain the basics with the help of real life examples to make things much simpler so that people understand.
Beginner app projects
I'm also just getting started with app development. Something I've been looking for is a beginner app project. Wish I could find a walkthrough of a simple app like a game of Hangman or something like that. I've been through the android developer training web site and got some good info but some things I'm still a little stuck on. Id Love to see an actual app (rather than just a mock up of some fields and buttons) and then a slightly dumbed down explanation of the code. Might be a lot to ask but man it would be great!

Android insights: HW Acceleration, performance, Lags

Hi @all,
yesterday i posted a nice article about how HW Acceleration is done since honeycomb (and the difference before).
I think its a good idea to post here nice and interesting articles - this can help the devs here but the users to why
sometimes its simply impossible to code things or fix things.
Please dont spam this thread, even its in general section - let users read interesting things instead of pages full of ****
"The Reason Android is Laggy"
Dianne starts off her post with a surprising revelation:
“Looking at drawing inside of a window, you don’t necessarily need to do this in hardware to achieve full 60fps rendering.
This depends very much on the number of pixels in your display and the speed of your CPU. For example, Nexus S has no
trouble doing 60fps rendering of all the normal stuff you see in the Android UI like scrolling lists on its 800x480 screen.”
Hun? How can this be the case? Anybody who’s used a Nexus S knows it slows down in all but the simplest of ListViews.
And forget any semblance of decent performance if a background task is occurring, like installing an app or updating the
UI from disk. On the other hand, iOS is 100% smooth even when installing apps. But we know Dianne isn’t lying about the
potential CPU performance, so what’s going on?
The Root Cause
It’s not GC pauses. It’s not because Android runs bytecode and iOS runs native code. It’s because on iOS all UI rendering
occurs in a dedicated UI thread with real-time priority. On the other hand, Android follows the traditional PC model of rendering
occurring on the main thread with normal priority.
This is a not an abstract or academic difference. You can see it for yourself. Grab your closest iPad or iPhone and open Safari.
Start loading a complex web page like Facebook. Half way through loading, put your finger on the screen and move it around.
All rendering instantly stops. The website will literally never load until you remove your finger. This is because the UI thread is
intercepting all events and rendering the UI at real-time priority.
If you repeat this exercise on Android, you’ll notice that the browser will attempt to both animate the page and render the HTML,
and do an ‘ok’ job at both. On Android, this a case where an efficient dual core processor really helps, which is why the Galaxy
S II is famous for its smoothness.
On iOS when an app is installing from the app store and you put your finger on the screen, the installation instantly pauses until
all rendering is finished. Android tries to do both at the same priority, so the frame rate suffers. Once you notice this happening,
you’ll see it everywhere on an Android phone. Why is scrolling in the Movies app slow? Because movie cover thumbnails are
dynamically added to the movie list as you scroll down, while on iOS they are lazily added after all scrolling stops.
Other Reasons
The fundamental reason Android is laggy is UI rendering threading and priority, but it’s not the only reason. First, hardware
acceleration, despite Dianna’s reservations, does help. My Nexus S has never been snappier since upgrading to ICS. Hardware
acceleration makes a huge difference in apps like the home screen and Android market. Offloading rendering to the GPU also
increases battery life, because GPUs are fixed-function hardware, so they operate at a lower power envelope.
Second, contrary to what I claimed earlier, garbage collection is still a problem, even with the work on concurrent GC in Dalvik.
For example, if you’ve ever used the photo gallery app in Honeycomb or ICS you may wonder why the frame rate is low. It turns
out the frame rate is capped at 30 FPS because without the cap, swiping through photos proceeds at 60 FPS most of the time,
but occasionally a GC pause causes a noticeable “hiccup”. Capping the frame rate at 30 fixes the hiccup problem at the expense
of buttery smooth animations at all times.
Third, there are the hardware problems that Dianne discussed. The Tegra 2, despite Nvidia’s grandiose marketing claims, is hurt
by low memory bandwidth and no NEON instruction set support (NEON instructions are the ARM equivalent of Intel’s SSE, which
allow for faster matrix math on CPUs). Honeycomb tablets would be better off with a different GPU, even if it was theoretically
less powerful in some respects than the Tegra 2. For example, the Samsung Hummingbird in the Nexus S or Apple A4. It’s telling
that the fastest released Honeycomb tablet, the Galaxy Tab 7.7, is running the Exynos CPU from the Galaxy S II.
Fourth, Android has a ways to go toward more efficient UI compositing. On iOS, each UI view is rendered separately and stored
in memory, so many animations only require the GPU to recomposite UI views. GPUs are extremely good at this. Unfortunately, on
Android, the UI hierarchy is flattened before rendering, so animations require every animating section of the screen to be redrawn.
Fifth, the Dalvik VM is not as mature as a desktop class JVM. Java is notorious for terrible GUI performance on desktop. However,
many of the issues don’t carry over to the Dalvik implementation. Swing was terrible because it was a cross platform layer on top
of native APIs. It is interesting to note that Windows Phone 7’s core UI is built in native code, even though the original plan was to
base it entirely on Silverlight. Microsoft ultimately decided that to get the kind of UI performance required, the code would have to
be native. It’s easy to see the difference between native and bytecode on Windows Phone 7, because third party apps are written
in Silverlight and have inferior performance (NoDo and Mango have alleviated this problem and the Silverlight UIs are generally very
smooth now).
Thankfully, each of the five issues listed above is solvable without radical changes to Android. Hardware acceleration will be on all
Android phones running ICS, Dalvik continues to improve GC efficiency, the Tegra 2 is finally obsolete, there are existing workarounds
for the UI compositing problems, and Dalvik becomes a faster VM with every release. I recently asked +Jason Kincaid of +TechCrunch
if his Galaxy Nexus was smooth, and he had this to say:
“In general I've found ICS on the Galaxy Nexus to be quite smooth. There are occasional stutters — the one place where I can
consistently get jitters on the Galaxy Nexus is when I hit the multitasking button, where it often will pause for a quarter second.
That said, I find that the iPhone 4S also jitters more than I had expected, especially when I go to access the systemwide search
(where you swipe left from the home screen).”
So there you go, the Android lag problem is mostly solved, right? Not so fast.
Going Forward
Android UI will never be completely smooth because of the design constraints I discussed at the beginning:
- UI rendering occurs on the main thread of an app
- UI rendering has normal priority
Even with a Galaxy Nexus, or the quad-core EeePad Transformer Prime, there is no way to guarantee a smooth frame rate if these
two design constraints remain true. It’s telling that it takes the power of a Galaxy Nexus to approach the smoothness of a three year
old iPhone. So why did the Android team design the rendering framework like this?
Work on Android started before the release of the iPhone, and at the time Android was designed to be a competitor to the Blackberry.
The original Android prototype wasn’t a touch screen device. Android’s rendering trade-offs make sense for a keyboard and trackball device.
When the iPhone came out, the Android team rushed to release a competitor product, but unfortunately it was too late to rewrite the UI
framework.
This is the same reason why Windows Mobile 6.5, Blackberry OS, and Symbian have terrible touch screen performance. Like Android, they
were not designed to prioritise UI rendering. Since the iPhone’s release, RIM, Microsoft, and Nokia have abandoned their mobile OS’s and
started from scratch. Android is the only mobile OS left that existed pre-iPhone.
So, why doesn’t the Android team rewrite the rendering framework? I’ll let Romain Guy explain:
“...a lot of the work we have to do today is because of certain choices made years ago... ...having the UI thread handle animations is the
biggest problem. We are working on other solutions to try to improve this (schedule drawing on vsync instead of block on vsync after drawing,
possible use a separate rendering thread, etc.) An easy solution would of course to create a new UI toolkit but there are many downsides to
this also.”
Romain doesn’t elaborate on what the downsides are, but it’s not difficult to speculate:
- All Apps would have to be re-written to support the new framework
- Android would need a legacy support mode for old apps
- Work on other Android features would be stalled while the new framework is developed
However, I believe the rewrite must happen, despite the downsides. As an aspiring product manager, I find Android’s lagginess absolutely
unacceptable. It should be priority #1 for the Android team.
When the topic of Android comes up with both technical and nontechnical friends, I hear over and over that Android is laggy and slow.
The reality is that Android can open apps and render web pages as fast or faster than iOS, but perception is everything. Fixing the UI lag
will go a long way to repairing Android’s image.
Beyond the perception issue, lag is a violation of one of Google’s core philosophies. Google believes that things should be fast. That’s a driving
philosophy behind Google Search, Gmail, and Chrome. It’s why Google created SPDY to improve on HTTP. It’s why Google builds tools to help
websites optimize their site. It’s why Google runs it’s own CDN. It’s why Google Maps is rendered in WebGL. It’s why buffering on Youtube is
something most of us remember, but rarely see anymore.
But perhaps the most salient reason why UI lag in Android is unacceptable comes from the field of Human-Computer Interaction (HCI). Modern
touch screens imply an affordance language of 1 to 1 mapping between your finger and animations on the screen. This is why the iOS over-scroll
(elastic band) effect is so cool, fun, and intuitive. And this is why the touch screens on Virgin America Flights are so frustrating: they are incredibly
laggy, unresponsive, and imprecise.
A laggy UI breaks the core affordance language of a touch screen. The device no longer feels natural. It loses the magic. The user is pulled out of
their interaction and must implicitly acknowledge they are using an imperfect computer simulation. I often get “lost” in an iPad, but I cringe when a
Xoom stutters between home screens. The 200 million users of Android deserve better.
And I know they will have it eventually. The Android team is one of the most dedicated and talented development teams in the world. With stars like
+Dianne Hackborn and +Romain Guy around, the Android rendering framework is in good hands.
I hope this post has reduced confusion surrounding Android lag. With some luck, Android 5.0 will bring the buttery-smooth Android we’ve all dreamed
about since we first held an HTC G1. In the mean time, I’ll be in Redmond working my butt off trying to get a beautiful and smooth mobile OS some
of the recognition it deserves.
Click to expand...
Click to collapse
How do Android Apps work- Java, its compilation and role of DalvikVM
OK, here goes mine..
was researching around about the role of java in android and I found this piece of info..
it explains the way android apps work and stuff..
Visit here for the full article..
What is Java?
Android applications are developed using the Java language. As of now, that’s really your only option for native applications. Java is a very popular programming language developed by Sun Microsystems (now owned by Oracle). Developed long after C and C++, Java incorporates many of the powerful features of those powerful languages while addressing some of their drawbacks. Still, programming languages are only as powerful as their libraries. These libraries exist to help developers build applications.
Some of the Java’s important core features are:
It’s easy to learn and understand
It’s designed to be platform-independent and secure, using
virtual machines
It’s object-oriented
Android relies heavily on these Java fundamentals. The Android SDK includes many standard Java libraries (data structure libraries, math libraries, graphics libraries, networking libraries and everything else you could want) as well as special Android libraries that will help you develop awesome Android applications.
Why is Platform Independence Important?
With many programming languages, you need to use a compiler to reduce your code down into machine language that the device can understand. While this is well and good, different devices use different machine languages. This means that you might need to compile your applications for each different device or machine language—in other words, your code isn’t very portable. This is not the case with Java. The Java compilers convert your code from human readable Java source files to something called “bytecode” in the Java world. These are interpreted by a Java Virtual Machine, which operates much like a physical CPU might operate on machine code, to actually execute the compiled code. Although it might seem like this is inefficient, much effort has been put into making this process very fast and efficient. These efforts have paid off in that Java performance in generally second only to C/C++ in common language performance comparisons.
Android applications run in a special virtual machine called the Dalvik VM. While the details of this VM are unimportant to the average developer, it can be helpful to think of the Dalvik VM as a bubble in which your Android application runs, allowing you to not have to worry about whether the device is a Motorola Droid, an HTC Evo, or the latest toaster running Android. You don’t care so long as the device is Dalvik VM friendly—and that’s the device manufacturer’s job to implement, not yours.
Why is Java Secure?
Let’s take this bubble idea a bit further. Because Java applications run within the bubble that is a virtual machine, they are isolated from the underlying device hardware. Therefore, a virtual machine can encapsulate, contain, and manage code execution in a safe manner compared to languages that operate in machine code directly. The Android platform takes things a step further. Each Android application runs on the (Linux-based) operating system using a different user account and in its own instance of the Dalvik VM. Android applications are closely monitored by the operating system and shut down if they don’t play nice (e.g. use too much processing power, become unresponsive, waste resources, etc.). Therefore, it’s important to develop applications that are stable and responsive. Applications can communicate with one another using well-defined protocols.
Compiling Your Code
Like many languages, Java is still a compiled language even though it doesn’t compile all the way down to machine code. This means you, the developer, need to compile your Android projects and package them up to deploy onto devices. The Eclipse development environment (used with the Android Development plug-in) makes this pretty painless. In Eclipse, automatic compilation is often turned on by default. This means that every time you save a project file, Eclipse recompiles the changes for your application package. You immediately see compile errors. Eclipse also interprets Java as you type, providing handy code coloring and formatting as well as showing many types of errors as you go. Often, you can click on the error and have Eclipse automatically fix a typo, or add an import statement, or provide a method stub for you, saving lots of typing.
You can still manually compile your code if you so desire. Within Eclipse, you’ll find the Build settings under the project menu. If you have “Build Automatically” turned on, you can still choose the “Clean…” option that will allow you to do full rebuild of all files. If “Build Automatically” is turned off, “Build All” and “Build Project” menu options are enabled. “Build All” means to build all of the projects in the workspace. You can have many projects in an Eclipse workspace.
The build process, for regular Java projects, results in a file with the extension of JAR – Java ARchive. Android applications take JAR files and package them for deployment on devices as Android PacKage files with an extension .apk. These formats not only include your compiled Java code, but also any other resources, such as strings, images, or sound files, that your application requires to run as well as the Application Manifest file, AndroidManifest.xml. The Android Manifest file is a file required by all Android applications, which you use to define configuration details about your app.
Click to expand...
Click to collapse
And here goes another article, by an Ex-Intern Andrew Munn who worked on the android project..
i just post the link here, its a huge article...
Follow up to “Android graphics true facts”, or The Reason Android is Laggy
Click to expand...
Click to collapse
An Extremely important thread for me..........My friend has an iPhone 3GS and he always considers it better than Android, underestimating my LG O1 I've many a times proved him wrong, but not with technical aspects.....Now he'd understand what is ANDROID!!!!
D3oDex3D_Ayush717 said:
An Extremely important thread for me..........My friend has an iPhone 3GS and he always considers it better than Android, underestimating my LG O1 I've many a times proved him wrong, but not with technical aspects.....Now he'd understand what is ANDROID!!!!
Click to expand...
Click to collapse
exactly ! android is 100 times better and powerfull than ios ! if in an iphone ui rendering didnt happen didicatedly, it would be 100 times more laggy than android. one other thing that shows that ios does concentrate completly on ui when scrolling- swipe left right through homscreens in speed (even with all apps closed) - ull see that the dots below which indicate which screen ur on , doesnt change at all untill uve stopped scrolling and then it moves directly to the current screen indicator!
---------- Post added at 03:16 PM ---------- Previous post was at 03:09 PM ----------
btw this here is a contradicting article to what andy you posted ! here ! :
Dianne Hackborn - 00:38 (edited) - Public
A few days ago I wrote a post trying to correct a lot of the inaccurate statements I have seen repeatedly mentioned about how graphics on Android works. This resulted in a lot of nice discussion, but unfortunately has also lead some people to come up with new, novel, and often technically inaccurate complaints about how Android works.
These new topics have been more about some fundamental design decisions in Android, and why they are wrong. I’d like to help people better understand (and judge) these discussions by giving some real background on why Android’s UI was designed the way it is and how it actually works.
One issue that has been raised is that Android doesn’t use thread priorities to reduce how much background work interrupts the user interface. This is outright wrong. It actually uses a number of priorities, which you can even find defined right here http://developer.android.com/reference/android/os/Process.html#THREAD_PRIORITY_AUDIO in the SDK.
The most important of these are the background and default priorities. User interface threads normally run at the default priority; background threads run in the background priority. Application processes that are in the background have all of their threads forced to the background priority.
Android’s background priority is actually pretty interesting. It uses a Linux facility called cgroups to put all background threads into a special scheduling group which, all together, can’t use more than 10% of the CPU. That is, if you have 10 processes in the background all trying to run at the same time, when combined they can't take away more than 10% of the time needed by foreground threads. This is enough to allow background threads to make some forward progress, without having enough of an impact on the foreground threads to be generally visible to the user.
(You may have noticed that a “foreground” priority is also defined. This is not used in current Android; it was in the original implementation, but we found that the Linux scheduler does not give enough preference to threads based on pure priority, so switched to cgroups in Android 1.6.)
I have also seen a number of claims that the basic Android design is fundamentally flawed and archaic because it doesn’t use a rendering thread like iOS. There are certainly some advantages to how iOS work, but this view is too focused on one specific detail to be useful, and glosses over actual similarities in how they behave.
Android had a number of very different original design goals than iOS did. A key goal of Android was to provide an open application platform, using application sandboxes to create a much more secure environment that doesn’t rely on a central authority to verify that applications do what they claim. To achieve this, it uses Linux process isolation and user IDs to prevent each application from being able to access the system or other application in ways that are not controlled and secure.
This is very different from iOS’s original design constraints, which remember didn’t allow any third party applications at all.
An important part of achieving this security is having a way for (EDIT: It has been pointed out to me that iOS does in fact use multiple windows and multiple GL contexts. Lesson to me, just don't talk about anything I haven't directly verified. That still doesn't change things for Android, though, where as I mention later we simply did not have hardware and drivers that could do multiple GL contexts until fairly recently.)
individual UI elements to share the screen in a secure way. This is why there are windows on Android. The status bar and its notification shade are windows owned and drawn by the system. These are separate from the application’s window, so the application can not touch anything about the status bar, such as to scrape the text of SMS messages as they are displayed there. Likewise the soft keyboard is a separate window, owned by a separate application, and it and the application can only interact with each other through a well defined and controlled interface. (This is also why Android can safely support third party input methods.)
Another objective of Android was to allow close collaboration between applications, so that for example it is easy to implement a share API that launches a part of another application integrated with the original application’s flow. As part of this, Android applications traditionally are split into pieces (called “Activities”) that handle a single specific part of the UI of the application. For example, the contacts lists is one activity, the details of a contact is another, and editing a contact is a third. Moving between those parts of the contacts UI means switching between these activities, and each of these activities is its own separate window.
Now we can see something interesting: in almost all of the places in the original Android UI where you see animations, you are actually seeing windows animate. Launching Contacts is an animation of the home screen window and the contacts list window. Tapping on a contact to see its details is an animation of the contacts list window and the contacts details window. Displaying the soft keyboard is an animation of the keyboard window. Showing the dialog where you pick an app to share with is an animation of a window displaying that dialog.
When you see a window on screen, what you are seeing is actually something called a “surface”. This is a separate piece of shared memory that the window draws its UI in, and is composited with the other windows to the screen by a separate system service (in a separate thread, running at a higher than normal priority) called the “surface flinger.” Does this sound familiar? In fact this is very much like what iOS is doing with its views being composited by a separate thread, just at a less fine-grained but significantly more secure level. (And this window composition has been hardware accelerated in Android from the beginning.)
The other main interesting interaction in the UI is tracking your finger -- scrolling and flinging a list, swiping a gallery, etc. These interactions involve updating the contents inside of a window, so require re-rendering that window for each movement. However, being able to do this rendering off the main thread probably doesn’t gain you much. These are not simple “move this part of the UI from X to Y, and maybe tell me when you are done” animations -- each movement is based on events received about the finger on the screen, which need to be processed by the application on its main thread.
That said, being able to avoid redrawing all of the contents of the parts of the UI that are moving can help performance. And this is also a technique that Android has employed since before 1.0; UI elements like a ListView that want to scroll their content can call http://developer.android.com/reference/android/view/View.html#setDrawingCacheEnabled(boolean) to have that content rendered into a cache so that only the bitmap needs to be drawn as it moves.
Traditionally on Android, views only have their drawing cache enabled as a transient state, such as while scrolling or tracking a finger. This is because they introduce a fair amount more overhead: extra memory for the bitmap (which can easily total to multiple times larger than the actual frame buffer if there are a number of visual layers), and when the contents inside of a cached view need to be redrawn it is more expensive because there is an additional step required to draw the cached bitmap back to the window.
So, all those things considered, in Android 1.0 having each view drawn into a texture and those textures composited to the window in another thread is just not that much of a gain, with a lot of cost. The cost is also in engineering time -- our time was better spent working on other things like a layout-based view hierarchy (to provide flexibility in adjusting for different screen sizes) and “remote views” for notifications and widgets, which have significantly benefited the platform as it develops.
In fact it was just not feasible to implement hardware accelerated drawing inside windows until recently. Because Android is designed around having multiple windows on the screen, to have the drawing inside each window be hardware accelerated means requiring that the GPU and driver support multiple active GL contexts in different processes running at the same time. The hardware at that time just didn’t support this, even ignoring the additional memory needed for it that was not available. Even today we are in the early stages of this -- most mobile GPUs still have fairly expensive GL context switching.
I hope this helps people better understand how Android works. And just to be clear again from my last point -- I am not writing this to make excuses for whatever things people don’t like about Android, I just get tired of seeing people write egregiously wrong explanations about how Android works and worse present themselves as authorities on the topic.
There are of course many things that can be improved in Android today, just as there are many things that have been improved since 1.0. As other more pressing issues are addressed, and hardware capabilities improve and change, we continue to push the platform forward and make it better.
One final thought. I saw an interesting comment from Brent Royal-Gordon on what developers sometimes need to do to achieve 60fps scrolling in iOS lists: “Getting it up to sixty is more difficult—you may have to simplify the cell's view hierarchy, or delay adding some of the content, or remove text formatting that would otherwise require a more expensive text rendering API, or even rip the subviews out of the cell altogether and draw everything by hand.”
I am no expert on iOS, so I’ll take that as as true. These are the exact same recommendations that we have given to Android’s app developers, and based on this statement I don't see any indication that there is something intrinsically flawed about Android in making lists scroll at 60fps, any more than there is in iOS.
D3oDex3D_Ayush717 said:
An Extremely important thread for me..........My friend has an iPhone 3GS and he always considers it better than Android, underestimating my LG O1 I've many a times proved him wrong, but not with technical aspects.....Now he'd understand what is ANDROID!!!!
Click to expand...
Click to collapse
Ehhhh I still think 3GS is better than optimus one
That's a lot of bull**** in even more words...
Kidding
But I don't understand anything of it, I'll leave it to the real devs (A)
Luck dev'ing
ok, here some basic informations on how long it take and why before a developer can
release a complete OS:
http://developer.sonyericsson.com/w...from-source-code-release-to-software-upgrade/
About Accelerated Android Rendering:
It's pretty interesting although these guys aren't talking about Ice Cream Sandwich (they're talking about Honeycomb that introduced hardware accelerated 2D rendering)
http://www.youtube.com/watch?v=v9S5EO7CLjo
I could be way off base here, but is there anything useful that could be extracted from qualcomm's adreno sdk?
https://developer.qualcomm.com/
terratrix said:
Ehhhh I still think 3GS is better than optimus one
Click to expand...
Click to collapse
I am not comparing 3Gs and O1, am talking abt. difference between AndroidOS and iOS............
Sent from my LG Optimus One P500 using XDA App
This week, google started a nice topic on the android developer page "Best practices to develop android applications".
Reading some articles is recommended for developers who want to save some battery and/or network traffic, want to spped
up listviews, save ram and other good things:
look here:
Improving Layout Performance
Optimizing Battery Life
Sharing content between applications
i hope, this can someone help to understand what we can do to make things nice.

[Q] Help developing a simple Java Android App

Hey everyone, my name is Ian. I'm kind of new here, at least in a participatory role as wiki master of the Photon 4g's Sunfire dev team/collaboration. I have some talent in the world of web coding, but I'm useless at real programming.
I also have a rather nasty addiction to the world of flight simming, mostly as stand in for real flight time that I'm trying to orchestrate as I work towards a private pilot's license. Anyways, my program I use for flight simulation is X-plane and lacks in 3rd party applications that it can interface with, especially on the Android side. I would like to help to put together an Android app that can work with the sim and control basic functions. My current goal is to control radio systems and autopilot functions. To interface with the sim, I plan to use the Simulator Control System which is based on the CAN Aerospace protocol. This is cross sim application, so whatever works with X-plane will also work with Microsoft flight sim. I've been looking at the website, http://cross-simulator.com/, and I think that this seems like a fairly easy task. All the functions and commands are well documented and supported (there is even an example android code), I just don't know how to start. If anyone in this great community has some advice, I'd love to hear it because I really have no clue.
Thanks, and happy dev'ing
I would just download the example, import it in Eclipse and run it on the Android emulator (assuming you have downloaded and installed the Android SDK). Later, you can tweak the example code as you become more comfortable.

[Q] Is android right for my project?

Hi folks,
I have had this idea in my mind for a couple of years now and would like to get on with it and stop dreaming about it and just jump in and do it already!
My experience during the past 20 years has been working as a programmer on MSSQL and VB and VB.net with good working knowledge of C, HTML5, Javascript, VB, VC, Access, MSSQL, MySQL, PHP, CSS, some Java, etc...
I don't mind learning new skills and actually looking forward to getting started, but I need to know that I am not barking up the wrong tree.
I intend to make this an open source project and not as a commercial product.
My dream is to make my phone, my voice-driven computer. Where the phone might not have enough resources, I need to use my main computer as top tier and act as server.
I know ubuntu touch might be a contender but it lacks many drivers for GPS, Propriety drivers, etc...
Let me tell you about my idea first as a high level plan due to my ignorance of the details of this implementation.
I want to make my phone (Nexus 4) be able to listen to my commands via a Bluetooth headset (Through a speech recognition engine), and tell me in in natural speech, things that I need to know or care about. For example: "You have a new email from David. Do you want me to read it or display it?" Sort of like what is now a movie called "Her" without the science fiction and the lovey dovey story part .
I want to write an internet agent that would search the net (from a list of sites) for what I am interested (through an AI program like freehal.net), and keep them for display in the order of relevance when I query it.
I also need to take over the telephony hardware when needed. For example: A call comes in, I want to be able to look-up their number in my database of contacts, if an entry is found, to tell me "Sam is calling. Do you want to answer it?"
I also want to keep a black list table where I know they are trying to sell me something and answer the phone (without me pushing any buttons) and tell them that I am not interested in answering their calls and that they are on my black list. Then hangup. Without sending them to voice mail.
I tried asking the android community on Google 2 years ago to ask why the SDK doesn't provide telephony API front end to answer the call without user interaction, but got no replies.
I've installed ubuntu on my laptop to learn Linux and got it working properly after a couple of days and have downloaded and installed all the programs and sdks I think I'd need. There are a lot of interesting projects in AI and user agents going on and I like to participate in them once I am up to par with the linux environment.
Can anyone give me some guidance, pointers or what to look for. If there are any project in development that I could join, would be much appreciated.
I tried to explain my interest as best as I could. If you need more info, please let me know.
Thanks for all your help guys.

Coding languages

Hi guys, can anyone explain to me why you can have different coding languages? I am going to try and explain it the best way possible. Pretty much I want to know why some people use other coding languages instead of others? Are some better for particular activities? Like I know cross compatibility like you can't use html to code a game online you need to use Flash or Javascript etc.
tl;d why use one language over another?
Every programming language has advantages and disadvantages. For example Java is portable but slower then, let's say, C++. C++ is less portable and needs to be compiled seperately for every OS but it's faster. Python is very easy and very portable but it's slower then Java. Html, Javascript and Go are for websites. PHP is designed for the use with databases. Prolog uses a completely different approach and is good for logical stuff.
You see, (almost) every language has its own field of application. Additionally, everyone has a favorite language for whatever reasons (e.g. because he thinks the code is pretty). So it's a matter of taste as well.
nikwen said:
Every programming language has advantages and disadvantages. For example Java is portable but slower then, let's say, C++. C++ is less portable and needs to be compiled seperately for every OS but it's faster. Python is very easy and very portable but it's slower then Java. Html, Javascript and Go are for websites. PHP is designed for the use with databases. Prolog uses a completely different approach and is good for logical stuff.
You see, (almost) every language has its own field of application. Additionally, everyone has a favorite language for whatever reasons (e.g. because he thinks the code is pretty). So it's a matter of taste as well.
Click to expand...
Click to collapse
Thanks for the high quality response.
As a beginner, someone who wants to start developing android applications..What coding language do you think I should start with? I understand android is basically Java?
Blakebn2012 said:
Thanks for the high quality response.
As a beginner, someone who wants to start developing android applications..What coding language do you think I should start with? I understand android is basically Java?
Click to expand...
Click to collapse
Well, it's Java with some extra stuff. That's why I would recommend starting with Java. It's portable, object oriented and you'll need it for Android later anyway.
When I learned Java, I used the Head First Java book which I can highly recommend.
Ok thank you very much you have been a great help.
Blakebn2012 said:
Ok thank you very much you have been a great help.
Click to expand...
Click to collapse
You're welcome.
There's different languages for different things, like Java vs. C++ (Java is portable/cross-platform, pure object-oriented, has automatic garbage collection, etc; C++ is platform dependent and needs to be compiled on each environment, wasn't built from the ground up as OO, you need to allocate and manage memory yourself, etc. Java isn't quite as fast/efficient as C++ but it's come a long way from it's beginnings and is pretty close now, for desktop apps IMO anyway.
Then, for web development, there's Python and PHP. Both accomplish the same thing (doing back-end logic for websites, like querying databases so the data can be displayed on the page) but have different syntax. People like either one for different reasons and it's mainly just personal preference when it comes down to those.
So to answer your question, the difference between some languages is pretty great (like assembly and C#) and they're used for different purposes. And the difference between others, like PHP and Python, is for the most part superficial and it's just personal preference between the two.
The main reason we do have programming languages is that working directly on the bare hardware is pretty difficult. Working directly with machine code is difficult in many ways: it is hard to be kept bugfree, even harder to be read and understood, and there is also the problem that it's only working on a specific machine. Programming languages cope with those problems by introducing programming paradigms, which make several things easier, but it turned out that there is no paradigm which covers all needs. C/C++ for instance makes it possible to work pretty close to the machine while producing quite readable code, which can be ported easily from one plattform to another (compared to using assembly language). In contrast Java introduces a Virtual Machine on top of the actual system such that it's even a lot easier run code across several systems (compile it on one machine, run it everywhere ... as long as a JVM is available), and it brings the object oriented paradigm with it. Furthermore there are declarative languages for database programming, functional programming languages or logical programming languages for mathematical problems around, and so on ... . Sometimes you might not be interested in writing understandable portable code, such that assembly language is your best pet, but that's most probably not true in most situations.
123123132
Really good compact responses. I also want to recommend learning some shell programming, i.e. linux terminal programming for file/process management and low-level hardware manipulation in the kernel. Shells are usually mksh, zsh, bash, busybox ash, or symbolically linked to sh. This is known as a scripting language because you can run your programs/scripts on-the-fly without any compiling. Adding some shell scripts to your java app can make it very powerful such as with apps like trickster, synapse, performance control, etc., .. basically any kernel/hardware control apps.
Also you can try Ruby language. Its great for some everyday tasks, very simple and powerful(especially string processing). Also Ruby On Rails is very simple framework for web-developing. A week and you can try to code your own github. And the IRB console is good enough. But i duuno, is there any mobile-app-dev modifications of Ruby. Anyway, its still great enough.
Blakebn2012 said:
Hi guys, can anyone explain to me why you can have different coding languages? I am going to try and explain it the best way possible. Pretty much I want to know why some people use other coding languages instead of others? Are some better for particular activities? Like I know cross compatibility like you can't use html to code a game online you need to use Flash or Javascript etc.
tl;d why use one language over another?
Click to expand...
Click to collapse
That would be perfect, if we lived in a place where only one language is enough for all works XD
However, the really life isn't perfect.
Some works need complicated language to achieve and some don't.

Categories

Resources