Presentation about BlackBerry 10

Next week during Mobile World Congress I am going to do a presentation about BlackBerry 10 together with Jorge del Casar, BlackBerry Developer Evangelist in Spain. The event is organized by GDG Barcelona and will be held in the Facultat Informàtica Barcelona
[googlemaps https://maps.google.es/maps?ie=UTF8&cid=17558281092145204566&q=Facultat+d’Inform%C3%A0tica+de+Barcelona&gl=ES&hl=en&t=m&ll=41.389415,2.113323&spn=0.005634,0.00912&z=16&iwloc=A&output=embed&w=425&h=350]
If you’re a developer it’s a good opportunity to get to know BlackBerry 10 as we will speak about both html5 and native development.
Here is the link to the event:
https://plus.google.com/u/0/events/ckc7u8j5b138o6rfas9l8hkb0hk
More information:
https://developer.blackberry.com/

Few Android applications I've been working on…

I live in a rather small and calm city called Vilanova i la Geltrú, close to Barcelona and to other touristic places like Sitges, most of the time goes completely unnoticed. What applies to tourists also applies to some terms like technology, companies, … As an example, few months ago there wasn’t that much movement about mobile technologies but now seems that, slowly, companies and individuals are talking more and more about mobile apps, mobile web, mobile marketing, … As I already said, some times people doesn’t know what they need until you show them what are the options or opportunities of this “new” technology and then a new need is created for these people.
This is, of course, a very slow process. Last time I checked we weren’t yet at Silicon Valley. In Barcelona there are lot of companies, business, technological groups and, in general, global awareness about mobile technologies. Thanks in part because of the Mobile World Congress and the Mobile Wold Capital. I started noticing graphical designers are getting some small (or not that small) mobile projects, web development companies are starting to think how to provide mobile web solutions, and even some mobile app development companies are sprouting (some of them quite promising and some others not really).
My small contribution to start creating this conscience of mobile apps and mobile technology has been creating, in my free time, some small Android applications for my hometown. Give them a try, they’re a bit different (in UX/UI than most of the standard Android apps). Here is the list:
– RSS Reader of ‘Diari de Vilanova’ (Newspaper)
https://market.android.com/details?id=com.oocit.diaridevilanova



QR Code:
qr_diarivilanova
– Fira Novembre (November Fair of Vilanova i la Geltrú)
https://market.android.com/details?id=com.oocit.firanovembre2011



QR Code:
qr_firanovembre
– Festa Major (Local Festivities of Vilanova i la Geltrú)
https://market.android.com/details?id=com.oocit.festamajor2011



QR Code:
qr_festamajor

Més aparicions a TV!

El passat dia 16 Canal Blau TV va parlar de l’aposta de Vilanova pels smartphones. Dins d’aquesta “petita” notícia va fer una refèrencia a Service2Media i a la petita aplicació que vaig desenvolupar per a llegir les notícies de l’ajuntament de Vilanova publicades al seu RSS Feed.
Aquí teniu el vídeo. Ho podeu veure a partir del minut 12:25
http://blog.rafols.org/player_flv_maxi.swf
Link al video original a TDT Garraf
Per a descarregar l’aplicatiu, només per a Android: https://market.android.com/details?id=com.oocit.ajuntamentvilanova o fent servir el següent codi:

També vaig sortir breument en el capítol 91 de La Malla tendències. Aquí us deixo el tros que parla sobre smartphones:
http://blog.rafols.org/player_flv_maxi.swf
Link al video original a TDT Garraf

Barcelona BlackBerry Developer's Group

This last weekend we got the official confirmation from Research In Motion about our proposal to create an official, RIM-Sponsored, Barcelona BlackBerry Developer’s Group. And it’s no longer a proposal, it’s a reality!! Now is time to get as much developers interested and involved in the project and try to do a first meeting as soon as possible.
Meetings will be held in Neàpolis. They are an active part of the group and will give us support with infrastructure and communication.
Location:
[googlemaps https://maps.google.com/maps?f=q&source=s_q&hl=es&geocode=&q=Ne%C3%A0polis,+Vilanova+i+la+Geltr%C3%BA,+Barcelona,+es&aq=t&sll=35.101934,-95.712891&sspn=58.25614,74.179688&ie=UTF8&hq=Ne%C3%A0polis,&hnear=Vilanova+i+la+Geltr%C3%BA,+Barcelona,+Catalu%C3%B1a,+Espa%C3%B1a&cid=13198224724882845218&ll=41.22557,1.735497&spn=0.014525,0.024848&z=15&iwloc=A&output=embed&w=580&h=450]
Our intention is to do a first inaugural meeting in mid June. Please join the facebook group or send an email to info@bbdevbcn.com if you would like to assist.
web: http://www.bbdevbcn.com
facebook: http://www.facebook.com/pages/Barcelona-BlackBerry-Developers-Group/214492638575349?ref=ts
twitter: @bbdevbcn

Fuga de cervells a la vilanovina..

Des de fa uns dies estic intentant posar Vilanova al mapa… En alguns temes la veritat és que ja hi es i a més hi destaca.. però per exemple, amb el terreny de les aplicacions mòbils hi havia com un buit… Afortunadament no estic sol i ja hi ha gent que ha fet moltíssima feina per a potenciar les noves tecnologies aquí a casa.
Un dels meus motius principals per tornar d’Holanda era de montar una oficina de desenvolupament a Barcelona, ja que per raons d’idioma necessitem gent que sàpiga parlar català i castellà per donar suport als nostres clients espanyols (ves per on en aquest país parlant anglès no vas enlloc…) i tot comentant-ho amb en Conrad Rovira (d’A16 Sistemes informàtics) em va proposar la idea de mirar de situar l’oficina aquí a Vilanova i precisament a Neàpolis. A mi em va semblar una idea força interessant ja que a Vilanova tenim una “fuga de cervells” en petita escala. És el que te viure al costat d’una gran capital com Barcelona.
Després de reunir-me amb la gent de Neàpolis i amb l’Ajuntament de Vilanova, els vaig explicar el nostre projecte i entre tots vam fer una proposta, que vaig defensar amb els meus caps holandesos, per a situar l’oficina a Neàpolis, que començaria amb poca gent i mica en mica aniria creixent. A l’equip de direcció holandès no els va semblar malament la idea i el principal problema era, llavors, trobar o bé gent vilanovina o bé gent que estigués disposada a venir a Vilanova (allò que fem molts vilanovins d’agafar el tren a les 6.49am costa molt que passi al revés).
Ara doncs que aquest detall està arreglat només ens falta l’últim pas per a posar-hi l’oficina. Espero que ho pugui confirmar molt aviat!
Mentrestant, a nivell personal, també he estat ocupat intentant despertar aquesta curiositat per les tecnologies mòbils. Si que tenim tenim tècnics perfectament vàlids, com per exemple l’associació empresarial G15, però ens cal que els altres sectors (els que generen contingut) es donguin compte de quines ventatges i quins beneficis en podrien treure de tenir la seva marca a les butxaques d’un nombre cada cop més gran d’usuaris. Sent aquests usuaris consumidors més agressius que els “simples” usuaris d’internet (I aviat inclús en major nombre).
Com a exemples i basant-me en les idees del opendata vaig fer una aplicació molt senzilla per al Diari de Vilanova sobre terminals Android. Aquí teniu la notícia al mateix Diari:
Diari Vilanova
i el link a l’Android Market: https://market.android.com/details?id=com.oocit.diaridevilanova
Des del mateix mòbil podeu anar a la icona de Market i buscar “Vilanova” per exemple.
També, seguint la mateixa línia, vaig fer un petit lector de les notícies publicades per l’Ajuntament de Vilanova:
Android:
https://market.android.com/details?id=com.oocit.ajuntamentvilanova
Windows Phone 7:
http://redirect.zune.net/External/LaunchZuneProtocol.aspx?pathuri=navigate%3FphoneAppID%3D97cc22d3-6b7b-e011-986b-78e7d1fa76f8
Com que necessita el software Zune de Microsoft, també incloc una captura:
ajvil_wp7
Aviat les dues aplicacions estaran disponibles també per a dispositius BlackBerry i iPhone!
M’agradaria donar un parell de tocs d’atenció des d’aquí.. el primer és per a l’Ajuntament.. estaria bé que obríssiu més dades estil com té la Generalitat, així molta més gent podria fer coses (tant per mòbils com per projectes web, …) i també una mica a les universitats.. Com pot ser, realment, que enginyers a punt de treure’s el títol tinguin un nivell d’anglès pèssim o literalment inexistent? Per què l’anglès no és una prioritat, per exemple, en les carreres tècniques on la major part de documentació, exemples i eines estan en anglès? M’ha costat suor i llàgrimes fer entendre als meus caps holandesos com pot ser que els enginyers de casa, en major part, no parlin anglès. Senzillament no ho entenen… i, la veritat, jo tampoc.

ADEG & Canal Blau TV

Few days ago I did a presentation about the ‘smartphone revolution’ at my hometown local companies association ADEG. The presentation went very well and there was around 25 people there. I did the presentation together with Conrad Rovira, owner of A16 Sistemes Informàtics and we both managed to show the companies there why mobile technologies are very imporant for IT and Media sectors and what are the possibilities of mobile applications.
We also introduced the creation of a smartphone development interest group in the region. Please get in touch with us to get more information.
The next day we both went to Canal Blau TV to have a quick chat (live!) about the same topic, the ‘smartphone revolution’.

Uns dies enrera vaig donar una presentació sobre la ‘revolució smartphone’ a l’associació d’empreses locals del Garraf – ADEG. La presentació va anar força bé i van anar unes 25 persones. La presentació la vaig fer conjuntament amb Conrad Rovira A16 Sistemes Informàtics i vam aconseguir mostrar a les empreses presents perquè la tecnologia mòbil és tan important per als sectors de IT i Media i quines són les possibilitats de les aplicacions mòbils.
També vam aprofitar per explicar la creació d’un grup d’interès en desenvolupament per a dispositius mòbils. Encara estem ultimant els detalls, però poseu-vos en contacte amb nosaltres per a més informació.
El dia següent vam anar al Canal Blau TV per fer una petita tertúlia (en directe!) sobre el mateix tema, la ‘revolució smartphone’.
Here is the video (low quality):
Aquí podeu veure el video en baixa qualitat:

http://labs.rafols.org/flvplayer.swf?file=CBTV_low.flv&autoStart=false

and here is in higher quality:
i aquí amb una mica més de qualitat:

http://labs.rafols.org/flvplayer.swf?file=CBTV.flv&autoStart=false

and finally here is the link to the original video on the TV channel website:
i el video original de la pàgina de TDT Garraf:
TDT Garraf
You can contact us at the following addresses:
http://www.service2media.com/contact/madrid
http://www.a16.com

Augmented Reality – II

In my last post I showed how to get position and orientation updates. In this short post (also because it’s quite simple) I’ll show how to integrate it with the camera preview.
To show the camera preview in Android it’s quite easy, just create a class that extends from SurfaceView and implements the SurfaceHolder.Callback methods:
[code lang=”java”]
package com.fuzzion.argine.viewer;
import android.content.Context;
import android.hardware.Camera;
import android.hardware.Camera.PreviewCallback;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
public class CameraView extends SurfaceView implements SurfaceHolder.Callback, PreviewCallback {
private Camera camera;
private boolean running = false;
public CameraView(Context context) {
super(context);
SurfaceHolder holder = getHolder();
holder.addCallback(this);
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
setFocusable(true);
requestFocus();
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
if(running) {
camera.stopPreview();
}
try {
camera.setPreviewDisplay(holder);
} catch(Exception e) {}
camera.startPreview();
running = true;
camera.setPreviewCallback(this);
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
camera = Camera.open();
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
try {
if(camera != null) {
camera.stopPreview();
running = false;
camera.release();
camera = null;
}
} catch(Exception e) {}
}
@Override
public void onPreviewFrame(byte[] data, Camera camera) {
}
}
[/code]
It’s really simple, just using the startPreview() / stopPreview methods. To overlay our previous view with the camera preview we have to do that in our Activity main class:
[code lang=”java”]
cv = new CameraView(this);
tv = new TestView(this);
setContentView(cv);
addContentView(tv, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
[/code]
We’re adding the camera preview and our previous viewer (removing the background, and changing the arrow color to white) so we can see both views at the same time.
I’ve also implemented the PreviewCallback class to receive callbacks with the camera raw data (byte[]). It might be useful some day..

Augmented Reality – I

Since I had my first android phone I got curiosity into augmented reality. I have to say, compared to j2me, android is a lot more powerful and you get surprised about how easy is to achieve some things than in j2me are near impossible or rather complicated. Also seems that AR is some kind of teenager fashion, now it’s really cool to do things in AR instead of just showing a map with POIs. Let’s have the POIs floating around the user, even if it’s more confusing than showing a map, but, hey! it’s cooler.
Anyway, I had to try it by myself, otherwise I couldn’t apply the cliché of having an android phone and did some AR tests. I’ll introduce the engine I developed with different articles, explaining few parts of it, and if anyone is interested I can provide access to the svn server where the code is stored (send me an email to raimon.rafols [a] gmail.com). You can use this code for any non-commercial project you want but you need the written permission of the author for commercial usage.
One of the basic parts needed for an AR engine is to know the exact location and orientation of the device. Otherwise it won’t be possible to show the correct POIs and in the correct position in the screen. Here is a code snippet of the orientation provider.
[code lang=”java”]
package com.fuzzion.argine.hal.android;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import android.app.Activity;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.util.Log;
import com.fuzzion.argine.engine.OrientationListener;
import com.fuzzion.argine.hal.OrientationProvider;
public class AndroidOrientationProvider implements OrientationProvider, SensorEventListener {
private SensorManager sManager;
private List listeners;
public AndroidOrientationProvider() {
listeners = Collections.synchronizedList(new ArrayList());
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {}
@Override
public void onSensorChanged(SensorEvent event) {
float values[] = event.values;
switch(event.sensor.getType()) {
case Sensor.TYPE_ACCELEROMETER:
break;
case Sensor.TYPE_ORIENTATION:
for(OrientationListener listener : listeners) {
listener.directionChanged(values);
}
break;
}
}
@Override
public void registerOrientationListener(OrientationListener listener) {
listeners.add(listener);
}
@Override
public void removeOrientationListener(OrientationListener listener) {
listeners.remove(listener);
}
public void start() {
Activity act = AndroidPlatform.getActivity();
sManager = (SensorManager) act.getSystemService(Context.SENSOR_SERVICE);
sManager.registerListener(this, sManager.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_FASTEST);
}
public void stop() {
if(sManager != null) {
sManager.unregisterListener(this);
}
}
}
[/code]
In the next entry I’ll explain the integration of all the parts (camera, orientation and position). Meanwhile you can check the code in svn.

Service2Media is hiring!

Service2Media is looking for experienced developers to extend our development team in Enschede
These are the positions currently available:
Senior Java Developers
– Candidates must have expertise in web server technology, in-depth Java knowledge on Linux platforms
– Speaks and writes English fluently
– Have a BSc or MSc degree in computer science or a related subject
– Experienced in J2ME, J2EE, Glassfish, JMX, SQL and XML
– Experience with Linux, Tomcat, Apache and memcached
– Experience with SVN, TRAC, Mantis and Eclipse.
– Experience with Google protocol buffers
– Have at least 3 years of relevant programming experience
– Focused on end to end experience.
Windows Mobile Developers
– Candidates must have expertise in developing native applictions on WM 6.x
– Speaks and writes English fluently.
– Have a BSc or MSc degree in computer science or a related subject.
– Experienced in Windows Mobile 6.x, SQL and XML.
– Experience with SVN, TRAC, Mantis and Eclipse.
– Experience with Google protocol buffers
– Have at least 3 years of relevant programming experience
– Focused on end to end experience.
Symbian Developers
– Candidates must have expertise in developing native Symbian applications
– Speaks and writes English fluently
– Have a BSc or MSc degree in computer science or a related subject
– Experienced in Symbian C++ development, SQL and XML
– Experience with SVN, TRAC, Mantis and Eclipse
– Experience with Google protocol buffers
– Have at least 3 years of relevant programming experience
– Focused on end to end experience.
Are you the person who combines an open mind with accurate work? Who understands that life at the cutting edge is exciting, demanding and rewarding? Then we’ll be looking forward to meeting you.
Send your résumé to raimon [at] service2media.com if you think you are up to the challenge.

Image Rotation in j2me

Lately I’ve been creating some low level image functions for Java ME just to see if low level bitmap manipulation was way too slow for doing it on real time on Java ME or it was, at least, usable. I’ll publish more functions but I’ll start with Image Rotation.
In Java ME is easy to rotate images if you want to rotate by an angle multiple of 90° but it doesn’t provide any mechanism to rotate it by an arbitrary angle (yes, ok… you could do the same using the Mobile 3D API)
I created a small function that fills that gap and allows image rotation by any angle. The resulting image will have the same size as the original (watch out for the corners..)
[code lang=”java”]
public static void rotateImage(Image src, float angle, Graphics g) {
int sw = src.getWidth();
int sh = src.getHeight();
int[] srcData = new int[sw * sh];
src.getRGB(srcData, 0, sw, 0, 0, sw, sh);
int[] dstData = new int[sw * sh];
double rads = angle * Math.PI / 180.f;
float sa = (float) Math.sin(rads);
float ca = (float) Math.cos(rads);
int isa = (int) (256 * sa);
int ica = (int) (256 * ca);
int my = – (sh >> 1);
for(int i = 0; i > 1);
for(int j = 0; j > 8;
int srcy = (-mx * isa + my * ica) >> 8;
srcx += sw >> 1;
srcy += sh >> 1;
if(srcx < 0) srcx = 0;
if(srcy sw – 1) srcx = sw – 1;
if(srcy > sh – 1) srcy = sh – 1;
dstData[j + i * sw] = srcData[srcx + srcy * sw];
mx++;
}
my++;
}
g.drawRGB(dstData, 0, sw, 0, 0, sw, sh, true);
}
[/code]
If we move all the calculations that doesn’t need to be done in the inner loop to the external loop we will have a speed improvement:
[code lang=”java”]
public static void rotateImage(Image src, float angle, Graphics g) {
int sw = src.getWidth();
int sh = src.getHeight();
int[] srcData = new int[sw * sh];
src.getRGB(srcData, 0, sw, 0, 0, sw, sh);
int[] dstData = new int[sw * sh];
double rads = angle * Math.PI / 180.f;
float sa = (float) Math.sin(rads);
float ca = (float) Math.cos(rads);
int isa = (int) (256 * sa);
int ica = (int) (256 * ca);
int my = – (sh >> 1);
for(int i = 0; i > 1) * ica + ((sw >> 1) <> 1) * isa + ((sh >> 1) << 8);
for(int j = 0; j > 8);
int srcy = (yacc >> 8);
if(srcx < 0) srcx = 0;
if(srcy sw – 1) srcx = sw – 1;
if(srcy > sh – 1) srcy = sh – 1;
dstData[wpos++] = srcData[srcx + srcy * sw];
xacc += ica;
yacc -= isa;
}
my++;
}
g.drawRGB(dstData, 0, sw, 0, 0, sw, sh, true);
}
[/code]
And if we know beforehand the size of the image we want to rotate we could do some extra tricks (for example, here assumes the source image will be 256×256 pixels and will only work with that resolution):
[code lang=”java”]
public static void rotateImage(Image src, float angle, Graphics g) {
int sw = src.getWidth();
int sh = src.getHeight();
int[] srcData = new int[sw * sh];
src.getRGB(srcData, 0, sw, 0, 0, sw, sh);
int[] dstData = new int[sw * sh];
double rads = angle * Math.PI / 180.f;
float sa = (float) Math.sin(rads);
float ca = (float) Math.cos(rads);
int isa = (int) (256 * sa);
int ica = (int) (256 * ca);
int my = – (sh >> 1);
for(int i = 0; i > 1) * ica + ((sw >> 1) <> 1) * isa + ((sh >> 1) << 8);
for(int j = 0; j > 8) & 0xff;
int srcy = yacc & 0xff00;
dstData[wpos++] = srcData[srcx + srcy];
xacc += ica;
yacc -= isa;
}
my++;
}
g.drawRGB(dstData, 0, sw, 0, 0, sw, sh, true);
}
[/code]
These functions paints the rotated image in a Graphics object directly, but doing some minor changes it could generate a new Image with the content:
* Change the function declaration to:
[code lang=”java”]
public static Image rotateImage_img(Image src, float angle) {
[/code]
* Replace the drawRGB call with:
[code lang=”java”]
return Image.createRGBImage(dstData, sw, sh, true);
[/code]
Feel free to use it for whatever you want but it would be nice if you drop me a line and put me somewhere in the credits 🙂