Saturday, December 28, 2013

Keep your App signing keys safe.

Today I tried to publish version 3 of Dream Noise but struck against a problem that I was not aware previously.

During the preparation of the apk for uploading to Google Play, I forgot the password for the signing. "OK, no big deal. I will just delete the old keystore and create a new one," I thought. Well, that went well until I upload the apk onto Google Play. As the version 3 of the Dream Noise was signed with a different key, Google detected that the difference and reject the submission.

I can see that this is the correct thing for Google to do. The signing of apk ensures that it can only be updated by the same people.

So the lesson learn for me is to keep a note of the password that I have used to create the keystore.

To recovery of this problem is to unpublish Dream Noise from Google Play, wait for it to be removed. Upload a new application on to it. That is the plan. Let see if it will work out like that.


This is a link on StackOverflow that addresses this problem. Take heed.

http://stackoverflow.com/questions/4843212/the-apk-must-be-signed-with-the-same-certificates-as-the-previous-version

Monday, December 16, 2013

Dream Noise is on Google Play

Dream Noise is now published on Google Play. Initially, I wanted to do the right testing phase and run the Alpha / Beta test programs through the Google eco system. After speaking to a couple of friends, it turns out that the simplicity of the app allows it to be published straight away.

If you are interested to find out what it is, just to the Google Play link, (https://play.google.com/store/apps/details?id=com.dreamnoise.application) to download and play.

I have also posted the link to Facebook, Google Plus and Twitter. I am now actually sure how to track where the most clicks are coming from. The Google Developer console does have a statistical information, but it is only for downloads. Visits does not count to the Google Play item does get counted.

So far, it has gone through one iteration. It was mostly to change the background colour from a white colour to something darker. The reasoning is when the user is trying to fall asleep, it would be rather silly to have it a bright light emitting from the phone. So I changed it to a dark blue colour.


Saturday, November 30, 2013

zipalign

Before an application is uploaded into Google, it must be aligned to the 32bit boundary. The alignment will be checked by the Google during the upload process. If it fails, a pop up message will say that the .apk is not aligned and reject the upload.

The zipalign tool is located to /tools. You can call it directly or add it to your PATH environment variable.

To execute it, use the following

zipalign -v 4 < outfile.apk>

The outfile is now ready for upload into Google.


Saturday, November 16, 2013

Simple usage of MediaPlayer on Android

In the side project, I wanted to play a sound that I have embedded as part of the resources. After a short research, Android provides MediaPlayer to help you play sounds and videos. I am only going to use it playback some sounds.

Before I started, I browse over to the MediaPlayer docs on Google. The most important is the state diagram that it is displaying. From here, it is required for states of your implementation of the player to follow.

To start with, you will need to create your instance of MediaPlayer.

try {
    mp = MediaPlayer.create(getApplicationContext(), R.raw.whitenoise_30s);
} catch (IllegalStateException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
mp.setLooping(true);
mp.start(); 

When create() is called, the MediaPlayer enters into Prepared state. This means that we can immediately call the start()  and the MediaPlayer transitioned into the Started state. The audio will start to play on  the speaker.

To stop the playing, stop() can be called. When stop() is called, the MediaPlayer transitioned into Stopped. The audio will stop to play and be silent on the speaker.

To playback, instead of calling create() again, it is better to call prepare(). From the state diagram, the MediaPlayer will transition from Stopped to Prepared. A boolean could be used to track if the MediaPlayer has been created or not. This is to indicate whether create() or prepare() should be called. 

Saturday, November 02, 2013

Setting up the menu on an Android App.



As I am developing the Android App, I need to add a simple menu for popping up a dialog box to show the version of the application. As far as I know, the only menu that can be popped up is the Menu button. On a phone, this soft button is usually located on the bottom left hand corner.

I wanted to have a single menu item in the list. It is simple "About"

Firstly, I create a menu.xml and placed it in under /res/menu.

xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
   
    <item android:id="@+id/menu_about"
          android:title="About" />

</menu>

Secondly, I added the code that adds this menu. This code resides in onCreateOptionMenu() which is in MainActivity.java.


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu items for use in the action bar
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.main_activity_actions, menu);
        getMenuInflater().inflate(R.menu.menu, menu);
        super.onCreateOptionsMenu(menu);
        return true;
    }

