Saturday, 6 July 2013

How to add View to android service ?

Generally Android service do not have view

Android Service can be explained as -

Service is an application component that can perform long-running operations in the background and does not provide a user interface. Another application component can start a service and it will continue to run in the background even if the user switches to another application.

But If you want to add some UI to the service , then you can use WindowManage for this purpose.
Suppose you want to add Imageview to the android application, Then following code serves the purpose.

ImageView imageView = new ImageView(this);
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
  params.gravity = Gravity.LEFT | Gravity.BOTTOM;
  params.setTitle("Any Title");
  WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);

   wm.addView(imageView, params);

copy this code in the onCreate()  function of the service.
You can experiment different layout params and found out what is useful for your.

Wednesday, 3 April 2013

Official Upgrade for Samsung Galaxy pop S5570 from Android 2.2 to android 2.3

Galaxy pop is one of early Android smartphone of Samsung. Galaxy pop has android 2.2 (Froyo) as default OS. However, you can upgrade your  galaxy pop to Android 2.3 i..e very  easily.

Note : Before upgrading your smartphone, Kindly remove your sdcard ,sim card and take backup of your contacts and other important data. Make sure that your phone battery is fully charged. The process should not be interrupted in between. 

Steps to upgrade your galaxy pop from froyo to gingerbread are as follows.

Step 1: Install  samsung kies to your laptop/pc
Step 2: Connect your Galaxy pop with laptop using USB cable. Now open kies, and wait till your device is detected.

Step 3: Go to Tools menu, Click on  "Firmware Upgrade and initialisation" option.

Step 4: Now click on available update.... it would take around 15-45 minutes depending upon your machine and internet connection speed.

Step 5: Reboot your device after upgrading process is successfully completed.

Check "About phone" option in settings menu !
Congratulation ! you have Android 2.3 in your Galaxy pop.

Monday, 25 March 2013

How to use Whatsapp without changing LAST SEEN time !!

Hello Friends, Whatsapp is nowadays very popular medium for communication.
It is very handy and easy to use. It has very Great feature called Last Seen.  This feature enables user to see that when his/her friend used the Whatsapp last time.

So, Sometimes It may happen that  you wish to Use Whatsapp but you don't want that your Friend come to know about your last whatsapp access time right?
Reason Can be anything ;-)

[ For this Trick , Whole credit Goes to my friend Manas Vaishnav ]

Basic Rule is - Don't Open Whatsapp while your Data connection/Internet connection is ON.

Scenario :

In normal condition you data connection is enable.
you will receive whatsapp notifications when someone messages you.
now disable your data connection.
open whatsapp... read message... if you want to reply then type your message and press send button
Now close Whatsapp,
enable data connection !

You have read your message, replied to your friend yet your Last Seen Time will not changed !

"Relationship now a days begins with 'First seen' at Facebook & Ends after noticing 'Last seen' on Whatsapp !" - Manas Vaishnav

Thursday, 21 March 2013

Mouse Programming in C

This is simple tutorial to show you How you can  use Mouse  in your C program.
I have Attached a source file. This program is not developed by me. I found it on internet somewhere, But as this program is easy to understand I am using this program.

See Source code here.

To Enable Mouse in C program you need to generate Interrupt.
The interrupt number for Mouse input related service is 33h.

Files to include -> dos.h
Function from dos.h to be use ->int int86(int intno,union REGS *input , union Regs *output)
This Function Generates Software interrupts

union - REGS is defined in dos.h file
it is defined as

