David Freitag

Greenhorn
+ Follow
since May 28, 2011
David likes ...
Android C++ Python
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by David Freitag

You should try downloading the newest version of netbeans, it shows you using v6.5, 7.0 is out now. If that does not work i would check to see if you have the latest version of the java... and if none of that works i would switch to Eclipse, mostly because it is supported by the devs@google...
6 years ago
It appears the problem i am having is a verizon related issue.

A friend of mine, who just got done doing some work on some verizon towers told me that it was because their towers, and really their entire network as a whole are very, very old. That this was the reason why only Verizon's NAT assigns a private ip address to all mobile phones. But he also said that they are in the middle of a massive overhaul, and around a year from now this whole problem may be settled. But from what i understand Verizon wants it to be this way, something about a private ip address being more secure or something.. But the good news is that most other service providers worldwide do not assign private ip's via their NAT.
I am developing an Android app for the company i work for, we create instruments that calibrate instruments that measure air quality all around the world... most of the time companies that maintain these instruments are on average 1000km away from the instruments in question, so having a mobile app to communicate with those instruments is... quite handy indeed.

Getting on to it... This is my first plunge into networking, so bear with me. Basically the application opens a direct socket to an instrument and sends and receives plain string arguments. So far i have been able to successfully achieve this goal over a Wifi connection (Quite proud of myself, as this is really my first program that not only i will be using...).

But when it comes to opening direct sockets over 3G there seems to be a major issue, at least with Verizon...

Reading around the net i have managed to learn a bunch about how networks actually work, and that while connected to 3G over Verizon's network, mobile devices aren't assigned ip addresses...
Something about the NAT used to route the connection, i honestly have no idea what that means, i just know it makes direct ip sockets impossible, or at the very least BurrferedReaders impossible...
Essentially this pseudo code explains exactly how the app works as of late,

That is surrounded by a hand full of listView's and various GUI components to make it a functioning app, but this chunk is the only real "Functional" part of the program.

This is probably the most standard socket thread there has ever been, and it works (I wouldn't say perfectly, but well will suffice) over Wifi.
This is all well and good, accept in the world of mobile devices, being constrained to Wifi only on a mobile application is as close to useless as it gets.

Is there any native part of java that can be utilized over 3g, to pass string arguments?
Heck even if i needed to add a library to my code, if it works i'd take it.

PS: It took quite a while for me to decide which forum this topic belongs in, after some thought, yes it is under the mobile context, but the content is mostly geared towards Sockets and other networking portions of my program, Sorry in advance if this is decidedly in the wrong place.
You are missing the point, i modified my post to reflect exactly what i was trying to say.. sorry for any confusion.
6 years ago
It doesn't really matter where the string comes from, what Rob said still stands true. You may want to look into built in Java Encryption to handle your passwords.
You may want to look into This article.
6 years ago
Well, the only way i know of how to pass information between activities is using a Bundle.
But that involves directly starting an Intent, and im not sure thats what you are looking for but here 'goes.

to pass information into the Activity in question, you use Intent.putExtra();

You will use that PrefixTitle in the TargetActivity to look for the correct information, there are several different data types that can be passed not just Strings as in this example.


Hope that helps..
6 years ago
I didn't mean function as in a method or constructor, i just meant that it is a part of java..

And thanks ;]
6 years ago
The System.out.println part of java is used to print strings to a console.

If you are working with strings you will all ways be using double quotes, or ""s.

The '+' sign is used to concatenate strings... thats just a big word meaning, to add them together.
Example:

will print out HelloWorld.
if you are going to print out a bunch of variables concatenated together to form one long string, you need to start with a string..
Example:

this will output:

Output: 25, 32, 50

6 years ago
There are tons of ways to work with Exceptions, and Exception types.
My favorite (And probably not the best method) is using try/catch
Example:


Generally i try to use just the simple java Exception, because it will give information about ANY Exception thrown about what you are trying to do. Further down the line your programs may need to do certain things based upon what error is thrown, that is where you would want to become more specific in what Exception you want to be looking for.

This will print to your console what exception is being thrown, from there you can do a few quick google searches to find out what the problem may be. But in this case its because you are trying to divide by zero.

if you try to run that, it will print out:

java.lang.ArithmeticException: / by zero


and a java.lang.ArithmeticException: / by zero search will give you more information on why that is bad.
6 years ago
It sounds like you are asking whether you can modify the strings stored in the "strings.xml" file in your code like you could manipulate any other string stored as a variable..

The answer to that question is No. Those values are Constants, IE they cannot be modified unless you open the file in eclipse and manually change them.

If you want Strings and String-array's that are modifiable while the program is running, then you will need to create and modify them within the java portion of android.

Pseudo code:


An extremely simple example but you get the point.

If you mean actually opening the "strings.xml" file in eclipse? then yes, it is completely modifiable, its just that you need to use the proper syntax to create the variables.

Pseudo code:


just paste that into strings.xml, just make sure that strings.xml begins with

and ends with


To use a string or string-array defined in this file, or any other file like this, use


If you aren't sure where to put that code, hit "Ctrl + f" on your keyboard, and search for

and paste it into the end of the constructor.

if you don't know what LogCat is, in Eclipse click Window -> Show View -> Other... a window will pop up, maximize the folder "Android" to the left and select "LogCat" and click Ok.
6 years ago
Have you actually created an emulator using the AVD manager?
Try this:


