Sean Michael Hayes

Ranch Hand
+ Follow
since Feb 08, 2012
Sean Michael likes ...
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sean Michael Hayes

Maneesh Godbole wrote:The getValue() will be called whenever the table wants to repaint itself. From a developer's perspective that will be any time after the table is displayed on the UI

Good point, I better make a cover for that. Thanks for the heads up.
5 years ago

Maneesh Godbole wrote:Uh oh! I see a Null Pointer exception if your rowList is empty

The getValueAt method is only called when I pass data into the table and reload it, or am I missing something here? It isn't automatically loaded at the start.
5 years ago
Well I'm thick....

Turns out the problem was in my GetValueAt method. I had set the boolean value to false in a switch statement. This was during the stage where I just wanted the table to display and then forgot to add logic to it.

5 years ago
I have a checkbox in a JTable. This JTable uses an abstractTableModel with each row being populated by an arraylist containing Objects. One value is a boolean value that appears on the table as a checkbox. When I click on this checkbox. The value of the boolean in that particular object changes but its GUI representation does not check/uncheck itself to represent this. Is there something wrong with my setValueAt method in my custom table model?

5 years ago

Steve Luke wrote:Are you saying that the method reaches line 21 (the curr.alerted() method) but does not reach line 22 (the Log statement)? If so then
1) I would check the logs to see if there is an error
2) If no error, then the curr.alerted() method must hang, blocking the Timer's thread from executing further. Figure out what makes it hang, and make it stop.

The DDMS tools which ship with the Android SDK should help you figure out the state of the timer's thread.

That was it, for the telnet, I parsed the text as it came in. I was asking it to read up to a word that actually never appears. Just telling it to disconnect when its action is sent fixed the issue.
5 years ago
I've been looking at this problem for hours now and nothing seems to be clicking.

I have a local service to monitor the values retrieved using SNMP and compare them to stored values in object instance, if a value exceeds that amount defined in the instance, a telnet command is launched to that machine over the network.

In the monitor task, the run method shall run the performAction() method.

When the alerted() method is called by the alertObject, the timer seems to stop with it and shall not run again. Is the telnet command I'm launching from that instance interfering somehow?
5 years ago
I have an App that is listening on a certain port for messages to come through. I need this service to run as long as the Application is running on the phone. However, the problem I seem to have is that the Service seems to die seconds after it is created in the code and then started again according to the logs and then seems to die again later.

What is weird is that the destruction of the Service is not logged despite me putting a log message in the OnDestroy() method to inform me if it dies.

here is the Service being launched in my main code.

And here is the service, I am using the setForeground method as that seems to be the solution according to Google
6 years ago
What would be the best way of accomplishing this? The service is started on start-up of the application when the first activity loads. But later on in the application in a different specific activity I want to pass a variable to the service? I am new to services in Android and am wondering if anyone could point me in the right direction?
6 years ago
Is it possible to create your own custom traps in SNMP4j, like for example, if a certain value on my laptop like.....number of processes exceeds a specific amount, a Notification is triggered?

Sahil Rally wrote:Hii Sean

Use Context object available in onReceive() method.


NOTE: Both Activity and Service extends Context , so if you are launching Notification from Service/Activity , you can simply use this.

Thank you for the reply Sahil, however I tried your technique and I was still getting a NullPointerException. I eventually solved the problem by simply passing in the context of my service into the reciever class and assigning it to a variable there.
6 years ago
I'm running a service on my Android Application to listen for SNMP trap messages (calling my trap receiver's listen() method) on a port. When a PDU is recieved on that port, a Notification is meant to be sent to my phones status bar.

However, when I try sending a test trap that will automatically be picked up by my receiver class, it gets the PDU but no Notification is sent. I'm getting a NullPointerException on this line:

The line was originally:

The first line was an attempt at solving the problem as I thought the issue was it was not getting an Activity Context to call NOTIFICATION_SERVICE so I found this solution where the current Activity on top of the stack is stored in an Activity variable and we can call it using the ref_currentActivity() method and get the Context from that but it doesn't seem to work. Here's the code for my trapReceiver class:

BTW I'm using API level 8
6 years ago

Paul Clapham wrote:What I would recommend is this:

1. Use DOM to parse the file and build a Document object.

2. Use XPath to find the element into which you want to insert your newly-built element.

3. Insert the newly-built element into the element you just found.

4. Write the Document out to a new file using a Transformer.

I'll certainly give that a try! Thank you very much! :)

Jayesh A Lalwani wrote:How are you reading and writing the file right now? Which API do you use?

I am using SAX to parse the XML file. Up to now I have only been reading from the XML file, I have not written anything to it yet.
I have this xml file

What I want to do is get a new <reading> element with its children (I know how to create one) and insert it at the end of the <readings> element after the last child of <readings>

But the problem is that it needs to be inserted in to a specific device based on its <name> element value, not all of them. How would I do this with the way the file is written now?
I understand if the file is not written in the best way to allow this but modifying how the file is written would require re-doing a lot of my java code so if it is possible I would rather go ahead with that.

Peter Johnson wrote:Yes, this should really be asked in the Android forum, I'll move the post for you. I suspect that you are running into one of the methods that is not provided on the Android platform (which is not 100% Java compliant), hence the error.

Thanks for the reply and you are indeed right! I was using API level 8 as my Android API and did not realise that it only supported JDK 1.5 and below. I couldn't upgrade my API as my Samsung Galaxy mini did not support any higer so I simply overrode the method and replaced the 1.6 methods with a 1.5 equivalent (System.arrayCopy) and it seems to work!
6 years ago