union REGS{
struct WORDREGS   x;
struct BYTEREGS     y;

WORDREGS  & BYTEREGS are defined as

struct WORDREGS{
unsigned int ax,bx,cx,dx;
unsigned int si,di,cflag,flags;

struct BYTEREGS{
unsigned int al,ah,bl,bh;
unsigned int cl,ch,dl,dh;

You don't need to remember all this stuff. This is just for understanding.
If you have studied any  Micro Controller subject then you can easily identify that these ax,bx... indicates Registers.

So, let me first tell  what we exactly gonna do.

For every type of event there are Software interrupt number are defined.
for example using keyboard, sound, mouse.
Here for mouse interrupt number is 33h.
and for all types of operation like show mouse pointer, initialize mouse, restrict mouse pointer on screen etc.. we have different Service numbers.

Generally service number will be provided in
ax register,
so here we will write something like

now all the input information will be provided in   variable of type REGS, and we will get out put in similar union varible

In our program we have declared
union i,o;
we will use
 i as input 
o as output, 

so this are some of service numbers for mouse

0~ Mouse Reset/Get Mouse Installed Flag
1~ Show Mouse Cursor
2~ Hide Mouse Cursor
3~ Get Mouse Position and Button Status
4~ Set Mouse Cursor Position
5~ Get Mouse Button Press Information
6~ Get Mouse Button Release Information
7~ Set Mouse Horizontal Min/Max Position
8~ Set Mouse Vertical Min/Max Position

This is example who you  can use this  service.

To initialize mouse;

done !!

to Restrict mouse pointer between square (10,10) to (20,20);;

very simple right?
now Go through source code and  try your self.

Tuesday, 19 March 2013

Hide files in Image

This is very popular and old trick to hide any kind of file in image ! But it is very effective :)
I have written this blog assuming that reader is novice to command prompt and all.

So Here are the steps :

Step 1. 
put all files that you want to hide in one folder.
compress that folder using winrar, winzip or 7-zip whatever you like.
If you want to hide only one file then you can directly compress it without putting it in to the folder.

Step 2.
Now make sure that your jpeg image (the one that you want to use) and compressed file (your data) are in same folder (Just to make process simpler.)

Step 3. 

open Command prompt
[click on start menu, open "Run" , type - cmd  , click ok ]

Step 4.
Open path of your image and compressed folder in command prompt.

suppose your command prompts shows
and your image and compressed files are in  E:\new folder
then   type following commands
E:         hit enter
cd new hit enter

Step 5.
this is last step
type following command
suppose your image is  -  abc.jpg
compressed file is         -  xyz.rar

copy /b  abc.jpg+xyz.rar  pqr.jpg     hit enter

Done !!  now open pqr.jpg file.... it is image which contains your data !!
you can send to the person who know  how to retrieve data from it

Steps to retrieve data from Image :

Again open Command prompt
Go to path where your encrypted image is saved.

type following command

Rename pqr.jpg   data.rar

now your image will be changed to compressed file data.rar
extract this data.rar  and you will get your data !

Monday, 18 March 2013

Facebook Chat Emoticons (Smilies) and Ascii art

Hello Friends, Facebook is now tightly bounded with our day to day life .  Facebook chat box is one of most frequently used medium of communication right? So  here,  Emoticons comes in to picture.
Emoticons (Smiles) makes conversation live and meaningful. Besides that it is fun ☺.

I am crazy after such Emoticons. I love to learn new Emoticons. So here, I will show you several  the ways to insert Emotions in the Facebook chat or comments.

Simple Emoticons :

Advance Emoticons:
type the code and hit enter. you will get image which is given below each code !!!

Ascii Symbols :

some of the Ascii Symbols are very useful.
For example :☺ ☻ ♥ ♦ ♣ ♠ ♦

To use such symbols , Press Alt key and while pressing Alt key press any number from Numpad. then release Alt key.

example :
to print ☺
hold alt key ,press 1 in num pad then release alt key. thats it..
and beauty of this Ascii symbols is that you can use this symbols anywhere in any editor. ☺. 

Reference table :
Ignore Hex code... use Decimal code. 

If you know any other way. let me know , I will add in this blog  ♥
Happy chatting ;-)

Sunday, 17 March 2013

Keeper - A two player game in C

This is tutorial for creating a Two player game in C.

The name of game is keeper. It is very simple game and very easy to implement. Even if you are novice to Graphics programming in c, you will be able to grasp everything.

Download Source code from  Here

Required Structures :
  • pad : This structure will keep track of location of pad and size of pad. 
  • ball : This structure will keep track of ball size, position and direction of ball
  • limit : This structure consist the coordinates of boundary of  game area.
  • game_data : This structure will keep track of score.

struct pad
int x,y,l;

struct game_data
int score;
struct game_data p1={0},p2={0};

struct limit
int lx1,ly1,lx2,ly2;
struct limit l={90,90,450,400};

struct ball
int x,y;
int dir;
int size;

There are several functions like game,draw, get_dir, mv_ball  etc.. all of them are self explainatory. comments are provided in the source code.

draw function will draw whole screen including boundaries, ball, pads.


while(!kbhit()){goto e;}
if(k=='w' || k=='s'||k=='e'){key1=k;}
else if(k==72||k==80||k==77||k=='o'){key2=k;}


mv_ball will provide new coordinates of ball according to it's direction

void mv_ball(void)
case 0 : ball.y-=2; break;
case 8 : ball.y+=2; break;
case 2 : ball.x+=2; break;
case 6 : ball.x-=2; break;
case 1 : ball.x+=2; ball.y-=2; break;
case 3 : ball.x-=2; ball.y+=2; break;
case 7 : ball.x+=2; ball.y+=2; break;
case 5 : ball.x-=2; ball.y-=2; break;

game function is main function for game logic. It will check that whether ball hits boundary, pad , any key is pressed or not etc...

void game(void)

