kindle tutorial

Amazon Kindle Application Development Tutorial – Part 3

Posted on Updated on


Kindle Application Lifecycle

Hello everyone.
Hope you are fine and doing good in your daily routine.

Here is the 3rd part of my series of tutorial on Amazon Kindle Application Development.

Note : So far we have discussed following topics in this category.

In this part I will describe some core concept that one must know before starting development on kindle plateform. It includes life cycle of kindle application and some other key points we have to care during code.

Earlier i was going to start hello world tutorial but i felt these things should discuss first so that when one start writing his first program he/she should clear about whats going on at backend. So let start.

I have bring my bowl of “fruit chaat” but my music player is silent today. I’m not in mood of listen any track, but while reading these lines; don’t forget to follow the traditions. You must have something to eat and listen, having relax seat in your chair …

Orite here we go ..

Active Content

First of All we need to know what is “Active Content” are. Within the community of kindle developers you will hear this term time and again. Active contents are noting but the apps runs over kindle device. Simply the apps for kindle, here we called them “active content”. Simple it is.

Kindlet

Technically, kindlet is an interface in kdk (kindle development kit). We extends its subclass and write our code. At little abstract level, the main entrance of our kindle application is called kindlet.

For example like any java program must have a class that contains main() method; to start application from that point (.i.e.  via main() method) same in case of kindle app, there must be a class that must extend subclass of kindlet interface (AbstractKindlet class) and hence become entry point of our kindle app. Such class is normally refer as kindlet of our kindle app.

In more concise words, if someone asks you where is your kindlet, then it means he/she is asking about the entry point of your kindle application, the class which extends the subclass of kindlet interface of kdk .i.e  AbstractKindlet class.

Lifecycle of Kindle application

Like every application, active contents have also a defined life cycle. Our application move in between these life cycle phases during its execution and terminates from its exit point.  There are four phases application move among. They are

  • loaded
  • ready to run
  • running
  • shutdown

when application jumps into a phase, a specific method is called, defined in kindlet interface. These method calls and phase changes are very well defined until any unchecked exception is thrown, that causes the active content to die/shut down and user will see crash. Now as application crashed, there isn’t no surety whether the life cycle will complete normally or will terminate immediately.

The kindlet method associates with above mentioned phases are

  • create()
  • start()
  • stop()
  • destroy()

Refer the following image describing the phases and method calls during the life cycle of kindle application

{src : kdk documentation}

Lets discuss different phases of life cycle

Loaded

When we chose a kindle application to run, its kindlet initialized, along with other static initialization of application. Once this happened, its means kindlet object has been constructed and properly initialized, hence application has LOADED.

At this stage, we don’t see any screen/user interface at user end. Its all occurred at backend. At developer lever, we don’t have access to persistent storage; we haven’t access to application environment/context.

  • After loaded phase, there are two possible ways. Either application will enter in “ready to run” phase or will “shutdown”. In case of shutdown kindlet will not notified.

Ready to run

In case application are eligible for “ready to run” then a transition is occur via method called create() declaired in Kindlet interface. At this stage application gain access to kindle environment and we have a reference of KindletContext object. This object represents the Kindle application’s environment for a Kindlet and provides access to the Kindlet’s user interface, filesystem space, network connectivity and more.

Once a Kindlet create method has finished, the Kindlet is considered “ready to run”. The application’s user interface is not visible while in the “ready to run” state and no user input will be received. be patient

The next phase from “ready to run” is to “running”. During this start() method of kindlet interface will be called. Even at this point, the user interface is still not visible.

“ready to run” to “shutdown” is also possible. If this occurs, destroy will be called. During destroy, the application should release any resources it has allocated.

Running Phase

The end of start() method moves the application in running state. At this point user interface become visible and application is said to be running state. User  can start using application.

  • Note: one thing  need to know. When user plug usb cable to device,  then  the device goes to screen saver and its stop() method calls for current running application. You can’t use device when its plug with usb cable. The stop() method should pause any executing work, release any file or network resources, and prepare for the user interface to be made invisible. At this stage application move to “ready to run” state again.

Shutdown State

When use wants to quit the application, the application moves to shutdown state and stop () method is called. This pause any executing work, release any file or network resources, and prepare for the user interface to be made invisible.

That’s was a theoretical concepts for life cycle of a kindle application. Let have a quick glance over life cycle methods of kindlet.

create

is the first step in the life cycle. A reference to the application’s environment is provided to this method. This method will only be called once during the life of the Kindlet instance.

start

indicates that the application is about to become active. Upon completion of the start method, the user interface will become visible and the application will start to receive events from the user. Unlike create, start may be called many times during the overall life of the Kindlet instance. For instance, entering and exiting the screensaver results in a stop event followed by a start event. Similar cases exist for USB and other system notifications.

stop

indicates that the application should stop. The user interface will become invisible shortly after this method completes. When the user interface becomes invisible any open option panes will be closed. Stop will be called on a running application when the Kindle enters USB mode, screensaver or exits the application.

When an application is stopped, the file system may disappear. It is important for applications to close resources like files and re-open them on stop / start cycles, respectively. Additionally, any threads that are performing work should either shutdown or sleep. This includes network access, and all requests for connectivity may be cancelled on stop.

destroy

indicates that the Kindlet instance will not be used again. This permits the Kindlet to clean up resources and do any housekeeping that may be necessary on application exit.

The device may choose to shutdown an application during screen saver or USB mode to preserve battery life.

Its enough for today .. in next part, we will move to actual development, a hello world program. though i start working that part today but i felt we should discuss these things first so that while writing the code, we should know what actually going inside code and at backend of our application.