In the snippet of code, I have also shown the code for the action bar. However, the line of the that creates the option menu the call to getMenuInflater(). Be sure that the ID of the xml file is referenced correctly.

When the menu button is clicked, a menu will pop up with only the "About" option displaying.

Thirdly, I created code to handle the event when the "About" option is selected. This is handled in the onOptionsItemSelected() method. So I have the following implementation.

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle presses on the action bar items
        switch (item.getItemId()) {
            case R.id.action_search:
        Toast.makeText(getApplication(), "search is selected",
Toast.LENGTH_SHORT).show();
        
            openSearch();
                return true;
            case R.id.action_settings:
            
        Toast.makeText(getApplication(), "settings is selected",
Toast.LENGTH_SHORT).show();
        
                openSettings();
                return true;
                
            case R.id.menu_about:
                // Single menu item is selected do something
                // Ex: launching new activity/screen or show alert message
                //Toast.makeText(AndroidMenusActivity.this, "Bookmark is Selected", Toast.LENGTH_SHORT).show();
                
            String message = getString(R.string.app_name) + "\n" + getString(R.string.app_version);
            
    // pop up a very simple About dialog box.
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder
    .setMessage(message)
    .setPositiveButton("OK", null)
        .show();
                return true;

            default:
                return super.onOptionsItemSelected(item);
        }
    }

This implementation also includes actions for when items from the action bar is also selected.

So when the "About" is selected, a simple dialog box will pop up.

This code also abstract the strings to strings.xml so that it be changed easily. A snippet is shown below.


    <string name="app_name">BackgroundNoise</string>
    <string name="app_version">version 0.01</string>


Friday, April 19, 2013

Started a T-Shirt shop

I have always been fascinated by a business like a market stall on a weekend. Since shifting to Germany, the chance of that happening is small.

So I started to look around the internet to see what is happening. I came across the concept of drop shipping. Drop shipping is a concept where you are selling the physical product, but the inventory is held by your supplier. The supplier also ships the product directly to the customer. Do a check via Google on what drop shipping. Plenty of information will pop up. T-Shirt is a possible avenue.

The T-Shirt bug started when I came across Tee Spring after hearing it on Mixergy. The thing about Tee Spring is that it uses the crowd funding model. You design a T-Shirt by putting some text and some graphic on a T-Shirt. Next you specify how many T-Shirt is your minimum quantity, and set your selling price. You will also need to specify the number of days it is on sale for. Once all these are set, it is time to launch it onto the market. The idea is to get the minimum of number of folks to sign up. When the time has expired and if the minimum number of folks have signed up, a production run of the T-Shirt is executed and delivered out. Some folks have had great success with this platform, unfortunately, I didn't

The next platform I tried was a spreadshirt. It is a more traditional model. You basically create a shop, upload or create some T-shirts, and start the marketing campaign. You can see what my efforts are at http://smartarsecomments.spreadshirt.co.uk/.

The one thing that I did which I should have taken sometime is the name of the shop. I called it "smart arse comments". In some ways, it portrays a red neck attitude for the shop, not something that I feel happy about. It also limits to what I can sell in the shop. The name of the shop should represent the type of T-Shirt it is selling. In the long term, I definitely don't want to see T-Shirts with smart arse comments on it.

Well, I have created 8 T-Shirts on it, any haven't managed to sell any yet. Today is the 8th since I started the shop. The next thing I need to do is to create more T-Shirts, and the start the marketing campaign. I hope that the type of T-Shirts that I have for sale is of interest to the general public.





Friday, January 04, 2013

Hacker News in various flavours


Hacker News is a news aggregator for news tidbits in the tech work about the hacker community.  In this context, hacker means someone who takes something and modifies it to be used in a different manner. The modifies aspect is the hacking activities.

So without further ado, the following is how some folks from the HN community likes to show the news items. 

Websites
Browser extension
Twitter