      if((ball.x-105<=ball.size && abs(ball.y-pd1.y)<=32 )||(435-ball.x<=ball.size&& abs(ball.y-pd2.y)<=32))



      // ball.dir=random(7);
while(!kbhit()){ draw();}


 case 'w':   if(pd1.y-pd1.l-l.ly1>10) pd1.y-=2;  break;
 case 's':   if(l.ly2-(pd1.y+pd1.l)>10) pd1.y+=2;  break;
 default : break;
 case 72:    if(pd2.y-pd2.l-l.ly1>10) pd2.y-=2;  break;
 case 80:    if(l.ly2-(pd2.y+pd2.l)>10) pd2.y+=2;  break;
 case 'o' : gameover();
 default  : break;





When 'o' is pressed ,The game will be over and score of each player will be displayed.

If you have any query or suggestion then leave comment !

Thursday, 14 March 2013

SNAKE game using concept of Linked list - Graphics in C

This is tutorial for  creating a game using graphics in c.
If you know some concept of linked list then it will be very easy to understand. This is not standard way to create this particular. But, I have made this program to implement concept of Linked list !!
This is logical right?  when you need to increase length of snake in the game you can just add one item to the linked list !! this is it.
Download source code from here
If you you are working on windows 7.then you will need DosBox to run this program.

Structures :

struct loc
int x,y;

struct snake
struct loc sloc;
struct snake *link;
char dir;

struct game_data
int score;
int no_food;

struct game_data gd={0,0};

struct limit
int lx1,ly1,lx2,ly2;
struct limit l={96,96,404,404};

struct food
struct loc floc;

  • Structure "loc" have 2 integer variables to save x and y coordinates.
  • Structure "snake" is basically a linked list , new node of this structure will be created when snake will increase in length.
  • "game_data" will store score and number of food consumed by snake
  • "limit" defines the boundary of rectangle in which snake can move. crossing this limits will result in game over.
  • "food" contains coordinates of food to be displayed

Functions :

