Sunday, October 2, 2011

First App on Android Market

        After a year of my technical rantings in Mobile Application Development mainly focused on Android, I have my first application published on the Android market.

        My first application came as a service to my community and dedicated to them, the app is named Salaat(Namaz) Reminder. The main motive behind conception of the app was that everyone of the  community should offer their Salaat(prayers) in congregation in the Masjid.

        Salaat Reminder is a simple application which involves multiple alarm functionality.There are applications available on the market that automatically raise an alarm at the desired Salaat(Namaz) time depending on the locality, but that time does not match with time in the local Mosque hence to remind an individual about the Salaat time at their local Mosque I have come up with this application.

https://market.android.com/details?id=com.salaat_reminder&feature=search_result



Thursday, September 29, 2011

Android NDK

After a lot of googling, and going through some tutorials i could finally setup theAndroid NDK(Native Development Kit) on my machine and successfully compiled a C code, generated the library and ran the code on emulator.

I would like to post some issues that i had to go through while setting up the environment for compiling C code on Windows. Despite of the step-by-step procedure given here
http://mindtherobot.com/blog/452/android-beginners-ndk-setup-step-by-step/    and
http://www.pocketmagic.net/?p=1332
the cygwin setup was quite confusing for me.

Cygwin is a utility that provides Linux environment on windows, which is required to compile the C code into a library that is used by Android through jni(java native interface). To setup Cygwin go to the link and download setup.exe. Run the exe and check  to install from internet, after that set the directory where setup will be installed as C:\cygwin(recommended), store the installation files at some safe place for further use D:\cygwinInstallationFiles. A list of Packages will appear in that choose Devel package and in that select make:The GNU version of 'make' utility'.

After completing the installation, go to the directory where cygwin is istalled(C:\cygwin) open the Cygwin.bat using a text editor and paste the following code there

@echo off

set IS_UNIX=
set DEV_ROOT=D:/Work/AndroidNDK/NDK_Demo
set JAVA_HOME=C:/Program Files/Java/jdk1.6.0_01
set CLASSPATH=D:/Work/AndroidNDK/NDK_Demo/obj
set PATH=D:/android-sdk-windows/SDK/tools;D:/android-ndk-r5/android-ndk-r6b-windows/android-ndk-r6b
set ANDROID_NDK_ROOT=/cygdrive/D/android-ndk-r5/android-ndk-r6b-windows/android-ndk-r6b
set NDK_PROJECT_PATH=/cygdrive/D/Work/AndroidNDK/NDK_Demo

C:
chdir C:\cygwin\bin
bash --login -i

DEV_ROOT represents your current project's working directory(in my case it is NDK_Demo)
The project must be organized as follows:
A) The JNI part (the .c and .h and Android.mk files) in:
D:/Work/AndroidNDK/NDK_Demo /jni
B) The JAVA part (assets,bin,gen,jni,libs,obj,res,src with the .java files) in:
D:/Work/AndroidNDK/NDK_Demo
For these paths always use forward slashes.

Save the file.

Now we come to making the Android.mk file, create a file Android.mk in the jni folder and paste the following code

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

# Here we give our module name and source file(s)
LOCAL_MODULE := demo
LOCAL_SRC_FILES := demo.c

include $(BUILD_SHARED_LIBRARY)

Finally Run the cygwin.bat file by double clicking it. and navigate to your project folder as shown in fig



Type ./ndk-build to compile the JNI project.
The C files have been successfully built. Now using Eclipse, you can build the Java android project, and it will include the JNI part automatically. Easy.

Hope to come back soon with some development about MAC(iPhone).




Saturday, September 17, 2011

My new machine!!!!!!!!


Finally after a long wait I have my new machine on my desk.
For long I had to face the dilemma of choosing the processor between Intel and amd, and in the end amd won the battle.
Amd packs in all the important features that Intel does that too at a considerably lower price. Thus in the price to performance ratio amd wins.
But it is said that amd processors heat up quickly and so need good cooling, as of now I cannot comment on this, although one thing I can say is I am very happy with the performance till now.

Configuration I came up with………

AMD Phenom II X4 965 Black edition 3.4 Ghz
Asus motherboard M5A88 M EVO
LG 22” LED monitor E2260V
WD 500 GB
Transcend 4Gb DDR3 1333MHZ RAM
280W PSU
LG DVD Writer

I have installed virtual MAC Snow Leopard on it and soon will be starting iPhone development on it and I hope that everything just works fine.

Wednesday, July 27, 2011

Video Streaming On Android

Despite being so simple and easy to develop applications on Android, it's still a tough job to stream a YouTube video. On a requirement of video streaming, I began my search, googled through various sites and blogs but was unsuccessful, and while m writing, i still i don't know the solution. Although I found some solutions.

