Friday, December 21, 2012

Be On Time – How’s To’s

Be On Time is a alarm that contain a different set of features then most regular alarm apps and in fact it’s a clock web radio. The minimum Android version accepted is ICS 4.0 and it’s made to be used with the latest 4.2. I also tested it in my Nexus 7 and it should work well on all tablets that have Wi-Fi and microphone than run from ICS 4.0 above.

This is the first screen that you will see, on the top left corner you can see the radio icon and a toggle button for on and off the radio. If you don’t have any radio the toggle button will be disabled. Touch on the radio icon and you will get to the radio selector spinner.

After you select you radio, touch the Select button that is at the right side of the spinner selector with this the popup will close and return to clock, after that if you wish turn on the radio it’s just hit the toggle button (Off/On), that the app will load the buffer and start play it as soon the buffer is full.
Touching on the clock numbers will bring a different pop up, this one is for you select the transparency background color, the font type and color also.

To select it you need touch the Select button.
For you go to create/update or delete alarms, just touch the clock icon, the if you have any alarm on you will have the icon in blue.

Once you hit the clock icon this next screen will load up, the main screen.

To create a new alarm just touch on the plus blue icon on the top left corner from the screen.

To set the hour and minutes, just touch over the time displayed under the alarm name entry, you can slide up and down or tap and entry the desired time in each field..

Here you can create the alarm with all settings that you want. The rules for create an alarm are quite few though there is a few:
You can’t set an alarm with less than 2 minutes from the actual time and to the same day using date, if you try it the app can if you are using week days, set the alarm to the exactly same time though to the next selected day, if using by date the alarm will not be created and for last if you don’t set a date or week days then the alarm will be setted to the next day at the same hour.

Screen for select week days (above), the rule to roll each column up or down and tapping to entry the value desired is also valid for Date,

Screen for select date (above),

Volume options (above),

Snooze options (above), the snooze interval numbers means minutes.

Select sound screens (above), the selected sound option will be in blue

Add Net Radio option (from main screen menu), if you had copied or know one URL that you want, it’s just type, or copy it into the second entry field and Save it. Clear will just clear both entry fields. 

The web part for you import all links that you want, please be aware that many links are broken or missing, also you can hit menu and insert an URL desired, if the URL doesn’t contain HTTPS you can only type part of it e.g. : from  just type that the browser will load it for you if the url is correct. To quit the browser you just need to hit back a few times or open the menu and touch on Exit browser.
Once you had touched a net radio link, and if it’s compatible (Windows Media format is not) the app will import it to you and you will get a message telling you that (below).

The settings screens is pretty simple, the last item is the one that will make the alarm keep playing for the desired time selected.

Widget, will always tell you the next alarm, the blue plus button takes you straight to create a new alarm and the second to the main screen where you can edit, create or delete any alarm that you already have.

To stop the alarm you must tap twice in less than 1 second.

When importing radios be aware that not all links would be working, and also that not always that not working link will not be working, it's a matter of try it sometimes.

So that’s all, if you have any doubt that it’s not in this post, please feel free to send me an email to that I’ll reply as soon as I can, and please rate the app if you like.

Saturday, November 17, 2012

Example for Encrypt and Decrypt using AES with Android 4.2

