Archive for the ‘IT & Development’ Category

Last night, Android SDK 1.6 was released!

As a good developer, your first official act should be to check your current applications against the new Android version.
Concerning my apps, Metricdroid is good to go for Android 1.6, but my Rundroid+ Widget unfortunately isn’t.

My first interest was the known issue in 1.5 that the AppWidgetProvider won’t call the onDelete()-Method so you had to come up with Jeff Sharkeys workaround code for the onReceive()-Method (check my Widget-Tutorial for more information). Well, as far as I can tell (tested with my widget), this bug belongs to the past.

Unfortunately, it seems that the update periode (the one you configure in your xml-metadata with android:updatePeriodMillis) is not called any more. I tested my widget with a Toast-Message that should pop up every 5000 millis and was placed in the onUpdate()-Method. Same code worked fine on 1.5.

Well, using the update mechanism with updatePeriodMillis isn’t a convenient way at all because you don’t have the chance to reconfigured it, but still: Shouldn’t this still be working?
I planned to change my code so the user can configure the update periode, but now I’m a little bit under pressure to get this up and running. The first android 1.6 phones are announced for the beginning of October.

I’ll keep you updated on my research with 1.6.

I finally made it, my first Android widget ist available on the android market.

As you might have seen already, I have the “Nike+ Coach” (available in your nikeplus acount) on my website. A little flash that connects via the nikeplus XML-Service to the public interface and downloads my public running data, such as total runs, total distance, total running time and total calories.

My Rundroid+ Widget is using the XML-Service to bring this data to your Android desktop after entering your Nike+ ID. I’m not quite sure, but I think you have to configure the public interface to be active on your nikeplus account, before you can connect to your public running data. You can try it out by using this link
http://nikerunning.nike.com/nikeplus/v1/services/widget/get_public_run_list.jsp?userID=YOURNIKEID

Rundroid+ App-Icon
Rundroid+ Widget

Display your public running data on your Android desktop.

For the direct link to the application on the market click here.
If you find any bugs or suggestions, please contact me here: android [ at ] thesmile.de

Rundroid+ Widget Desktop Screen

Even though the app was almost ready, it took some time to get the meta stuff straight.

  1. finishing up the last tests
  2. versioning
  3. signing with own keystore (the ADT-Eclipse Plug-in is really helpful with it’s export wizard)
  4. creating google developer account and pay 25 bucks for an android market account (per account, not per app)
  5. uploading your app which includes the following steps:
    1. uploading your signed file
    2. creating screenshots of your app (2 is max.)
    3. entering name & description for your app
    4. find out which category of your app is appropriate (found travel and think that’s the one)
    5. read another 2 agreements to make sure it is really ok to upload

It’s finally done and my first Android application is now available on the android market.

Metricdroid Icon

Metricdroid

Calculate US-Units to Metric-Units and back. Also includes temperature conversion and measuretables for shoes, cloths and chemise seperated for women, men and kids.

The idea for this application was already born in 2005 when I had my 7 month internship in california. At that time I developed this application for windows mobile devices and now ported it to android.

For the direct link to the application on the market click here.
If you find any bugs or suggestions, please contact me here: android [ at ] thesmile.de

Metricdroid Calc-Screen

Very nice Webmontag

August 11th, 2009 No Comments

Last night the Frankfurt Webmontag was very nice.

Since I’m a developer, I like the techi-stuff most and last night was an 80% techi Webmontag. Very interesting presentations (not only the techi ones) and a lot of new and interesting people that I met.

We had

Since I’m doing a lot of android stuff, I definitely have to check out the cross platform mobile dev and get back to you with some further information in upcoming posts.

This blog post is dedicated to Darren Cooper who always says:

“If you like Webmontag, tell others … if you don’t, tell us (so that we can make it better)”

I just want to tell everyone:

