Posts Tagged ‘Java’

Android: Howto find the hardware MAC address of a remote host

Monday, February 7th, 2011

I recently needed to find the MAC address of a remote host in my LAN by its IP address.

Unfortunately, Java/Android does not offer an API to find a MAC address by IP. :-(
The DatagramPacket class does not reveal this information for the source host, either.

But Android is Linux, and hence we can try to find the MAC by accessing the ARP cache information!

(more…)

If you like my work, buy me a beer. (Suggested: 3€ for a beer, or more for more beer ;-) )

Sending mails on HTC Hero

Thursday, October 8th, 2009

I wanted to create an automatically crash report feedback in SqueezeCommander.

I thought, the easiest solution would be to send the reports by mail, so the user can also see all informations that will be reported to me and choose if he wants to send or discard the report.

Normally, it should be possible to send emails from within an application by creating an intent Intent.ACTION_SEND with extra parameters.

Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "email text");
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] {"email@address.com"});
sendIntent.setType("message/rfc822");
startActivity(Intent.createChooser(sendIntent, "Title:"));

Unfortunately, this does not work on my HTC Hero. ;-(
(more…)

If you like my work, buy me a beer. (Suggested: 3€ for a beer, or more for more beer ;-) )

OpenOffice.org Extension Development with Eclipse (ooeclipse)

Sunday, June 28th, 2009

How to create a OOo Java Extension using Eclipse as IDE

Recently, I tried to create an OpenOffice.org Extension (.oxt) with Java. I’m using Eclipse as Java IDE for all my projects, so I wanted to use Eclipse for this task as well.

There is an Eclipse plugin to help you with this task, but there are come caveats. The old versions of this plugin do not work with the current OpenOffice.org version (3.0+).

You will probably get an error message when trying to specify the SDK (“SDK version has to be at least 2.0.4″) or the OOo location (“Invalid OOo path”)  in the plugin.

Eventually, after some time searching the web, I  found a working solution! (more…)

If you like my work, buy me a beer. (Suggested: 3€ for a beer, or more for more beer ;-) )

Read a zip file comment with Java

Wednesday, January 7th, 2009

I was not able to find a Java build-in solution to read the file comment of a ZIP.

Reading the comment of a ZipEntry can easily be done by invoking ZipEntry.getComment(), but you cannot read the global archive comment of the ZIP file with it.

Therefore, I have implemented the following solution. It reads n bytes from the end of the ZIP file and searches (backward) for the magic sequence that indicates the end of the ZIP contents.

(more…)

If you like my work, buy me a beer. (Suggested: 3€ for a beer, or more for more beer ;-) )