  • "draw" : This function will draw whole screen. which includes,
    1. Rectangular Boundary limits
    2. snake
    3. food
    draw(struct snake *head,struct food *f)
    struct snake *temp;
    while(!kbhit()){goto e;}
  • "gameover": This function will draw screen when game is over, it includes score and number of food consumed.
  • gameover(void)
    outtextxy(100,100,"----------------- GAME OVER ----------------------");
    printf("\t\t# Score      - %d",gd.score);
    printf("\n\t\t# No of food - %d", gd.no_food);
    while(!kbhit()){goto s1;}
  • "game" : This is main logic of our snake game. It does following tasks in sequence within a while loop.
    (while loop checks whether 'p' (for pause) is pressed or not.)
    1. checking condition whether snake hits boundary. if it hits boundary then call "gameover" function
    2. check whether snake consumes food or not.
      if it consumes food then generate new food at new location, increase score and food count.
      and create new node of snake structure to increase the length of snake.
    3. check whether any key is pressed to change direction of snake. according to that set the direction of snakes head.
    4. update direction and location of all node of snake body.
    void game(struct snake *head,struct food *f)
         struct snake *temp,pre,nxt;
    temp->link=(struct snake *)malloc(sizeof(struct snake));
    temp->link->sloc.x= temp->sloc.x;
    temp->link->sloc.y= temp->sloc.y;
    switch(key) //this key varible is set in draw() function
     case 'a': if(head->dir!='d'){head->dir='a';  head->sloc.x-=2; } else {key=head->dir;} break;
     case 'w': if(head->dir!='s'){head->dir='w';  head->sloc.y-=2; } else {key=head->dir;} break;
     case 'd': if(head->dir!='a'){head->dir='d';  head->sloc.x+=2; } else {key=head->dir;} break;
     case 's': if(head->dir!='w'){head->dir='s';  head->sloc.y+=2; } else {key=head->dir;} break;
Now you can download the source code of the game and run on your own pc.
make changes and try to modify this game.
If you have any query please leave a comment.

Wednesday, 13 March 2013

Tower Of Hanoi - Graphics in C

Hello Friends,
This is simple Tutorial about Graphics in C with example program  "Tower of Hanoi" problem.
Hope you all know about tower of Hanoi problem. If you don't know , google it :)
or visit this wikipedia page :  Tower Of Hanoi

Here is link to source file to c program : Click here

Note : program of c graphics works on 16-bit pc.
it will work on Windows xp. If you have windows 7 then you will need Dosbox to run this program.

If you traverse the program from main() function , then it is self explanatory , if you need help go through the explanation given below.

Structures :
  • loc    : containg to integers x, y  for storing coordinates of particular object
  • struct loc
    int x;
    int y;
  • bar   : It contains two variables of loc structure. one is for permanent location of bar called barloc, other is avloc which is to store on which location a ring can b put on bar.
  • struct bar
    struct loc barloc;
    struct loc avloc;
  • ring   : This structure have variable to store location of particular ring and the size of ring (top most ring have smaller size, bottom most ring have biggest size)
  • struct ring
    struct loc rloc;
    int size;
Functions :
  • draw : this function will draw whole screen,
     first it will put all the lables on the screen
    then it will draw all bars on the screen
    then all the rings will be drawn
    void draw(struct bar a,struct bar b,struct bar c,struct ring r[],int no)
    {    int i;
        outtextxy(250,30, "TOWER OF HANOI");
        outtextxy(60, 330, "SOURCE");
        outtextxy(240,330, "DESTINATION");
        outtextxy(470,330, "TEMPORARY");
        bar(a.barloc.x-2, a.barloc.y-200, a.barloc.x+1, a.barloc.y);
        bar(b.barloc.x-2, b.barloc.y-200, b.barloc.x+1, b.barloc.y);
        bar(c.barloc.x-2, c.barloc.y-200, c.barloc.x+1, c.barloc.y);
      setfillstyle(8+(i%2),10 /*getmaxcolor()*/);
  • towers : This function is recursive function. to under stand the logic go through this wikipedia page
  • void towers (int n,struct bar *from,struct bar *to,struct bar *aux,struct ring r[],int no)
    int i=1;
    (r[1].rloc.x)= to->avloc.x;
    (r[1].rloc.y)= to->avloc.y;
    if(from->avloc.y!=300){from->avloc.y+=20; }
    if(from->avloc.y!=300){from->avloc.y+=20; }
I hope this will help.
If you have any query then leave comment, and suggestions are always welcome on this blog !

Monday, 11 March 2013

How to use Android Emulator to test Custom ROM

You might have a smart phone , more precisely android smart phone and you want to install a fancy customized ROM right?

Well,  before flashing any custom ROM directly on smartphone you can try it on Android virtual device.

Requirement :
Android sdk -tool should be installed on pc/laptop to create AVD (android virtual device)
system image of custom ROM

Follow the steps given below

Step 1: Open Command prompt (run > cmd  hit enter).

Step 2: change path to "tools" folder of your android sdk
it is something like  ..\Android\android-sdk\tools
[Note : if you have set your path variable for Android Sdk then skip this step   ]

Step 3: enter the command : android list target
This command will give you list of available Android targets with ID of perticular target.
Note down the Id number of target for your custom rom
for example if your custom ROM is for ICS then choose ID number of 4.0 like wise

Example Outout :

Available Android targets:

id: 3 or "android-7"
     Name: Android 2.1
     Type: Platform
     API level: 7
     Revision: 3
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WVGA800 (default), WVGA854
     ABIs : armeabi

id: 5 or "android-8"
     Name: Android 2.2
     Type: Platform
     API level: 8
     Revision: 3
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WVGA800 (default), WVGA854
     ABIs : armeabi
id: 15 or "android-15"
     Name: Android 4.0.3
     Type: Platform
     API level: 15
     Revision: 3
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854,
     XGA720, WXGA800
     ABIs : armeabi-v7a, x86

Here for ICS we can chose ID- 15

Created AVD 'abc' based on Android 4.0.3, ARM (armeabi-v7a) processor,
with the following hardware config:

Step 4 : now we will create avd for our target sdk
command : android create avd -n NameOfEmualtor -t TargetID
hit enter ,If you receive error message : Error: This platform has more than one ABI.

Please specify one using --abi. find out abi for your target from previous "android list target" command output and now run
command: android create avd -n Name_Of_Emulator -t TargetID --abi AbiType

Example: android create avd -n myemulator -t 15 --abi armeabi-v7a
Now it will prompt : Do you wish to create a custom hardware profile [no] :
if you dont want to create custom hardware then simply give enter, It will chose default settings. and will give you following output

Step 5:
now you can see that folder named after you avd will be created in
"C:\Users\your_user_name\.android\avd" folder
copy your all Images like user image, data image, system image to this folder.

Step 6: now you can start emulator with your custom ROM by following
command : emulator -avd Name_Of_Emulator

For the first time it may take several minutes to start your AVD.

Done !
your comments, questions and suggestions are always welcome.

Wednesday, 27 February 2013

Use Whatsapp from your Laptop Using BlueStacks App Player

BlueStacks App Player lets you run apps from your phone fast and full screen on Mac and Windows.

Over 5 million people around the world use top apps like Angry Birds Space, Kik Messenger, Where's My Water and more on their laptops with BlueStacks. It took 10 engineers two years to build the complex "LayerCake" technology that enables this to happen – but you get to experience it free while in beta. 

I Googled  about some way to use whatsapp on pc and  I found some blogs showing how to Use whatsapp using BlueStacks App player. Those (See references below) are really Nice blogs/posts, But it doesn't mean that I should not write blog about same topic ri8? :)
So here it is...

Requirements : You should have a Mobile No.(This should be real because you will get verification message on that number).  This number should not  be associated to whatsapp in any other device. This means you can not use same whatsapp account on your smartphone and on your laptops/other devices

So, to use Whatsapp on your laptop, go through following steps :

1) Download BlueStacks App Player. Link : Click Here

2) Install the software.  next->next-> I agree-> ok thing... :p

