Author Options:

What's wrong with my Android code? Answered

I'm trying to write a simple Android app for my own personal use that gets basic Cpu and Memory information, but I'm only getting 1 error at the end that I can't figure out. The code is attached below, so if someone could be so kind as to show me what's wrong? I get the following error:

Multiple markers at this line
- Syntax error on token "+", delete this
- Syntax error on token(s), misplaced

On the last line:
System.out.println(cpuInfo + memInfo);


> System.out.println(cpuInfo + memInfo);
.  Apparently, "+" is not a string concatenator in Android or you have some other syntax error. But I've never used Android.

It is a valid string concatenator for Android as it's Java.

How did you store the cpu and mem info into the cpuInfo and memInfo variables?

What data type are they?

Are they the data type that println will accept?

Are they data types that can be concatenated with a + ?

.  I dunno, I've never used Android (or Java). Maybe the values are returned as arrays. Google is your friend.

Yeah, I saw that the first time, so no need to italicize, bold, and repeat.

Am I not supposed to offer correct information because someone who never used it gave incorrect information? I do program with Java and the Android framework, which is why I'm offering suggestions.

It'd be more helpful for you to pastebin the relevant code, but I'm still betting on a data type mismatch somewhere.

.  It would seem that you erroneously replied to my comment when you meant to post a top-level comment. If you have any expertise at all with the situation at hand then please (more italic and bold for ya) feel free to offer your advice - just don't reply to this post, instead, click on "Add Comment" above and that will start a new thread.

It would seem you are easily offended and your only defense to being corrected is to trash this thread with your completely irrelevant whining.

I intentionally responded to your incorrect comment to add correct information instead of responding in a separate one which could possibly be buried and detached from what I was referring to. I then added some suggestions instead of further muddling this topic with more comments.

You, however, seem to have got upset that someone corrected your incorrect statement. I have experience with Java/C/C++/C#/x86 ASM/z80 ASM/ARM ASM/VB/XNA/DirectX/Android/CSS/PHP/HTML/JS/Python and plenty more frameworks/apis/languages that I don't feel like bothering. I came here with suggestions based on actual experience and knowledge, and you came here to pull something out your rear, post it, then get upset and muck up this thread when someone corrects you.

You incorrectly assumed you can't concatenate with + in Java/Android, incorrectly assumed I missed your statement that you don't know Java/Android (and thus have no reason to respond), and now are incorrectly assuming that I don't know how to respond to a comment.

Move along now.

Haha, you had your first encounter with grumpy grandpa. Don't worry, stick around. Welcome to Instructables.

Thanks for the warm welcome.

I hope the hostility towards people that correct bad information isn't prevalent here.

You read too much into the replies you get around here. A lot of the sneeriness is a force of habit to deal with the random questions that pop up from users too lazy to look up things and want to be spoon fed the answer. This may not be the case but corrections are always welcome. And if you happen to run into our resident particle physicist, you better cite your sources to back up your answers.

Both are removed as soon as they've been flagged and reviewed...

Hey, I think we found your long lost evil twin or cousin. Wait...that would make him/her nice.

Maybe first try to print out or display cpuinfo alone and memory alone first.
If that works, there is a problem with how you are concatenating the numbers - maybe you have to convert from numeric to text first, and then whatever the correct syntax is to concatenate in a single string. Good luck.