feel free to ask any thing confusing here. i will try my best to make it more simple, easy to understand as per your kind suggestions.

Be blessed. Have a nice day.

free counters

Advertisements

Amazon Kindle Application Development Tutorial – Part 2

Posted on Updated on

Setting up your system for Amazon kindle

Hi,

Hope everyone is good and enjoying life.

Today is Sunday, i just get done with weekly cleanup of my room, reset my bookshelf, brought some useless things/papers out from drawer etc. I’m lil tired too. Now get free to have some talk to you.

Note : This is the 2nd part of my series of tutorial on Amazon Kindle Application Development. So far we have discussed following topics in this category.

Today i will describe how to set development environment for Amazon Kindle application. It pretty simple. If you are already a java developer then you have done much already. In my last post i gave you an overview of kindle platform. Today you will learn how to install basic tools to start development.

Bring your coffee/tea with some snacks, play some good slow track at background  and lets start.

Follow the step given below to install required tools for kindle development. As java developer, you can skip some of them.

Download JDK
For those who are already doing java development skip this step, for those who are new to java, they must download and install java development kit (JKD). Currently version 6 is latest so you must use it. Download JDK.

Install JDK
After downloading JDK install it to your prefer location, then edit a “path” environment variable entry (right click My computer->properties->Advance tab and then click environment variable at bottom), append the [jdk-instal-dir]\bin … like in my case, I appended the entry c:\Program Files\Java\jdk1.5.0_06\bin in path variable after placing semi-colon in the previous entry.

Download eclipse
Next, we will use eclipse IDE for our development and debugging. As eclipse is free with many useful Plug-in available. Download eclipse.
After download, run eclipse. It will ask you the location of workspace. A workspace is a location where all your projects will be saved by default. You can choose the custom location for your projects too. When eclipse will start, you will see welcome page of your workspace.

Configure jdk with eclipse
its time to link your jdk with eclipse so that while compiling and building your projects

  • Click Window > Preferences from the main menu in Eclipse
  • Click Java > Installed JREs
  • Click Add.
  • Fill the fields:
    • JRE type = Standard VM
    • JRE name = jdk1.6 [or any other name of your choice]
    • JRE home = path to the JDK (eg. C:\jdk1.6.0_06)
    • Default VM Arguments leave blank

At this point you are ready to start your java development.

Download Kindle Development Kit
Amazon made its Kindle Development Kit (KDK) available for download to software developers. But before download you’ve got to register and be approved by Amazon to download the Kit. You can apply here. The KDK is currently in a limited Beta phase.
After getting approval you will be sent a link to download kdk. Its ~13MB zip archive file name KDKv1.

Kdk comes with kindle application libraries, sample applications and kindle simulator. You can test your application over simulator before submitting to your client or kindle store.

Thats all for today. At this moment you are ready to start application development for kindle platform. In next tutorial you will learn basic constitue of kindle application, how to make hello world project and running your project on simulator.

In case of any query, confusion or you feel i missed something important, feel free to comment.

Have a blessed day.

error in displaying visitors. please retry.

Amazon Kindle Application Development Tutorial – Part 1

Posted on Updated on

Hello All.

hope everything is good.

Amazon Kindle i used in my development.

From last few weeks i’m working on an application development of Amazon Kindle, an ebook reading device by Amazon. In my last post i introduce to you kindle device. Now its sdk is also available for custom applications. I’m probably the first in my region who is working on kindle. So as per my bad habit, i’m going to share what i have learned so far. So from today i’ll post 2, 3 tutorials covering basic concepts regarding application development on kindle platform.

Note : This tutorial is a part of my series of tutorial on Amazon Kindle Application Development. So far we have discussed following topics in this category.

As its mid night, i will try to be concise and will focus mainly on key points. But i assure you as developer you will quickly get what you EXACTLY need to know… more details i will post in next tutorial. So as a tradition of my blog, have a cup of tea/coffee, sit relax in chair and for few min just forget everything around you. Read the rest of the post and get what you actually want to learn; in a simple  and quick way.

i’m going to explain some very basic concepts first. then in later post will move to actual development process.

Orite lets go .. few general things need to know in start

  • Kindle was basically an ebook reading device by Amazon. You can download books from Amazon, subscribes to blogs and can read contents on your kindle device.
  • Kindle as application is also available for iPhone. You can install that app from AppStore and can use same features provided by standard kindle device.
  • Then Amazon launched beta sdk for kindle platform; let the developer community to develop application for kindle device. Many application has been developed including games, productive apps etc. The kindle kdk team is continuously intouch with all developers and taking their platform to much more mature state by having feedback/suggestions.
  • In this series of tutorial, we will learn how to develop application for kindle platform using kindle skd. We will test them over its simulator and then run over device.

Orite now something related development perspective.

  • First of all, congratulations, kindle development is java based so thumbs up , take a relax breath and have little smile .. yesss that’s the way  🙂 …  (don’t forget to take sip of tea/coffee)
  • As there is java development, me like many other developer community suggests you should use eclipse IDE for your development. Eclipse no doubt the best tool currently available. Here I’m not going to tell which features it provides else I need few years to tell everything in details. As we have already used eclipse for our Android and blackberry application development, so again I will prefer to use eclipse.
  • The kindle sdk provides a simulator for testing your application. Though you can fully test your creativity over there but as a matter of fact you MUST need to run it over kindle device before submitting to your client or to launch publically. I used kindle that was cost nearly $150 (though it wasn’t mine at all)  so if you wish you can have your own kindle else test it over simulator 🙂

Thats all from today’s lecture. In the next part I will describe how to set development environment on your system to start applications for kindle.

have good time.
free counters