Thursday 23 December 2010

Custom Timer for Android OS (with Cross Thread Messaging to Handle the UI updates )

Code below shows MyTimer class which implements the Runnable interface in order to be run as an individual thread. This class also supports MyTimerListener to inform the classes which are registered to this class, onTick event.

MyTimerClass

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class MyTimer implements Runnable {

long interval;
List<MyTimerListener> l = new ArrayList<MyTimerListener>();
@Override
public void run() {
while(true)
{
try {
Thread.sleep(interval);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Iterator<MyTimerListener> it = l.iterator();
while(it.hasNext())
{
((MyTimerListener)it.next()).onTick();
}
}

}
MyTimer(long Interval)
{
interval=Interval;
}
public void addListener(MyTimerListener mtl)
{
if(!l.contains(mtl))
l.add(mtl);
}
public void removeListener(MyTimerListener mtl)
{
if(l.contains(mtl))
l.remove(mtl);
}
public void start()
{
Thread t = new Thread(this);
t.start();
}

}



MyTimerListerner interface responsible for handling the onTick event.


public interface MyTimerListener {
void onTick();
}



Implementation of MyTimer


android.os.Handler;

public class AttachedClass implements MyTimerListener {

private MyTimer mt = new MyTimer(1);
private Handler mHandler = new Handler();// Main thread attaaches this handler itself while it creates the instance of AttachedClass instance
public void startAttachedClass()
{
mt.start();// start method creates a new thread and runs mt in it.
}
@Override
public void onTick() {
Runnable r = new Runnable() {
public void run() {
TextView1.setText("Text has setted");
}
};
mHandler.post(r);// onTick event called by new thread which has been created in mt.start(). but TextView1 belonges to the main thread. In order to make handled setText method by new thread, Handler's post method has used which requires a Runnable(method) which will be run in main thread.

}
}
}


You can leave your questions to the comment section. Than you..

Monday 20 December 2010

Android TranslateAnimation sucks!

I really searched a lot on getting animated object's current location on the screen during the translate animation but I just found an android forum complaint title on it. And an Android officer was saying that It is not available to get this info during the animation and it could be added in the newer versions of android sdk. But this sucks and an important lack if you are developing a game in 2D. Animations are important and there are just 3 event listeners in IAnimationListener which listens 3 events of the animation; Start, End, Repeat. What about the during? I want to gather the info about my object which has being effected. Therefore, there is just 1 way for me, I will develop my own animation class rather to use TranslateAnimation. I will share it from here shortly.

Wednesday 8 December 2010

Damn developer.android.com is not working

The is the second time in last 3 days I am trying to connect to the Android Developer website (developer.android.com) and it is not responding again. It is a massive shame to Google. I hated it damnn!! the the worst is because of the Android Developer website is so good, there is no alternative answers to Android problems in anonymous website in the internet.

Edit: It has been Turkish Telecom's fault some wrong google IPs are stille banned because of Youtube Ban in Turkey. Grghhhhhhh....

Monday 15 November 2010

My Windows Phone 7 Application: Ringring

My very first WP7 application, I have developed an alarm clock it is my custom design :). I also designed my custom slider control which cannot be found anywhere. This application is for understanding WP7 application development I will come with new ones in the upcoming days.

Wednesday 6 October 2010

Windows Phone 7 Speech Recognition helps to improve your American English accent

I have just downloaded and started to develop applications for WP7 for a few days. My first impression is Silverlight + XNA rocks for the game developers. It is obvious that Microsoft aims to hit mobile game and entertainment market with its new product. I am developing my very first WP7 application at the moment and I will share its screenshots in later days.

One last thing about WP7 is speech recognition which is really fun :)). You need to speak proper american english though otherwise you say 'banana' and it gets it as 'hanna' . Anyway, it is a way to test your accent for free right?
We will see the MS's achievements in next few months but I really like this product as a Silverlight and .Net Developer.

Monday 27 September 2010

I like this way too


Extended desktops, yeah!

Quick tips: What is devenv.exe?

devenv.exe is the starter program for Visual Studio family IDEs which can be used for adding rules to starting of the Visual Studio or opening a new instance of Visual Studio automatically. It can be called from the command line (cmd.exe) with the parameters which are used for handling the start up of new Visual Studio instance. You can find the devenv.exe's user manual in the link below

http://www.cmake.org/pipermail/cmake/2006-July/010015.html

Sunday 5 September 2010

How to install lovely Android SDK to your computer

