Swastik
Life is easy because we write the source code.....
Swastik Dey wrote:
As per your error log, the exception is occurring in the above line, i.e. NumberFormatException. As per the log its probably trying to parse a space character. Do a log trace to find out what value are you getting in actVal.
Swastik
Swastik
Swastik Dey wrote:Just look at the error log you have mentioned it displays
java.lang.NumberFormatException
I still doubt in some condition it's getting a space character as your error log says that.
Life is easy because we write the source code.....
Swastik
Pramod P Deore wrote:what is at line 40?
Life is easy because we write the source code.....
Swastik
Pramod P Deore wrote:print the value of tempStr, at the start of callCompleted(String tempStr)
{
System.out.println ("tempStr is"+tempStr);
}
Just an outside question: Is there a way to display the contents of LogCat directly in this forum (or maybe other help forums like StackOverflow) without taking a print screen and attaching the image?
Life is easy because we write the source code.....
Swastik Dey wrote:From your code what looks to me the server is returning some name and value. So instead of returning the message like that, why not make it simpler
<msg name='a' value='1.0'/>
or may be
<msg>
<name>a</name>
<value>1.0</value>
</msg>
and now use some standard parsers like Jdom or Sax.
Swastik
Pramod P Deore wrote:
Just an outside question: Is there a way to display the contents of LogCat directly in this forum (or maybe other help forums like StackOverflow) without taking a print screen and attaching the image?
Copy it from logcat and print it like code you have printed above.
Swastik
Swastik Dey wrote:What code do you have in line number 54 in TCPListen.java?
Swastik
Swastik
Swastik Dey wrote:One more point, what's the use of using a loop in postExecute. Why not change the method signature of the listener interface and pass the entire ArrayList, in this case it will decrease the number of method calls as well.
Swastik
Swastik Dey wrote:Probably you can make one more change as well. I am not getting the use of the loop in doInBackground(),even if the server returns one message loop continues till 100. You may follow the following process.
1. doInBackground message gets one message from server
2. return the message
3. onPostExecute is fired with the String response(not ArrayList)
4. invoke callCompleted with this String.
Swastik
Swastik Dey wrote:Ok, so if the client is supposed to receive n number of messages, even that for loop can't be a proper solution. I assume that you are not going to receive all (n) messages at a time, rather at a specific time interval. If this is the case why not use Timertask to schedule this activity. Start a time task, which runs at a specific time interval and executes the asynctask. Some message arrives you show the user the proper notification.
Swastik
Swastik Dey wrote:Ok, even if the message comes at any time, its at least going to take one second if not more. So what's wrong in scheduling the task, which checks for a new message after every one second, and of course the client app is running.
Swastik
Swastik
Swastik Dey wrote:I am asking you to schedule at the client end. In stead of starting the asynctask from main activity start it from the scheduler. And process it just using a String no ArrayList.
Swastik
Swastik Dey wrote:Yes you are right, I considered to be one minutes. Sorry about that.
Swastik Dey wrote:I had used this just to test the server response.
Swastik
Swastik Dey wrote:You have called setContentView twice. Remove the first call.
Madhu Nandan wrote:
Swastik Dey wrote:You have called setContentView twice. Remove the first call.
Oh, I had overlooked it. Now I corrected that. But there is another error in timer task-cannot create handler.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.main);
// Set up the window layout
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);
// Set up the custom title
mTitle = (TextView) findViewById(R.id.title_left_text);
mTitle.setText(R.string.app_name);
mTitle = (TextView) findViewById(R.id.title_right_text);
TcpServiceHandler handler = new TcpServiceHandler(this);
handler.execute("");
_timer=new Timer();
MessageConsumer mc = new MessageConsumer(this);
//check after every one second
_timer.scheduleAtFixedRate(mc, 0, 1000);
}
Swastik Dey wrote:You have called setContentView twice. Remove the first call.
Don't get me started about those stupid light bulbs. |