It just sounds like you are telling Eclipse to use an AVD that you don't actually have.

your console output should look more like this:

[2011-05-29 02:11:51 - Environics] Android Launch!
[2011-05-29 02:11:51 - Environics] adb is running normally.
[2011-05-29 02:11:51 - Environics] Performing com.Environics.MainView activity launch
[2011-05-29 02:11:51 - Environics] Automatic Target Mode: Several compatible targets. Please select a target device.
[2011-05-29 02:11:54 - Environics] Uploading Environics.apk onto device 'emulator-5554'
[2011-05-29 02:11:54 - Environics] Installing Environics.apk...
[2011-05-29 02:12:11 - Environics] Success!
[2011-05-29 02:12:11 - Environics] Starting activity com.Environics.MainView on device emulator-5554



And to find installed applications you want to open the Application Drawer,

That will open a window,

that is all of the installed applications, to run one just click one.
6 years ago
For starters this is what was dumped into my console:

Conversion to Dalvik format failed with error 1
trouble processing "java/nio/CharBuffer.class":

Ill-advised or mistaken usage of a core class (java.* or javax.*)
when not building a core library.

This is often due to inadvertently including a core library file
in your application's project, when using an IDE (such as
Eclipse). If you are sure you're not intentionally defining a
core class, then this is the most likely explanation of what's
going on.

However, you might actually be trying to define a class in a core
namespace, the source of which you may have taken, for example,
from a non-Android virtual machine project. This will most
assuredly not work. At a minimum, it jeopardizes the
compatibility of your app with future versions of the platform.
It is also often of questionable legality.

If you really intend to build a core library -- which is only
appropriate as part of creating a full virtual machine
distribution, as opposed to compiling an application -- then use
the "--core-library" option to suppress this error message.

If you go ahead and use "--core-library" but are in fact
building an application, then be forewarned that your application
will still fail to build or run, at some point. Please be
prepared for angry customers who find, for example, that your
application ceases to function once they upgrade their operating
system. You will be to blame for this problem.

If you are legitimately using some code that happens to be in a
core package, then the easiest safe alternative you have is to
repackage that code. That is, move the classes in question into
your own package namespace. This means that they will never be in
conflict with core system classes. JarJar is a tool that may help
you in this endeavor. If you find that you cannot do this, then
that is an indication that the path you are on will ultimately
lead to pain, suffering, grief, and lamentation.



Since i have been developing with Android and Eclipse i have noticed a bunch of small hiccups, whether it is ADB, Eclipse, or my Droid that is causing issues.
One such issue is this one, which by the way left me at my knees for over an hour... but it could have been worse, all of my code is in-tact, no major problems, but the most major as of yet.

I just wanted to document what i did to solve this problem, so others can figure it out on their own, being that some developers (Like myself are not complete experts) and may run into this problem...

Essentially this is what happened, as i mentioned before, there are hiccups in the process, one such hiccup seems to be a loss in the link between my Android project, and the "Android X.Y" library.
At which time was not immediately bad, it was only until i saved what i was currently working on that i noticed a problem, as Eclipse (Being as awesome as it is) Ran an automatic build, this prompted a window letting me know that the link to the library was lost, and that i needed to tell eclipse what android library my project should build under.

Being that my development just a few months ago amounted to notepad and command prompt, the learning curve on my own has been quite steep. Also being that i have been awake now for just over 24 hours made figuring this one out a bit of a daunting task.

When this dialog came up, i neglected to pay attention to exactly what it was going to do when i mindlessly clicked "Ok", i just clicked "Ok". That is when the error hit. Because i did neglect to actually read the dialog, i immediately went through the list of things i do to try and solve these seemingly useless, random errors. Unplug and plug in phone, restart Eclipse, restart ADB and finally Reboot... After all that no dice.

It took some Googling, but i managed to narrow it down to a few handfuls of problems. (Most of which involved things above my intelligence level currently...)
Either the message is true, and i am trying to add java core packages to my build path (Which i would never do... because that just seems like a massive waste of time and CPU...)
Or there is a problem with my Build Path.

Being that i went from Command prompt and Notepad, my knowledge of stuff like this is still extremely lacking. From what i understand a Build Path is exactly what it says, the path your linker looks through to build your applications.. IE the link to the "Android X.Y" Library. When it hit me, that dialog asked me to modify the Android Library location.

I opened my Current project's properties, and referenced what was under the "Libraries" tab in the "Build Path" tab to other perfectly functioning projects in my workspace, and sure enough there was a stray "Android.jar" that was pointing at the jar where i have android installed on this box. My guess is somehow Eclipse lost the ability to find that "Android X.Y" library, had me mindlessly add this "Android.jar" to my build path, and seeing as that probably uses core java stuff, it thought i was trying to. At some point (My guess is when i restarted Eclipse) Eclipse realized that it was in fact an android project, and added the "Android X.Y" library to the build path...

Once i removed the stray "Android.jar" and did a refresh to run the automatic build everything was fine again. This just goes to show, ALWAYS read stray error dialogs, no matter how short your attention span.

Hopefully this will help someone in the future, because there are probably other developers like me (Still a noob) trudging their way through developing...
6 years ago