It’s awesome and if you haven’t been there yet, your have to join Webmontag Frankfurt [#wmfra] next time.

Android, AppEngine, Wave, Chrome, Goolge APIs …

The first Google Technology UserGroup in Frankfurt has been announced on www.frankfurt-gtug.org.

It’s a get together on a regular basis to discuss Google technology and share ideas and experiences amoungst the group.
All people interested in Google technology are most welcome to join us not only developers.

We look forward to meeting you.

If you want to join, please go here.
Our Twitter Tag is
#gtugfra
and get on the Mailinglist here.

I just uploaded my first Java App for free for you.

As you know, I was recently playing around with iText for some serious PDF action.
Last night I came across the problem to merge an office generated letter with my (also available as pdf file) letter paper. I usually print those so I don’t have the letter paper in my office document. This time I wanted to send out an E-Mail as PDF and that’s where the problem started:

I was looking for some software to merge my letter with my letter paper and I only found some demo stuff which always put some kind of watermark into my document.

Ok, iText, PDF-manupulation .. here we go. On my new site My Apps you can now download the PdfLetterPaper application which first of all is for free and 2nd does not put any demo watermark crap into your document.

Currently the app only supports one page or better; merging the first page of your letter with your letter paper. I’ll fix that later .. I had no need for that at the moment.

Go ahead and enjoy some unrestricted pdf merging.


Just fyi: If you are using Free PDF XP to print PDF files from your office documents, make sure that you configure it on the “medium quality” or “high quality”. The default on my computer was “ebook”. I don’t know what the hell Free PDF XP is doing here, but the created PDF will not merge with the other one. I always had a big X over the whole document and it took me some time to figure out what happend and who was the culprit.

Surprisingly I never really had to use any Input- Outputstreaming with Java since a few days ago. … Well, ok, some FileInputStreams or some InputStreams from resources; but that’s not what I mean.

Playing around with iText I had to manipulate a few PDF-Templates as explained earlier under PDF-Templates for iText and then merge them together into one PDF-file. The problem was, that iText needs to have an OutputStream to put the content to. At first I was on the wrong track trying to use PipedStreams … but those only work between different threads, not in the same so I had to throw that idea away.

I came accross the ByteArrayOutput- and ByteArrayInputStreams. You just go ahead and create a ByteArrayOutputStream and give that one to the iText PdfReader. If you need the Stream again, you can now use it, manipulate it a 2nd time and in the end pass it to the user as a File (FileOutputStream) or through the browser using the response.getOutputStream().

The code looks like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
 
PdfCopyFields copy = new PdfCopyFields(outputStream);
 
// walk through the readers and add several PDF-files to one document
for (PdfReader pdfReader : readers) {
  copy.addDocument(pdfReader);
}
copy.close();
 
// save result of this reader in memory
PdfReader read = new PdfReader(new ByteArrayInputStream(outputStream.toByteArray()));
 
// stamper to have access to AcroFields
PdfStamper stamp = new PdfStamper(read, finalOutputStream);
 
// fill pdf form fields with given stamper
fillPdfFormFields(stamp);
stamp.close();
 
outputStream.flush();
outputStream.close();
finalOutputStream.close();

I just managed to update my HelloWidget Tutorial after Andreas Kompanez review (thx 4 that).

Go to Android: HelloWidget Tutorial to get the updated turorial and sourcecode. I consider writing a small eBook. I will probably add every new step I make to Android widgets and hopefully get some kind of eBook out of it. I keep you in the loop.

I finally found a very good open source combination for creating PDF-template files and using them with iText in a java project.

Just go here and get OpenOffice. Create a new document with OpenOffice Text. Go to “View > Toolbars” and select “Formcontrols” (hope it’s right, I’m using the german version and I’m translating). Now you can add form controls to your document like a textfield i.g. Right click on that field and select “control field …”
The properties window of that control will pop up and you can set a name to identify this control. I’ll give it the name “firstTextField”.
Now click the “Export PDF-Button” at the top toolbar of OpenOffice and save the document as PDF somewhere.

Now, go to your java project, don’t forget to import your iText libs and manipulate your previously saved pdf file like this:

1
2
3
4
5
6
7
PdfReader reader = new PdfReader("formfields.pdf");
PdfStamper stamper = new PdfStamper(reader,
new FileOutputStream("formfields_itext.pdf"));
 
AcroFields form = stamper.getAcroFields();
form.setField("firstTextField", "Setting text with iText into form control.");
stamper.close();

To make sure your user is not able to change any values in that form, you have to set the property “read only” of the field control in OpenOffice to true. iText can still access this field and set the text but using a PDF-Reader, the user cannot change it. If you’re using this mechanism to create pdf-templates your might not want to have frames around your text field. You can set frames to “no frames” in the property window as well.

I also had the problem of adding a table to an existing PDF which is not possible with form fields. Although the book iText in Action covers a lot important stuff, this problem is not explained in detail. Here’s how you add a PdfPTable to your existing pdf:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
...
// use the stamper from previous code but don't close it
// parameter is the pageNo starting with 1 for the first page
PdfContentByte contentByte = stamper.getOverContent(1);
 
// add PDFTable
float[] widths = {0.23f, 0.23f, 0.23f, 0.23f};
PdfPTable table = new PdfPTable(widths);
 
// there is no default width so you have to set it
// otherwise you'll get an exception (table width can't be zero)
table.setTotalWidth(reader.getPageSize(1).getWidth() - 50f);
 
PdfPCell cell;
cell = new PdfPCell(new Paragraph("Headline Cell 1", STANDARD_FONT_BOND));
cell.setBorder(1);
table.addCell(cell);
 
... add more cells
 
// INFO: 0,0 is the bottm left corner of a pdf-page
table.writeSelectedRows(
0,  // 0 = from line 1
-1,  // -1 = to last line
20.0f,  // X-Position (from left border)
300.0f,  // Y-Position  (from bottom to top)
contentByte);
 
stamper.close();

Enjoy the open source pdf-templating.

I spent a lot of time looking for an android hello world widget how to but I couldn’t find a simple example so I had to spend some time on cutting an existing one into pieces and then start from scratch with a HelloWidget tutorial.

I hope this will help you to get started on android desktop widgets. Please give me some feedback about the tutorial and/or any errors or wrong explanations.

Download the tutorial here. Get the source code here.