Wednesday, June 19, 2013

Java - Mail

How to send mail from Java sourcecode?
First you need to download the library mail.jar from oracle and add it to your Java project.
You can get it on the link below:
http://www.oracle.com/technetwork/java/index-138643.html

Than try out this code:
final String username = "username@gmail.com";
final String password = "password";

Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.port", "587");

Session session = Session.getInstance(props,
  new javax.mail.Authenticator() {
    protected PasswordAuthentication getPasswordAuthentication() {
        return new PasswordAuthentication(username, password);
    }
  });

try {

    Message message = new MimeMessage(session);
    message.setFrom(new InternetAddress("from-email@gmail.com"));
    message.setRecipients(Message.RecipientType.TO,
        InternetAddress.parse("to-email@gmail.com"));
    message.setSubject("Testing Subject");
    message.setText("Dear Mail Crawler,"
        + "\n\n No spam to my email, please!");

    Transport.send(message);

    System.out.println("Done");

} catch (MessagingException e) {
    throw new RuntimeException(e);
}


It's quite easy and it should work, unless your firewall blocks it, in that case open the port 587.
This is working for GMail accounts, but it should work with other accounts too, with just a little modification in the code.
This example code is copied from mkyong's website:
http://www.mkyong.com/java/javamail-api-sending-email-via-gmail-smtp-example/comment-page-4/#comment-135038

Thursday, June 6, 2013

Promising gadgets - Apple's Smartwatch vs. Google's Glass

Though smartwatches or smartglasses are not new, just like tablets before the iPads, they're still not a huge success. But Apple and Google are working hard to launch a new success device.

Apple, according to rumors on the internet, is working hard on a smartwatch, while Google is already demonstrating their smartglass called Glass. But which one will succeed?

Smartwatch
The advantage of a smartwatch is it's wearable as an ordinary watch. If you receive an sms or a whatsapp message,  you can simply read it from your watch. Of course, if you just want to know what time it is, use your watch. You can even check photos and other viewing stuff
The disadvantage is it has a small display, so entering a text using your fingers is not a good idea. Also it's not a good idea to take a picture with your watch.

To summarize a smartwatch we could list the advantages and disadvantages as follows:
Advantage:
  • easily wearable
  • coverable
  • readable for messages and notifications
  • viewable for photos
  • see who's calling
  • streaming video (or live video)

Disadvantage:
  • small battery size
  • small display size
  • not useful for entering text
  • not useful for taking pictures or recording videos
  • not useful for calling session, like talking to your phone and using headphones connected to the smartphone.

Seeing these advantages and disadvantages we can make following conclusions, a smartwatch should :
  • work as a client for a smartphone using bluetooth connection to communicate.
  • have low energy consumption because of small battery capacity. It would be very annoying to charge your watch everyday.
  • an api to write widgets for smartwatches.
  • have a side trackpad for vertical scrolling, because of small display size, your finger will easily cover the display and thus not user friendly.
  • copy UI from older gsm devices like the Ericsson G700. Cause these UIs were based on small display sizes.

Smartglass
The big advantage of smartglasses is you have your hands free while recording videos with an integrated camera. Because a smartglass is mounted on your head, it works also as a headset. The big disadvantage is, you have to wear a smartglass the whole day and not everybody likes to wear such a device that's not coverable.

To summarize a smartglass we could list the advantages and disadvantages as follows:
Advantage:
  • easily wearable
  • readable for messages and notifications
  • viewable for photos
  • see who's calling
  • streaming video (or live video)

Disadvantage:
  • small battery size
  • not useful for entering text
  • not coverable
Seeing these advantages and disadvantages we can make following conclusions, a smartglass should :
  • work as a client for a smartphone using bluetooth connection to communicate.
  • have low energy consumption because of small battery capacity. It would be very annoying to charge your smartglass everyday.
  • an api to write widgets for smartglasses.
  • have a side trackpad for scrolling.
  • have a suitable UI. Cause it's not a touch based device (i.e. a smartphone).

My personal opnion
I think the smartwatch will be a success for normal people, because it's like a watch, but a smart one. Like there was a normal phone before, now you have a smart one. A glass is not an electronic device, wearing glasses is only for necessity (to be able to see better). So I think for the normal people, a Google's Glass won't be a huge success. However, it could be a success in the business industry or in the world of sport and games. For example, a referee of a soccer game could see real life video of an incident before taking real decision. Or in a hospital, a nurse could see a patient's dossier, take a quick picture and send it to the doctor. There are great possibilities with a smartglass, but I doubt it will be successful for the normal people.
My conclusion is, smartwatch will be successful for normal consumers and smartglass will be successful in the business industry.

Tuesday, June 4, 2013

Soccer - Best soccer player of the world

Every year the FIFA soccer organization announce the best player of the year, the so called Ballon d'Or. It's often Messi, Christiano Ronaldo, Ronaldinho, Iniesta, Xavi and so on... If you see the big names, it's not fair to elect just the attackers. An attacker is not a defender, a defender is not a keeper, so it's not fair that Messi is the best football player of the year. I mean, Messi would not be so great without Xavi or Iniesta around him.

To make a fair election, the award should be divided into different groups. For example:
  • best keeper award
  • best defender award
  • best midfielder award
  • best attacker award
  • best free kick award
  • etc...
Maybe you can add an award for the best player award from the public audience.
However, to me, Messi is NOT the best player of the world, he's the best attacker of the year.

In my opninion Diego Maradona is the best soccer player ever!

NSNotification example