The first solution that I found for video was, to play the video through the built-in YouTube app or through browser. But this wasn't the desired, as by using this method the control would go to the external app or the browser.
The code for using this approach is here..........

Intent myIntent = new Intent(Intent.ACTION_VIEW);
myIntent.setData(Uri.parse("http://www.youtube.com/watch?v=cxLG2wtE7TM"));
startActivityForResult(myIntent,0);

The other solution was to get the video manually from YouTube and then place it on a Web Server(like Tomcat). This way we could play the video in VideoView by setting the url in one of videoview's method as given here...........

videoView.setMediaController(new MediaController(this));
videoView.setVideoURI(Uri.parse(URL_VIDEO));
videoView.requestFocus();
videoView.start();

This way the video plays like charm, but then i don't know if it's the correct approach or what................

The third option I thought of was, instead of streaming the video every time through HTTP(which indirectly downloads the video and then plays it) I could download the video once and store it on SDcard, later whenever required I could play it through my application. This would save up the cost of network usage and also speed up the video playing except for the time spent at first download. Also it must be noted that if the video being played does not change frequently only then it should be downloaded else not.

This is all I have to say about video streaming in android................
Keeping my search on for Streaming YouTube videos .................

Monday, July 18, 2011

AsynTask, VideoDownload and ProgressBar in Android

In this post I will be dealing about how to download a video in android.........

Downloading a video and simultaneously showing a progressbar in android is elegantly handled by AsyncTask class in Android. AsyncTask enables proper and easy use of the UI thread. This class allows to perform background operations and publish results on the UI thread without having to manipulate threads and/or handlers.

The code for video download is as follows.........as can be noted the Downloader class extends AsyncTask.
The Downloader Class has to be nested in your Activity.



public class DownloaderClass extends AsyncTask {

private boolean stop = false;
private FileOutputStream fileOutputStream;
private InputStream inputStream;
// this is the total size of the file
private int totalSize = 0;
// variable to store total downloaded bytes
private int downloadedSize = 0;

private HttpURLConnection urlConnection;
private File videoFile;

@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
showDialog(0);
}