I'll put in here the test that I did:
As after test the code on my Nexus it's worked encrypting and decrypting (before just encrypt was working), I got a String from an other phone, from SQLite, copied and sent it via email client (GMAIL) to my Nexus, then I have copied it and replace with the one that had been created on 4.2 (the copied one, was from 4.0.4 SII 3G), then started the app again and debugging I could see the correct string returning from this method:
public static String decrypt(String seed, String encrypted) throws Exception {
            byte[] seedByte = seed.getBytes();
            System.arraycopy(seedByte, 0, key, 0, ((seedByte.length < 16) ? seedByte.length : 16));
            String base64 = new String(Base64.decode(encrypted, 0));
            byte[] rawKey = getRawKey(seedByte);
            byte[] enc = toByte(base64);
            byte[] result = decrypt(rawKey, enc);
            return new String(result);

I've made an example to show how it's works.

Activity_main.xml (layout):
<RelativeLayout xmlns:android=""
    tools:context=".MainActivity" >

        android:text="App name" />

        android:text="This is the seed." />
        android:text="This is the text to encrypt" />

        android:text="Encrypted text" />

        android:text="Decrypted text" />

    </RelativeLayout> :
  1: package com.example.encryptdecrittest;
  3:         import;
  4:         import android.os.Bundle;
  5:         import android.util.Log;
  6:         import android.view.Menu;
  7:         import android.widget.TextView;
  9:         public class MainActivity extends Activity {
 11:     private String seedWith16Chars = "This is my seed.";
 12:     private String textToEncrypt = "Hi, this is a test to check its gone work or not.";
 14:     private TextView seed;
 15:     private TextView text;
 16:     private TextView encryptedValue;
 17:     private TextView decryptedValue;
 20:     @Override
 21:     protected void onCreate(Bundle savedInstanceState) {
 22:         super.onCreate(savedInstanceState);
 23:         setContentView(R.layout.activity_main);
 25:         seed = (TextView) findViewById(;
 26:         seed.setText(seedWith16Chars);
 28:         text = (TextView) findViewById(;
 29:         text.setText(textToEncrypt);
 31:         encryptedValue = (TextView) findViewById(;
 32:         decryptedValue = (TextView) findViewById(;
 34:         try {
 35:             // This value was got when did run it from an 2.3.3 device a Galaxy SII running Android 4.0.4
 36:             String encrypted = "MzA3RDBCMjMxMjQzNzcxREUxMUYxNjg1NzgwOTU1MjU1M0FDOUZEN0M3Q0JGQ0Q5MTI2NEIyNTE2"
 39:             // Uncomment the line bellow and comment the line above to run it on an Android 4.1.2 or older.
 40:             // String encrypted = EncodeDecodeAES.encrypt(seedWith16Chars, textToEncrypt);
 41:             Log.e("Encrypt", encrypted);
 42:             encryptedValue.setText(encrypted);
 44:             String decrypted = EncodeDecodeAES.decrypt(seedWith16Chars, encrypted);
 45:             decryptedValue.setText(decrypted);
 46:             Log.e("Decrypt", decrypted);
 47:         } catch (Exception e) {
 48:             Log.e("Exception", e.getLocalizedMessage());
 49:         }
 51:     }
 54:     @Override
 55:     public boolean onCreateOptionsMenu(Menu menu) {
 56:         // Inflate the menu; this adds items to the action bar if it is present.
 57:         getMenuInflater().inflate(, menu);
 58:         return true;
 59:     }
 61: }
 63: :
  1: package com.example.encryptdecrittest;
  3: import;
  5: import javax.crypto.Cipher;
  6: import javax.crypto.KeyGenerator;
  7: import javax.crypto.SecretKey;
  8: import javax.crypto.spec.SecretKeySpec;
 10: import android.util.Base64;
 12: public class EncodeDecodeAES {
 14:  private final static String HEX = "0123456789ABCDEF";
 15:  private final static int JELLY_BEAN_4_2 = 17;
 16:  private final static byte[] key = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
 19:  // static {
 20:  // Security.addProvider(new BouncyCastleProvider());
 21:  // }
 23:  public static String encrypt(String seed, String cleartext) throws Exception {
 24:   byte[] rawKey = getRawKey(seed.getBytes());
 25:   byte[] result = encrypt(rawKey, cleartext.getBytes());
 26:   String fromHex = toHex(result);
 27:   String base64 = new String(Base64.encodeToString(fromHex.getBytes(), 0));
 28:   return base64;
 29:  }
 32:  public static String decrypt(String seed, String encrypted) throws Exception {
 33:   byte[] seedByte = seed.getBytes();
 34:   System.arraycopy(seedByte, 0, key, 0, ((seedByte.length < 16) ? seedByte.length : 16));
 35:   String base64 = new String(Base64.decode(encrypted, 0));
 36:   byte[] rawKey = getRawKey(seedByte);
 37:   byte[] enc = toByte(base64);
 38:   byte[] result = decrypt(rawKey, enc);
 39:   return new String(result);
 40:  }
 43:  public static byte[] encryptBytes(String seed, byte[] cleartext) throws Exception {
 44:   byte[] rawKey = getRawKey(seed.getBytes());
 45:   byte[] result = encrypt(rawKey, cleartext);
 46:   return result;
 47:  }
 50:  public static byte[] decryptBytes(String seed, byte[] encrypted) throws Exception {
 51:   byte[] rawKey = getRawKey(seed.getBytes());
 52:   byte[] result = decrypt(rawKey, encrypted);
 53:   return result;
 54:  }
 57:  private static byte[] getRawKey(byte[] seed) throws Exception {
 58:   KeyGenerator kgen = KeyGenerator.getInstance("AES"); // , "SC");
 59:   SecureRandom sr = null;
 60:   if (android.os.Build.VERSION.SDK_INT >= JELLY_BEAN_4_2) {
 61:    sr = SecureRandom.getInstance("SHA1PRNG", "Crypto");
 62:   } else {
 63:    sr = SecureRandom.getInstance("SHA1PRNG");
 64:   }
 65:   sr.setSeed(seed);
 66:   try {
 67:    kgen.init(256, sr);
 68:    // kgen.init(128, sr);
 69:   } catch (Exception e) {
 70:    // Log.w(LOG, "This device doesn't suppor 256bits, trying 192bits.");
 71:    try {
 72:     kgen.init(192, sr);
 73:    } catch (Exception e1) {
 74:     // Log.w(LOG, "This device doesn't suppor 192bits, trying 128bits.");
 75:     kgen.init(128, sr);
 76:    }
 77:   }
 78:   SecretKey skey = kgen.generateKey();
 79:   byte[] raw = skey.getEncoded();
 80:   return raw;
 81:  }
 84:  private static byte[] encrypt(byte[] raw, byte[] clear) throws Exception {
 85:   SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
 86:   Cipher cipher = Cipher.getInstance("AES"); // /ECB/PKCS7Padding", "SC");
 87:   cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
 88:   byte[] encrypted = cipher.doFinal(clear);
 89:   return encrypted;
 90:  }
 93:  private static byte[] decrypt(byte[] raw, byte[] encrypted) throws Exception {
 94:   SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
 95:   Cipher cipher = Cipher.getInstance("AES"); // /ECB/PKCS7Padding", "SC");
 96:   cipher.init(Cipher.DECRYPT_MODE, skeySpec);
 97:   byte[] decrypted = cipher.doFinal(encrypted);
 98:   return decrypted;
 99:  }
102:  public static String toHex(String txt) {
103:   return toHex(txt.getBytes());
104:  }
107:  public static String fromHex(String hex) {
108:   return new String(toByte(hex));
109:  }
112:  public static byte[] toByte(String hexString) {
113:   int len = hexString.length() / 2;
114:   byte[] result = new byte[len];
115:   for (int i = 0; i < len; i++)
116:    result[i] = Integer.valueOf(hexString.substring(2 * i, 2 * i + 2), 16).byteValue();
117:   return result;
118:  }
121:  public static String toHex(byte[] buf) {
122:   if (buf == null)
123:    return "";
124:   StringBuffer result = new StringBuffer(2 * buf.length);
125:   for (int i = 0; i < buf.length; i++) {
126:    appendHex(result, buf[i]);
127:   }
128:   return result.toString();
129:  }
132:  private static void appendHex(StringBuffer sb, byte b) {
133:   sb.append(HEX.charAt((b >> 4) & 0x0f)).append(HEX.charAt(b & 0x0f));
134:  }
136: }

Then I did run it from a SII with that line that have a ciphered text commented,

        String encrypted =    "MzA3RDBCMjMxMjQzNzcxREUxMUYxNjg1NzgwOTU1MjU1M0FDOUZEN0M3Q0JGQ0Q5MTI2NEIyNTE2"

and the one that have

        String encrypted = EncodeDecodeAES.encrypt(seedWith16Chars, textToEncrypt);

Uncomented. Then the LogCat show me the encrypted value, remember that we are still running it from an Anroid 4.0.4 (SII). After that I've copied the text encrypted to be received by **encrypted** String, and unplugged the SII plugged my Nexus with 4.2 and ran the code and worked.
Maybe if you are using a seed (or password) with less than 16 digits it's gone fail. If it's the case try complete it from the text length (that is less then 16th position), with something like spaces or zeros, or even 1 and 0's - 10101..) up to the 16th position.
Also you need to pay attention if your previous code is initializing the keyGen with 128 bits and the class published above try first 256 and then if it's fail go downgrading up to 128bits, then you should comment all of them leaving only the one that has 128.
If you want to download the example project please go to 
I hope that it helps you.

Monday, March 12, 2012

Wallpaper Rotator

With this application you will be able to pick up to 30 pictures from your Gallery and make it rotate as your wallpaper, the minimum time interval it’s from 5 minutes, and the maximum of 7 days. This’s a pretty easy app. to work with and consume quite few battery also. It doesn’t let your CPU awake all the time.

On FREE version there is the maximum possibility of just 3 pictures and also just 3 time intervals (15min, 1Hr and 1 Day).

The first screen it’s the EULA, that will only be displayed once, and you will only be able to use the application if you agree with it.


Then you will be taken to a screen where it will display all your pictures (from your Gallery), all of them will have a left up corner for you hit and select it, if you hit the picture one dialog will ask you to to edit. If you choose yes will be taken to the gallery where you can rotate the picture, and perform some other things. Choosing cancel you will stay in the program.

After you select all pictures that you want, you should hit the Start button, that will take you to the Service page.


On the service page, if you have the service running, will see only the Stop Service button enabled. If not you can start hitting the checkbox “Activate Service”, once you have checked that box, all others components from the screen will be enabled, less “Stop service” button if you don’t have any service running.


After prepare the service enabling the checkbox, it’s time to select the time interval, that might be from 5 minutes up to 7 days, this will be the interval time that between one update and the next.


After that to in fact start the service, it’s just hit “Start Service”. After hit the button one notification on your notification bar will be displayed letting you know that the service it’s up and running. You can remove it opening the notification bar and clear.


Once you want to stop that service, it’s just open the application (if it’s not opened yet) select at least two images, hit start and then “Stop service” that will update your notification for the status Stopped.

The button Deselect All unmark all pictures that you had previously marked, and the Quit finish the application.

If you have started a service, you can finish the application, because the service will be running on the background.

Saturday, January 14, 2012

Ice Cream Sandwich 4.0.3 RC3–Update from RC2.11

Now it looks faster and more responsive than the last RC2.11 version, a few things got better also, one it’s that you have use the Samsung USB driver now and everything will be fine.

That means if you have RC3 flashed on your mobile, you need just the Samsung USB driver from my last post, everything works fine just with the Samsung USB driver, though has to be the one that it’s been used for the Nexus version (


Tuesday, January 10, 2012

Ice Cream Sandwich 4.0.3 RC2.11 for Samsung Galaxy S - Connecting the device on Windows 7/Vista


To get ICS for SGS main page ( )  or for the download page (

If you want instructions of how to to install can be found on this link :

If you want to root it, here are a couple of links : ,

Google USB driver link : , if you want to try a Samsung driver you can try that one from Samsung Nexus, in this

link : , for me it doesn’t have worked, though may it work for you.

After you flash it and if it can’t get connected with your PC, you can follow those steps to make it work.

1. Remove Samsung USB Driver;

2. Uninstall Kies and restart PC;

3. After restart, plug the USB cable in your PC and on your SGS;

4. Open your device manager (Control Panel –> Hardware and Sound –> Device Manager), then you will see the exclamation signal in yellow on the nod named Portable Devices, it will have the name GT-i9000;

5; Right click on it (assuming that you have already installed the USB driver), go to Update Driver, choose select the option Browse my computer for driver software  , then go to the place where you have installed the Android-SDK or the Google USB driver that should have a similar path as this one


and click ok, hold for a minute or two and Windows should install the driver, and it will recognize you SGS for the ADB, that means you can get connected on Eclipse (or similar IDE for development).

6. If you can’t get it connected as USB storage, and your handset is rooted, download the Terminal Emulator from the Android Market (it’s free) and insert those commands:

su <enter>

setprop persist.sys.usb.config mass_storage,adb <enter>

reboot <enter>

Your mobile will restart and then from notification bar you will have enabled the option to enable USB storage and will be able do copy/move/delete files/folders from your handset. If it doesn’t work, try those other commands :

su <enter>

setprop persist.sys.usb.config mtp,adb <enter>

reboot <enter>

This should make the final trick.

For my experience the ICS rocks even on a handset that has some age on the back as SGS, it’s fast, though not as with Gingerbread 2.3.5, this release candidate it’s pretty stable, after nearly 4 days (did have install it hours after they put it available to download), I still do have only one issue,  that’s I can’t access my external_sd card. This ICS doesn’t have the TouchWiz, what it’s quite good, due that I never liked of it, it’s too similar with IOS and quite few customisable. I’m enjoying it and hope that you also have joy with ICS on SGS.

For those guys that are doing the working on the ICS for SGS, my CONGRATULATIONS  for such good product (even on RC phase)  in a such short time. Well done.