There isn't something like MonoDroid [Acitvity()] attribute/annotation for Android Java SDK? While it is not strange thing in Java (for example WebServlet annotation) it is not possible to have something like that in Android Java SDK?
In fact, I am tired of editing AndroidManifest.xml!
All of your activities must, in fact, be declared in the manifest. I haven't seen any way to get around this so far. Of course, you could imagine some sort of tool that did post processing on your application (via Eclipse or something like that) and generated your manifest for you. However, I haven't seen such a thing, and doubt such a thing exists. Instead, people typically just declare them in the manifest (it takes a few seconds at most), or create them in Eclipse and let it do the "dirty work."
Related
What is happening under the hood? somehow this is passed down to the OS, and someshow the OS will find the right activity / activities, and launch it? Is there a service / lib running in Android handling this? I am trying to modified the OS to override the logic of startActivity across the board, is this possible?
Thanks.
I would take a look at the Android source! Whenever I'm developing and I run into an issue I read through the source to discover what is happening under the hood; it's quite interesting! It's an insight into what's actually going on, and also very good guidelines for documentation and code formatting!
http://source.android.com/source/downloading.html
A good starting point might be ActivityManagerService
Basically, when an app is first launched, startProcessLocked() in ActivityManagerService creates a new ProcessRecord (if necessary) and then calls Process.start(), which in turns builds the arguments for zygote and sends to zygote's socket using zygoteSendArgsAndGetResult(). Of course there's more to it than that, for example if an app shares a uid, is isolated, etc. But that gives you the basic process.
Looking over the source is indeed a good way to understand what's going on. However, unless you're planning on modifying it, don't bother downloading AOSP, just use GrepCode. Easier to browse, search and everything is hyperlinked so it's easy to follow through to classes, find usages, derived methods, etc. If you download AOSP, you'll be stuck with grep, ack-grep if you're lucky and a text editor. Also, you'll only have the one version you picked to checkout. GrepCode has the code for almost every version since 1.5.
The linked text above will take you to the relevant source at GrepCode. Try it out! The only downside is that GrepCode doesn't include the native C++ layer.
Ok, so it might be a stupid question that is very obvious... anyway, I am making a new application and I wanted to know if I should make a package for every category of objects,
for example: Monsters, PowerUps, Powers, FrameWork(where I make classes that I implement from) etc.
I am using canvas and a thread class to handle what happens inside the canvas(lockcanvas, unlock and post etc.)
So, should I make everything in one package or few packages, and will it be harder or do I need to know something to use these packages? Thanks!
It's entirely up to you how you group your classes. In terms of coding, it makes little difference as Eclipse will work everything out for you. Instead, consider how you can use packages to help you quickly go to the right place when you return to your code in six months time to correct a bug.
IMHO, your proposal seems to result in a few too many packages for comfort. I don't know how complicated your code is, but if you've only got a handful of classes per package, that's probably a bit too fine. Probably better to break your app into larger chunks of functionality. It's also worth spinning common "helper" or "utility" classes into their own package too.
As with any aspect of coding style, opinions will vary. But I found the following article to be well argued...
Package by feature, not layer
You could get the same organizing effect you are looking for by using folders inside the package to group code without all the hassle of additional packages. Unless you have a special technical requirement for multiple packages I would try to keep things as simple as possible.
I was using DroidDraw, working through the tutorials. Looking at the resulting XML and the Java code to tie them together, I was thinking that I could build a program to automate that process, so I started noodling something together. But before I go off and totally remake the wheel, I was wondering if something like this hasn't already been made before?
I'm thinking of something that takes the layout XML from DroidDraw, and outputs a Java application that works, and is ready for you to add your own code.
It seems pretty basic, has it been done and I've just not spotted it? I've tried Google searches, but I don't see anything similar.
The built-in UI editor that comes with Eclipse used to be pretty crappy - however, it's now getting better and better. Rev 11, which is coming out soon will a lot of new and useful features also.
Give it a try - I think you'll find this is the best tool.
The resulting XML file you can take from DroidDraw requires no Java code.. you simply setContentView(R.layout.name) and that's it!
Just use IntelliJ or Eclipse to set up a skeleton project for you, and import the XML you created via DroidDraw.
There is App Inventor. I have not tried it myself but it sounds pretty much like what you want.
As far as I know it is a very visual approach to develop an application.
I've just coded android for a few months, and I really enjoy it, but I find myself writing the same "(TextView)findViewById(R.id.mytextview)" code over and over again.
Coming from asp.net I can't help but wonder why there's no auto-generated class from which I can access my xml-declared views(controls) strongly typed?
Actually I kind of solved it for myself by creating a "viewshelper"-class for complex activities, so I can do "_views.mytextview" when I need the textview, but I still have to maintain these classes by hand each time I add or remove views.
Am I missing something, or should the android sdk do this for me?
Take a look onto roboguice, it looks like the library takes care about the problem.
IMHO, You are missing the Java approach for application development.
This is quite normal for those that use Eclipse (with out plugins) at the beginning this seam to be very problematic, but now i think that that show only the developer limitation.
I have a particular collection of code along with some XML files that I need to share with every application I will make.
At the moment I can't because as far as I am aware there is no way to do this. This seems like a massive oversight by the development team.
If the code needs changing, I have to change it in every app that I create - and will create in the future.
Are there any ways to share code in android yet?
I am using Eclipse for development.
You can create an Android library project. The TicTacToeMain sample project in the SDK shows how to reference your created library project.
You can reference a third party JAR like you would any Java project. Or are you talking about something else?
As for sharing XML files, I think you may have to just copy them to each project, but I'm not certain about that.
You can reuse particular Activity classes in applications other than the one they were installed with. Is that sufficient?
To do that, you need to set android:exported="true" in the Activity's declaration in AndroidManifest.xml. http://developer.android.com/guide/topics/manifest/activity-element.html has more details.