3) There is search button on home screen of Bluestack app player,
     Search for  Whatsapp.

     You will find link to play shop page. Click on that
     (You may be asked to setup google play account. Do it)
    Alternatively you can use 1Mobile Market also it is similar to Play shop

4) Download whatsapp and Install it , Just like you do in smartphone

5) Launch Whatsapp

6) you will be asked to give mobile number now.

7) Then a verification code will be send to your  number via message.

8) whatsapp application will try to automatically verify that code, but certainly it will be failed. After the timer is completed, you will be able to manually enter the verification code.

 Done !!!

Now you can just add your friends contacts and add them in whatsapp,,, 
Njoy :) :)

This Blog was basically written to show you that how you can use whatsapp on your pc/laptop.But the scope of BlueStack App player is not limited to this app only...

you can run any Android application,game from play shop on this app player !!!
this is same as smartphone in your laptop.

I Hope this is helpful.
Your comments are always welcome. 

References :
1)  Screenshots from
     Julian Xhokaxhiu's Blog : Click Here

Monday, 18 February 2013

Google Dictionary Extension

Google Chrome is  one of the best web browser, In voting polls   Google chrome is one the top.  Best feature of  Google chrome is availability of various Extension in Chrome web-store.

There are many  useful Extension  available in web-store. One of them that I frequently use is  "Google Dictionary "    this  app supports many languages, but I particularly use this    for English language.

 Link to Add this Extension in Google Chrome:   Click here


View definitions easily as you browse the web.

With this extension, you can:
1) Double-click any word to view its definition in a small pop-up bubble.
2) View the complete definition of any word or phrase using the toolbar dictionary.

Foreign words are automatically translated to your language of choice.

IMPORTANT: The pop-up bubble will not work in tabs that were open prior to installation; such tabs must be refreshed. Also, note that all extensions are disabled on Chrome Web Store pages (including this page).

Supported dictionaries:
  - Chinese (Simplified)
  - Chinese (Traditional)
  - Czech
  - Dutch
  - English
  - French
  - German
  - Italian
  - Korean
  - Portuguese
  - Russian
  - Spanish

 This Extension will make your life very easy. You can find out meaning of any word instantly by double clicking on that word. 

Introduction to Microsoft Office One note

To day I want to share my experience with  One note Tool of Microsoft office.  If you use laptop/pc for frequently for business, study purpose you will really love this tool. Earlier I was  using Notepad, Notepad++, Microsoft word etc for taking note, preparing blog and to save.  But now I use One note for all this purposes.

One note  has perfect structure.  One Note comes with sample notes and User manual. Here I have Directly Copied all the content of  one page of this manual to give you Idea about  Structure.

You can use this for saving personal information, Shopping information, Recipes, To do list etc…
It has many features to share notes,  Live meeting session etc..

You can find out more about one note on Google, but manual provided in  One Note itself is fabulous to
Start with.  Give a try to it.