@Override
protected String doInBackground(String... params) {
// TODO Auto-generated method stub
// method

// String
// path=Environment.getExternalStorageDirectory().getAbsolutePath()+PATH+fileName;
try {
// set the download URL, a url that points to a file on the
// internet
// this is the file to be downloaded
System.out.println("doInBackground");

URL url = new URL(params[0]);

// create the new connection
urlConnection = (HttpURLConnection) url.openConnection();

// set up some things on the connection
urlConnection.setRequestMethod("GET");
urlConnection.setDoOutput(true);

// and connect!
urlConnection.connect();

// set the path where we want to save the file
// in this case, going to save it on the root directory of the
// sd card.
// File SDCardRoot = Environment.getExternalStorageDirectory();
String videoPath = SDCARD_ROOT + params[1];
// create a new file, specifying the path, and the filename
// which we want to save the file as.

boolean exists = (new File(videoPath)).exists();
if (!exists) {
new File(videoPath).mkdirs();
}
videoFile = new File(videoPath, VIDEO_NAME);

// this will be used to write the downloaded data into the file
// we
// created
fileOutputStream = new FileOutputStream(videoFile);

// this will be used in reading the data from the internet
inputStream = urlConnection.getInputStream();

// this is the total size of the file
totalSize = urlConnection.getContentLength();

// create a buffer...
byte[] buffer = new byte[1024];
int bufferLength = 0; // used to store a temporary size of the
// buffer

// now, read through the input buffer and write the contents to
// the
// file
while ((bufferLength = inputStream.read(buffer)) > 0 && !stop) {
// add the data in the buffer to the file in the file output
// stream (the file on the sd card
fileOutputStream.write(buffer, 0, bufferLength);
// add up the size so we know how much is downloaded
downloadedSize += bufferLength;
publishProgress((downloadedSize * 100) / totalSize);
// this is where you would do something to report the
// prgress,
// like this maybe
// System.out.println(downloadedSize + "/" + totalSize);

}
// close the output stream when done
fileOutputStream.close();

System.out.println("Downloading finished");

playVideo();
// catch some possible errors...
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}

@Override
protected void onProgressUpdate(Integer... values) {
// TODO Auto-generated method stub
Log.d("% Downloaded : ", "" + values[0]);
progressDialog.setProgress(values[0]);
}

@Override
protected void onCancelled() {
// TODO Auto-generated method stub

// finish();
System.out.println("onCancelled()");
stop = true;

urlConnection.disconnect();
if (fileOutputStream != null) {
try {
fileOutputStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

videoFile.delete();

}

@Override
protected void onPostExecute(String result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
}}
In your activity call this Downloader class by calling execute() method and pass the videoUrl(from the video is be downloaded) and videoPath(where it is to be stored on SDCard)
as here........
downloaderClassObj.execute(VIDEO_URL, VIDEO_PATH);

That's it your video will start downloading and get stored on the specified location.............so simple isn't it :).

Now lets deal with the progressbar, for this you need to override onCreateDialog() method in your activity..........


@Override
protected Dialog onCreateDialog(int id) {
// TODO Auto-generated method stub

progressDialog = new ProgressDialog(this);
progressDialog.setCancelable(true);
progressDialog.setMessage("Downloading...");
// set the progress to be horizontal
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
// reset the bar to the default value of 0
progressDialog.setProgress(0);
progressDialog.setMax(100);
progressDialog.show();
progressDialog.setOnCancelListener(new OnCancelListener() {

public void onCancel(DialogInterface dialog) {
// TODO Auto-generated method stub
downloaderClassObj.cancel(true);
}
});

return progressDialog;
}
From your onPreExecute() method in Downloader class call showDialog() to initiate the progressbar.........the onPreExecute() method gets automatically called as soon as execute() method is called..............

And in the onProgressUpdate() you get the percentage download done...........

onProgressUpdate() gets called, with the function call publishProgress() in the loop while downloading the video............

That's it, your Video Downloading with a progress Bar is accomplished...........

Tuesday, July 12, 2011

What a pitiful situation.......

I am writing this post, just keeping in mind the situation of traffic and pollution in Pune, which I think is really pitiful. Commuting from home to workplace(which is 11km) is now becoming like everyday going on a war. There is terrible traffic on the roads and to add it all people are driving haphazardly.

But what i really feel compassionate about is that people don't have enough public transport facilities. One day while travelling to work place I saw a PMPML bus(the public transport here) in which a school boy was hanging with one hand on the last step of the bus and that too only on a single foot, even a slightest jerk could easily make his hand slip and get him caught under the wheels of the bus.

On the other hand a few men and women(mostly women) are consuming almost 10% of the city's fuel, which I think is quite a lot. More and more women in the city are carelessly opting for cars, and that too less fuel efficient cars as they don't want to compromise with the elegance(of their cars). Without proficient driving they are licensed to use four wheeler, which is constantly adding to the menace. Also no one is aware of the concept of car pooling here or may be they just don't care.

Petrol and diesel prices are sky rocketing but this hardly affects the high income group, they continue to use their luxury cars, leaving the common man to face the brunt of inflation.

It's high time now, and this should be taken seriously...........

Wednesday, June 15, 2011

Synchronous & Asynchronous Methods

It is so important to know whether a method call is synchronous or asynchronous.

Firstly i'll explain the difference between the two;

Synchronous methods, complete its execution and then returns the control back to where it was called from and the process further continues.

Whereas asynchronous methods when called they get started in their own separate thread, and run independently without affecting the main process thread.

Most of the methods are synchronous as they are easy to handle and operate with, but a few methods like webcomponents are asynchronous. For eg. downloading something while application is running is asynchronous method, also logically it should be so, since the data to be downloaded can be large or depending on network may take longer time, hence the main thread cannot stop for so long.

Monday, May 23, 2011

FrameWork Importance

While working with big frameworks the likes of Struts, Hibernate etc. you don't apprehend the importance of frameworks, nor do you completely understand the working of framework.

Being into mobile application development, only native sdk's provide the frameworks for developing appns, but what about the open source cross-platform compilers, i.e. the tool generating builds for all phone platforms using the same code.

Exploring such open source tools will make you think and rethink about how to develop a framework that will optimize mobile development.

Mosync is a tool that does the cross-compilation for you, but lacks a good framework to work upon with, thus to enable smooth operations while development it is was very important(while working) to develop a framework.

Fortunately one of my colleagues wrote a framework for Mosync, and now work flows like fluid, it has allowed us to work seamlessly on mobile apps, switching between different screens has become very comfortable and easy.

Had the framework not been developed, it would have been very difficult to work with.
Also it has made me realize how important it is to have a framework for development. Now all the apps that we develop are well synchronized and easily maintainable.
Most importantly any new functionality can be easily integrated within the application.

Mosync is truly a herculean tool, only skills to harness its power are required.
Will write about the experience with Mosync 2.5 alpha.

Till then keep surfing....................

Wednesday, April 13, 2011

Desktop R&R

Hi,
Thought of buying a new machine suddenly, as my old one is really old now. A pentium-4 processor 2.4Ghz, with just 1Gb of ram and 40Gb hdd, not really enough. So i began doing Research & Research for the same.

Suggestions from my team mates flowed in and was convinced to assemble a machine instead of going for a branded one.

After a lot of googling and reading from different forums i concluded upon a configuration which is more than enough for my needs:-

-> Intel i5-2500k processor(6M cache 3.3Ghz) an ultimate 2nd generation processor that beats i7-875k in price as well as performance

-> Intel DP55WB motherboard as a standard for i5 and i7 processors.

-> Samsung B2030 LCD monitor 20"

-> Seagate 1Tb HDD

-> Transcend DDR3 4Gb RAM 1300Mhz

-> LG 22x IDE super multi DVD Writer

Whole assembly is expected to come around in Rs 30k. Awaiting desperately to get my new beast as soon as possible.

Till then hope for the best.............

Friday, April 8, 2011

BlackBerry Workshop

Happened to be at the BB workshop held in pune on the 6th april '11 at the Hotel Deccan Rendezvous. Was a nice event, which explored about the company facts and their latest product the BB Playbook which is scheduled to be launched in early May in US and by June in India.

The workshop started with a small introduction about the company delivered by
Mr Pradeep Rao from Research in Motion.
Second spokesperson was Mr Alan Wong who had specially come down from HongKong
to give a handsOn experience of the BB Playbook.

The BB Playbook tablet is a powerful machine with its OS built over the QNX technology,
the OS promises powerful multitasking capabilities and is powered by 1Ghz dual core
processer(make not disclosed) with 1Gb ram.
It has got Flash 10.1 support and a HD display with HDMI port. Rear camera is 5mp while
3mp at the front, and records video at 720p which is lower than that of
Galaxy tab 2(1080p HD recording).

To develop apps on the Playbook and other BB devices there are several options as follows:-

1) Adobe AIR
2) BB Webworks
3) Native SDK
4) Browser development -> HTML5, Flash 10.1 and CSS3.