- Download Eclipse Galileo for your Linux based (mine was ubuntu) OS first then download the Android SDK. Run the tools/android file in the terminal then you will be able to set your android SDK visually by its interface. But this time you need to donwload the SDK packages because they do not come inside of you installer! Therefore, you get into the SDK interface and click to the Available Packages and select default package which is not selected! You click to the install button you feel sure yourself but BAM! an error which says that there is a connection error to get definition XML of the packages. Because you are shocked you do not read the end of the message and google this problem in the internet. But then you realizes that you need to select enforce https connection from the settings menu in the SDK interface, this is an important selection! therefore google left this to the users anyway. After that you install the SDK properly and this time you need to instal ADT (Android Developer Tools) to your Eclipse IDE, Pew! first step accomplished.

You see an URL for ADT source in google's website. You need to copy and paste it to the Help/Install New Software window's location area, anyway you see the ADT and click for another installation but BAM BAM! Another error which says that because of the lack of some BLA BLA packages the installation can not be finished. Your eager face turns into sour lemon but you did not lose your hope still and google this problem. This time, you find a solution which says you need to download WST Adapter because ADT needs it but it does not come with ADT and google does not say anything about it. I found the solution in a german forum and althogh i cannot speak any german but this problem helped me to improve my german skills. anyway now you have another link for WST Adapter and you can see the sunshine again you add this URL to your Help/Install New Software window's location area again and you hit to the Install button with all your power but BAM BAM BAM! Eclipse cannot find this repository because it is obsolete now. You feel that your eyes get wet but you don't lose your courage still. You google for an alternative solution and you see that google has already have a solution for this problem with another URL. Aww, was it that easy? anyway You get your smiley face because this time you are sure because this is official this solution is provided by google but BAM BAM BAM BAM! This link is obsolete as well. IRgggghhh!.... Anyway you are still alive, you think another solution immediately because of the adrenalin in your veins and that is to download Eclipse Helios and try ALL THESE URLs Helios equivalent but BAM BAM BAM BAM BAM! Helios throw exception error during the code writing. OH DEAR GOD! Now you are crying and cursing Ubuntu, Eclipse and google but you are still want to get in to the smart phone applications and you can not afford to the 1 year iOS developer licence ($100), brand new Mac ($1500) and an iPhone ($800). But you have still a pc right? and Linux is rubbish right? shall we try our chance in W7 this time yes? why not?

Then you format your OPEN SOURCE linux for any case ( HA HA HA :D ) and starts every thing from the begining. This time you download Java SDK first, then Eclipse then Android SDK. You need to download SDK tools bam bam bam bam bam..! again toold downloading error but this time small 'bam's because you know that you need to choose enforce https and set settings in right way and start again. Interface starts donwloading the tools but you know there are something coming, what was it, wait a sec and oh yes BAM BAM BAM BAM BAM BAM BAM BAM! Interface says that a folder is being used by another process it can be your anti virus program please turn it off. Huh? turning off the Windows Security Essentials. Aww man, of course you have to turn it off what you were thinking you are installing a huge, highly unstable and OS modifier SDK therefore my WSE may define it as an attact to W7 and may block it. Anyway, it is allright you gonna do it but where was the turn off switch of the WSE. Allright you found it in the Settings menu and turned it off alright it was your fault. Oh yes, finally you installed SDK and setted it hurray but what about ADT. Ok try the same link for it. And? BAM? BAM? BAM? no not this time. Yes I know it is very shocky but it installs into eclipse without errors. Yayyyy, everthing is prfect after a couple of hours you are ready to develop your first Android App but the time is late now and you feel sleepy so you go to the bad with a proud of installing Android SDK, ADT, Java SDK, W7, Eclipse Helios.

I dont know what shall I say about this process but Android SDK is such a pain in the ass especially if you try to use it in Ubuntu. Even in Eclipse, it is not responding sometimes beauces of the auto-intellisene keyword search process. I dont get the Java developers after my .Net and visual studio experience, Code developing in .Net is like a dream like; you cruise ship sinks near by a tropical island and fortunately you swim to an Island and every body is dead but 5 victoria secret models.

Short of long, Android is great platform, yes, but screw Linux to develop Android Apps and if you can afford, screw W7 as well and go get a Mac.

Tuesday 9 March 2010

World of Software

Ha ha you can see how it works :D

Friday 29 January 2010

Silverlight sample applications.

I have developed some silverlight applications which's links below. you can test them and also download the the source codes:

Key combination game: Aim of this game is to find out the secret direction key combinations to unlock some secret items like videos, images or sounds. In this application client side silverlight module sends key combinations to web server to check whether it is meaningful combination. This connection is provided by web services.(There is something wrong with my host's options therefore this application is not working properly. I ll get busy with it later because it is almost 4 in the morning :D)

RoboHobo: The functionality of this game is that to draw tracks with mouse pointer. There is a ball in this game which always goes after these tracks.

Group Project Interface Component: In that application you can test my bar loader component which is developped for King's College London MSc ASE program group project. Just enter an integer(negative or postive) value to text box and hit the button.