Converting equations to java for android?

I am a cameraman and I want to make an app for my Moto Droid that will calculate my depth of field given four inputs.

I am literally brand new to javascript and this programming stuff, so I was wondering if anyone could help me out.

I have a very basic GUI set up using Droiddraw which allows me to input my 4 variables, which are:

Focus (@+id/focust)

Focal Length (@+id/flt)

Aperture (@+id/apt)

Circle of Confusion (@+id/coct)

Equations for this calculation are located here

for example...

to get hyperfocal distance I need to get: ((f^2)/(N*c))+f

all of these variables will be drawn from inputs in the GUI, but I don't know how to call them, how to write the actual math, and how to address the results so I can make them appear in the "results area" on the bottom of the screen.

I've never done java before and I only want to make this app because the existing ones don't fit my needs.

Can someone help?


Asked by: Freddie461 | Posted: 20-01-2022

Answer 1

If I'm not mistaken, DroidDraw is a tool for building the XML user interface description used by the Java API. If you want to program for Android in JavaScript, something like PhoneGap might be a better choice. It lets you build real Android application using HTML and JavaScript.

On the other hand, if you want to use the XML and Java APIs, then you should probably run through the Android tutorials. The first one is Hello, World.

Since you're just getting started with programming, I can't stress tutorials enough. It's true that your idea shouldn't be too hard to implement, but you need to understand the basics first.

I don't mean to give the impression that one style (PhoneGap vs. Java and XML) is better. For your purposes, either should be fine. It's more a question of what you prefer. Java/XML is the paradigm supported by Google, and provides access to more functionality. On the other hand, if you already know HTML or JavaScript (or are interested in learning them), PhoneGap will certainly provide everything you need. I think PhoneGap is also intended to make it easier for beginners, though I haven't used it, so I don't know how successful they have been.

The XML file that is generated by DroidDraw can't be used within PhoneGap. If you do choose to use PhoneGap, then you will need to build the interface in HTML. You might be able to use something like DreamWeaver or FrontPage or one of any number of HTML editors to help you with this step.

The XML file is just a description of an interface. When you start your application, the Android platform uses this description to build the user interface that you see. Once that has happened, you can move data from the interface to Java, or from Java to the interface, without any hassle. You certainly won't be limited by the XML interface description - it's pretty flexible.

If you've been going through the Android tutorials, then it might be best to forget that I even mentioned PhoneGap. It's a wildly different alternative that is the right choice for some people and some applications. But the Android tutorials won't help you to understand it. I only brought it up because you mentioned JavaScript in your original post.

Answered by: Briony965 | Posted: 21-02-2022

Similar questions

Converting & to & in android?

I have a URL string in the following format. I want to replace & with & in the above URL. My result should be:

java - Converting a string to an integer on Android

How do I convert a string into an integer? I have a textbox I have the user enter a number into: EditText et = (EditText) findViewById(; String hello = et.getText().toString(); And the value is assigned to the string hello. I want to convert it to a integer so I can get the number they typed; it will be used later on in code. Is there a way ...

Converting a view to Bitmap without displaying it in Android?

I will try to explain what exactly I need to do. I have 3 separate screens say A,B,C. There is another screen called say HomeScreen where all the 3 screens bitmap should be displayed in Gallery view and the user can select in which view does he wants to go. I have been able to get the Bitmaps of all the 3 screens and display it in Gallery view by placing all the code in HomeScreen Activity only. Now, this ...

Converting base64 String to image in Android

Is there any way that I can convert a base64 String to image in Android? I am receiving this base64 String in a xml from the server connected through socket.

image - Android Converting from NV21 Preview Format on Nexus one to JPEG

How can I convert from NV21 to JPEG. Currently, NV21 is the only previewFormat that is supported by the camera on a Nexus One (running Android 2.2). Thanks.

android - Converting sql data before presenting it in ListView

I'm trying to modify an existing notepad example from the Android Developer site. I have a database with an existing column named CREATED_DATE(of the note) but the data for that column is presented as System.currentTimeMillis(). This is all good and probably in line with conventions since it's created by the developers. But my problem is that I want to present the date in a ListView...

Android Converting objects to XML and vice versa

I created a xsd and I created Java objects using Castor. Then I imported this in my Android project and tried to build an XML from the object, using the marshal method. Marshaller.marshal(v, writer); I received some wired exception trouble processing "javax/xml/parsers/DocumentBuilder.class":... So my question is Can I use Castor inside Android, If yes how can I work a...

java - Converting time durations from string to float

I'm working on an Android application that tracks time durations of tasks. Internally, it saves these durations as a float representing how many hours were spent on the task. So 30 minutes would be 0.5, 1 hour would be 1, etc. I've got all that code working great, along with code to convert these into hh:mm format for easier reading. However, there's also an aspect where the user can manually change this value u...

converting a canvas into bitmap image in android

I am trying to develop an app on canvas,I am drawing a bitmap on the canvas. After drawing, I am trying to convert into bitmap image. Can anyone give me a suggestion?

converting canvas into bitmap in android

I am trying to develope an app on canvas ,i am drawing a bitmap on canvas with the help of canvas.drawBitmap().After that i want to convert that canvas into bitmap. can anyone give me suggession thanking you in advance

Still can't find your answer? Check out these communities...

Android Google Support | Android Community | Android Community (Facebook) | Android