1) Adobe AIR
-> Uses
Flex(SDK) based on the Adobe Flash platform.
-> MXML is used for designing the UI/Front end.
-> Interactivity is achieved through the use of ActionScript.
-> FlashBuilder is the IDE required for developing using Flex and also BB Tablet OS SDK is required to build apps for BB.
-> Apps developed using Flex can be ported to BB, android and iPhone devices.

2) BB webworks
-> It is supported on BB v5.0 onwards.
-> Involves development using HTML5, CSS and JavaScript.
-> Simply we need to design UI in HTML5 and use javascript for interactivities, ZIP all the files and with the issue of a command(bbwp .zip) u get the .bar file generated to be deployed on the BB device.

More information can be found on the following website http://us.blackberry.com/developers/tablet

Will soon try the development and would be in a position to more clearly explain the steps.........
Till then keep surfing........GoodNight.


Tuesday, March 29, 2011

Hiding

Learnt a few hiding techniques, that is hiding data on windows or encrypting:-

1) Folder with no name=>
Press rename on a folder -> hold Alt and type 0160 -> thats it your folder will have no name.

2) Unable to start a command prompt ? No problem. Look at the following =>
Create a text file -> type: command.com and save as cmd.bat -> then run ->it should open up the command prompt.

3) Hiding files to an image to encrypt it =>
Place the image and the required files(that are to be added to the image) into particular folder -> using winrar compress the files to someName.rar (eg.Fonts.rar) -> now open the command prompt and navigate to the folder ->
type: copy /b imagename.jpg +somename.rar imagename.jpg -> press enter and its done.
To view the files encrypted in image open the image with winrar.


MoSync

The Mobile Application Development is fast gaining popularity and developers are required to code applications that can be used on most of the mobile platforms as possible.

With the need in mind, the search for an IDE began and was finally found in the form of MoSync(http://www.mosync.com/) IDE which is a cross platform tool generating the required packages for the particular devices.

MoSync is an IDE based on Eclipse that allows to code in c/cpp and builds packages for the specified device depending on its platform.

Will soon come up with something new to post ...........

Till then keep surfing............

Monday, March 21, 2011

Android

With the buzz everywhere about android, I started mobile application development in android (Nov'10). Being very new to IT industry I had very little idea about how to start about. But then after googling around found out the http://developer.android.com/index.html site which gives complete details about the whereabouts of android. It is the official android site completely dedicated to android development and news.

Beginning development in android was quite easy as it requires knowledge of core java only. And within a month I had my first POC(Proof of Concept) application ready on android. Though a very basic one :).

After that came a little tougher POC's which took me a lot of googling, but at the end the battle was won and i accomplished my tasks in time. cheers..:)

As and when i come across something new in android that i feel is important will be definitely updated by me..........

Till then keep surfing............

First Blog

After being encouraged by my colleague to have a blog, today I have created one, with the motive to post all the things that I consider important to be shared..............

I hope that I would be able to maintain a healthy blog by frequently updating it with new posts ..........

Till then keep surfing...........