<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>flattermann.net &#187; Java</title>
	<atom:link href="http://www.flattermann.net/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.flattermann.net</link>
	<description>flattermann&#039;s developer blog</description>
	<lastBuildDate>Sat, 10 Jul 2010 16:44:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Sending mails on HTC Hero</title>
		<link>http://www.flattermann.net/2009/10/sending-mails-on-htc-hero/</link>
		<comments>http://www.flattermann.net/2009/10/sending-mails-on-htc-hero/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 10:23:41 +0000</pubDate>
		<dc:creator>flattermann</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.flattermann.net/?p=445</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to create an automatically crash report feedback in <a href="http://sqcmdr.flattermann.net">SqueezeCommander</a>.</p>
<p>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.</p>
<p>Normally, it should be possible to send emails from within an application by creating an intent Intent.ACTION_SEND with extra parameters.</p>
<pre class="brush: java;">
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, &quot;email text&quot;);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, &quot;Subject&quot;);
sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] {&quot;email@address.com&quot;});
sendIntent.setType(&quot;message/rfc822&quot;);
startActivity(Intent.createChooser(sendIntent, &quot;Title:&quot;));
</pre>
<p>Unfortunately, this does not work on my HTC Hero. ;-(<br />
<span id="more-445"></span><br />
After some debugging, I found the reason:</p>
<p>HTC has implemented an own mail client (com.htc.android.mail) and it seams that this mail clients does not register correctly for Intent handling.</p>
<p>Therefore, <strong>the mail will be delivered to the internal Android Mail client</strong> (com.android.email), but that one is normally not configured (it does not share the settings with HTC Mail). <img src='http://www.flattermann.net/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
<p>I was able to make it work by using &#8220;text/plain&#8221; as message type:</p>
<pre class="brush: java;">
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, &quot;email text&quot;);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, &quot;Subject&quot;);
sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] {&quot;email@address.com&quot;});
sendIntent.setType(&quot;text/plain&quot;);
startActivity(Intent.createChooser(sendIntent, &quot;Title:&quot;));
</pre>
<p>Using this code, a chooser is shown to the user that also includes HTC Mail.</p>
<p>Unfortunately, even this solution does not work 100%, because if the user selects HTC Mail, the <strong>receiver address is not inherited</strong>. <img src='http://www.flattermann.net/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
<p><strong>I&#8217;m still searching for a working solution&#8230;</strong></p>
<p>For the crash reports, I&#8217;ve now set up a PHP script on my server that receives the crash report via POST request from my Android users and forwards it to me by email.</p>
<p class="buymebeer"><form action="https://www.paypal.com/cgi-bin/webscr" target="paypal" method="post"><input type="hidden" name="cmd" value="_xclick" /><input type="hidden" name="business" value="donation@flattermann.net" /><input type="hidden" name="return" value="" /><input type="hidden" name="item_name" value="Donation for Sending mails on HTC Hero" /><input type="hidden" name="currency_code" value="EUR" /><input type="hidden" name="amount" value="" /><input type="image" src="http://www.flattermann.net/wp-content/plugins/buy-me-beer/icon_beer.gif" align="left" alt="Buy me a beer" title="Buy me a beer" hspace="3" /></form><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&amp;business=donation@flattermann.net&amp;currency_code=EUR&amp;amount=&amp;return=&amp;item_name=Donation+for+Sending+mails+on+HTC+Hero" target="paypal">If you like my work, buy me a beer. (Suggested: 3€ for a beer, or more for more beer ;-) )</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.flattermann.net/2009/10/sending-mails-on-htc-hero/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>OpenOffice.org Extension Development with Eclipse (ooeclipse)</title>
		<link>http://www.flattermann.net/2009/06/openofficeorg-extension-development-with-eclipse-ooeclipse/</link>
		<comments>http://www.flattermann.net/2009/06/openofficeorg-extension-development-with-eclipse-ooeclipse/#comments</comments>
		<pubDate>Sun, 28 Jun 2009 16:01:51 +0000</pubDate>
		<dc:creator>flattermann</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Calc]]></category>
		<category><![CDATA[OpenOffice.org]]></category>

		<guid isPermaLink="false">http://www.flattermann.net/?p=369</guid>
		<description><![CDATA[How to create a OOo Java Extension using Eclipse as IDE Recently, I tried to create an OpenOffice.org Extension (.oxt) with Java. I&#8217;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 [...]]]></description>
			<content:encoded><![CDATA[<h3>How to create a OOo Java Extension using Eclipse as IDE</h3>
<p>Recently, I tried to create an <strong>OpenOffice.org Extension (.oxt) with Java</strong>.  I&#8217;m using <a href="http://www.eclipse.org" target="_blank">Eclipse</a> as Java IDE for all my projects, so I wanted to use Eclipse for this task as well.</p>
<p>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+).</p>
<p>You will probably get an error message when trying to specify the SDK (<em>&#8220;SDK version has to be at least 2.0.4&#8243;</em>) or the OOo location (<em>&#8220;Invalid OOo path&#8221;</em>)  in the plugin.  <strong></strong></p>
<p><strong>Eventually, after some time searching the web, I  found a working solution!</strong> <span id="more-369"></span>There is a tutorial about this issue at the OpenOffice.org Wiki:</p>
<p><a href="http://wiki.services.openoffice.org/wiki/JavaEclipseTuto" target="_blank">http://wiki.services.openoffice.org/wiki/JavaEclipseTuto</a> <strong></strong></p>
<p><strong>Unfortunately, the mentioned Eclipse plugin update site link does not exist anymore and the mentioned CVS version of the plugin does not work with OpenOffice.org 3.0.</strong></p>
<p>After searching the web, I found the new GIT Source Repository of the Eclipse plugin here:</p>
<p>git://anongit.freedesktop.org/git/ooo-build/contrib/ooeclipse</p>
<p>It is administrated by <strong>Cédric Bosdonnat</strong> &lt;cedricbosdo [AT] openoffice [DOT] org&gt;, the author of the ooeclipse plugin.</p>
<h3>Working Eclipse plugin update site</h3>
<p>Because I could not find an Eclipse update site hosting this version of the plugin, I&#8217;ve taken the source and created a plugin update site with the most current version of the plugin on my own:</p>
<p><a href="http://drake79.users.sourceforge.net/ooeclipse/site" target="_blank">http://drake79.users.sourceforge.net/ooeclipse/site</a> <strong></strong></p>
<p><strong>Do not try to download the plugin from this URL with your internet browser. This will not work!</strong></p>
<p><strong> </strong> <strong>Instead, Eclipse will do it for you when you do the following steps:</strong></p>
<p>In Eclipse, select <strong>Help &gt; Software updates &gt; Available software &gt; Add Site</strong> and enter the mentioned URL.</p>
<p>Below the new site, select <strong>OpenOffice.org</strong>, click on <strong>Install</strong> and follow the instructions on your screen.</p>
<p>After you&#8217;ve installed the plugin, follow the <strong>Tutorial from the OOo Wiki</strong> to create your first HelloWorld extension:</p>
<p><a href="http://wiki.services.openoffice.org/wiki/JavaEclipseTuto" target="_blank">http://wiki.services.openoffice.org/wiki/JavaEclipseTuto</a></p>
<p>I will try to keep the update site up-to-date.</p>
<hr />
<h4>Update (2009-07-01):</h4>
<p>Cédric&#8217;s page seems to be working again:</p>
<p><a href="http://cedric.bosdonnat.free.fr/wordpress/?page_id=11&amp;lp_lang_view=en" target="_blank">http://cedric.bosdonnat.free.fr/wordpress/?page_id=11&amp;lp_lang_view=en</a></p>
<p>You may probably use one of his plugin update sites, again:</p>
<ul>
<li><a href="http://cedric.bosdonnat.free.fr/ooeclipseintegration">http://cedric.bosdonnat.free.fr/ooeclipseintegration</a> (stable, but maybe old)</li>
<li><a href="http://cedric.bosdonnat.free.fr/ooeclipseintegration-dev">http://cedric.bosdonnat.free.fr/ooeclipseintegration-dev</a> (dev version)</li>
</ul>
<hr />If you want to compile the plugin on your own, here are are the necessary steps:</p>
<h3>How to build from source</h3>
<ul>
<li>Check-out the source from the repository:
<ul>
<li>git clone git://anongit.freedesktop.org/git/ooo-build/contrib/ooeclipse ooeclipse</li>
</ul>
</li>
<li>Change to the new directory:
<ul>
<li>cd ooeclipse</li>
</ul>
</li>
<li>Build the plugin:
<ul>
<li>ant -Dopenoffice.home=/usr/lib/openoffice -Declipse.home=/opt/eclipse -f build/build.xml</li>
<li>(adjust the two properties according to your setup)</li>
</ul>
</li>
</ul>
<p class="buymebeer"><form action="https://www.paypal.com/cgi-bin/webscr" target="paypal" method="post"><input type="hidden" name="cmd" value="_xclick" /><input type="hidden" name="business" value="donation@flattermann.net" /><input type="hidden" name="return" value="" /><input type="hidden" name="item_name" value="Donation for OpenOffice.org Extension Development with Eclipse (ooeclipse)" /><input type="hidden" name="currency_code" value="EUR" /><input type="hidden" name="amount" value="" /><input type="image" src="http://www.flattermann.net/wp-content/plugins/buy-me-beer/icon_beer.gif" align="left" alt="Buy me a beer" title="Buy me a beer" hspace="3" /></form><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&amp;business=donation@flattermann.net&amp;currency_code=EUR&amp;amount=&amp;return=&amp;item_name=Donation+for+OpenOffice.org+Extension+Development+with+Eclipse+(ooeclipse)" target="paypal">If you like my work, buy me a beer. (Suggested: 3€ for a beer, or more for more beer ;-) )</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.flattermann.net/2009/06/openofficeorg-extension-development-with-eclipse-ooeclipse/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Read a zip file comment with Java</title>
		<link>http://www.flattermann.net/2009/01/read-a-zip-file-comment-with-java/</link>
		<comments>http://www.flattermann.net/2009/01/read-a-zip-file-comment-with-java/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 00:50:15 +0000</pubDate>
		<dc:creator>flattermann</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.flattermann.net/?p=65</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>I was not able to find a Java build-in solution to read the <strong>file </strong>comment of a ZIP.</p>
<p>Reading the comment of a <strong>ZipEntry</strong> can easily be done by invoking ZipEntry.getComment(), but you cannot read the <strong>global archive comment</strong> of the ZIP file with it.</p>
<p>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.</p>
<p><span id="more-65"></span>The ZIP file comment can be found 22 bytes after the beginning of that magic sequence&#8230;</p>
<pre class="brush: java;">
public static String extractZipComment (String filename) {
String retStr = null;
try {
File file = new File(filename);
int fileLen = (int)file.length();

FileInputStream in = new FileInputStream(file);

/* The whole ZIP comment (including the magic byte sequence)
* MUST fit in the buffer
* otherwise, the comment will not be recognized correctly
*
* You can safely increase the buffer size if you like
*/
byte[] buffer = new byte[Math.min(fileLen, 8192)];
int len;

in.skip(fileLen - buffer.length);

if ((len = in.read(buffer)) &gt; 0) {
retStr = getZipCommentFromBuffer (buffer, len);
}

in.close();
} catch (Exception e) {
e.printStackTrace();
}
return retStr;
}

private static String getZipCommentFromBuffer (byte[] buffer, int len) {
byte[] magicDirEnd = {0x50, 0x4b, 0x05, 0x06};
int buffLen = Math.min(buffer.length, len);
// Check the buffer from the end
for (int i = buffLen-magicDirEnd.length-22; i &gt;= 0; i--) {
boolean isMagicStart = true;
for (int k=0; k &lt; magicDirEnd.length; k++) {
if (buffer[i+k] != magicDirEnd[k]) {
isMagicStart = false;
break;
}
}
if (isMagicStart) {
// Magic Start found!
int commentLen = buffer[i+20] + buffer[i+21]*256;
int realLen = buffLen - i - 22;
System.out.println (&quot;ZIP comment found at buffer position &quot; + (i+22) + &quot; with len=&quot;+commentLen+&quot;, good!&quot;);
if (commentLen != realLen) {
System.out.println (&quot;WARNING! ZIP comment size mismatch: directory says len is &quot;+
commentLen+&quot;, but file ends after &quot; + realLen + &quot; bytes!&quot;);
}
String comment = new String (buffer, i+22, Math.min(commentLen, realLen));
return comment;
}
}
System.out.println (&quot;ERROR! ZIP comment NOT found!&quot;);
return null;
}
</pre>
<p class="buymebeer"><form action="https://www.paypal.com/cgi-bin/webscr" target="paypal" method="post"><input type="hidden" name="cmd" value="_xclick" /><input type="hidden" name="business" value="donation@flattermann.net" /><input type="hidden" name="return" value="" /><input type="hidden" name="item_name" value="Donation for Read a zip file comment with Java" /><input type="hidden" name="currency_code" value="EUR" /><input type="hidden" name="amount" value="" /><input type="image" src="http://www.flattermann.net/wp-content/plugins/buy-me-beer/icon_beer.gif" align="left" alt="Buy me a beer" title="Buy me a beer" hspace="3" /></form><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&amp;business=donation@flattermann.net&amp;currency_code=EUR&amp;amount=&amp;return=&amp;item_name=Donation+for+Read+a+zip+file+comment+with+Java" target="paypal">If you like my work, buy me a beer. (Suggested: 3€ for a beer, or more for more beer ;-) )</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.flattermann.net/2009/01/read-a-zip-file-comment-with-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
