***Last updated on 11 May 2013 ***

Friday, 29 March 2013

PART 4 : the finishing touch

hello everyone ,
here we are now to the final step of development, ie, adding the functionality, thinking it the logical way what actualy we want our app to do ?
to increment the counter and display the value in text (On addition)
to decrement the counter and display the value in text (On subtraction)

 Getting to work

In the onClickListener method,  below the "// TODO Auto-generated method stub"define the funtionality
for addition :-
                counter++;
                display.setText("your total is "+counter);
for subtraction :-
                 counter--;
                display.setText("your total is "+counter);
 the code will look like this
check to see if you have missed anything

EXECUTING THE APP 

  • select the application from package explorer
  • right click > Run as > 1 Android application
  •  The app will load onto the Emulator

thus we come to the end of making this app , this isnt much diffficult one but its very nice one to basically, explain the steps required in every android app. 

For any query comment below , and subscribe for more android development

cheers :)

PART 3 :Adding the funtionality


hello everyone ,
 hope you have up till now done the xml part , so now we will be adding the functionality to our app. That will be done by the java. If you have some basic knowledge about JAVA it will be helpful here , if not dont worry just follow the steps carefully , i will be explaining everything.


STEP 1 : Initializing the variables

  • go to the  Mistic > src > com.game.mistic > MainActivity.java  .This is where the java class is, open it and you will find something like this .

  • after this initialize the variable , here we will be needing add button , subtract buton and the textview to show our output. For this initialize the variables as shown below. Initially you will be having some error , for that you have to import the packages (importing packages mean to get the definitions for the keywords we are going to use). For this  just hover over the keywords (here Button and TextView) and click on import (the first option in yellow box).


STEP 2: connecting the java class with xml file  

  •  For this in OnCreate method  add below code   

     add = (Button) findViewById(R.id.badd);
        sub = (Button) findViewById(R.id.bsub);
        display = (TextView) findViewById(R.id.tvDisplay);  
                  This will allow the java program to know from where to take the values, ie from where it is    taking response

STEP 3: Adding the listeners

  • In this step will will be adding listeners which will listen to the user's activity.

  • add the listener  add.setOnClickListener( )     (just type add.setOn    and Eclipse will suggest you this one .)

  • take the void listener and in place of null write new.ViewOnClickListener() again this will be suggested by the eclipse so you dont have to worry about the method it defines.

  • Note: Since java is case sensitive so take good care of cases(uppercase/ lowercase)

  •  After this add one more listener for adition ie, sub.setOnClickListener()


    Uptill now will will be having this , after this will will be assigning the work to our listeners

     

     for any query or suggestions comment below or share this post so that others can also benefit from it .

     

     

Wednesday, 27 March 2013

How to backup android apps

Well people often face situations when they have to reset their phones due to many reasons(viruses,lags etc). But often they are caught in the dilemma of how can they backup their original apk files into their memory cards so that they do not lose their important games or applications. Let me make it a bit simple for you. When you reset your phone you just lose your downloaded android games and applications. I am going to tell you an amazing way to save your money, time and internet data. Just follow the following steps.

Step 1

Move all your downloaded applications in the SD card.(For applications that you can not move to SD card just do not use them, find alternatives. Developers must ensure that their apps should be movable to SD card)

Step 2

Now download this magical File Manager.I found it on the Google android market.
File Manager

Step 3

Install and move this File manager too on the memory card, so that you can take its backup also.

Step 4

Open the newly installed file manager. It should be having a yellow folder icon. See the screenshots.

Step 5

Touch the green "Up" button which is next to HOME button in the app.


Step 6

Now touch the "asec" folder.

Step 7

Now you could see the package names of the applications that you have installed from anywhere. Just touch/click the "Multi" button to select multiple folders. COPY them and PASTE them to your SD card. And yayeeee!! now you can reset your phones.
For those who have alternate methods please comment here!!!

Friday, 8 March 2013

Part 2: Setting up the xml

Hello there continuing from where we left ie, activity_main.xml 

copy the below code in between  the xml file where linear layout has been defined

 


after this xml part is done. (dont worry will come to explaining the code shortly )

Moving on to strings.xml located at   res>values>strings.xml 

 here the name is the variable we used in xml to reference the string defined in value. It is done so that if we need to change the variable we may change the value from here only and the value will be changed from complete application (off course where we have defined the variable)

for example: name app_name is defined with value my first app, this means if we want to change the name of our app all we need to do is change the value here and name will be changed from every where wher variable app_name is used.

to make attributes click on add > select String> enter the values for name& value, and you are done.

 

here we have used values as below


 

EXPLAINING THE CODE

So the section where we understand what everything we just did, comes here :)

<TextView  //defining the text area and the text to be displayed        android:layout_width="fill_parent" //defines the width of text area
        android:layout_height="wrap_content"// defines the height of text area
        android:text="@string/head" // this is where the variable head is defined      which has value in strings.xml
        android:textSize="45sp"  //defines the size of text
        android:layout_gravity="center" // defines the layout alignment
        android:gravity="center" //defines the text alignment
        android:id="@+id/tvDisplay" // defines the id. it will be used later in funcionality
        /> // closing the textview tag

 

After this we defined the two buttons one for add other for subtract, the attributes we used in them too are similar  and differ in id, and text. and ofcourse we used button tag for buttons<Button></Button>

So this was all for today after completing till here we will be having output that may look like this

 for any query or suggestions comment or share .

 

 

 


Friday, 1 March 2013

Android :some serious work :P

hello pancakes !!  this is my first post here hope you like me too as brijesh :)
so starting for the first app ..

  • Open up new android application and continue as explained previously, if you get any problem with that check the procedure again here .


making new program

  • After you complete with making g it you will get the starting screen .Up-till now everything is just as we previously did .hence forth the real work starts. we will be working on activity_main.xml first.
  • On activity_main.xml we will automatically be having some content as shown below and for rest we will be adding  some other things too.
  • EXPLAINING THE CODE 
    The first segment we have here is
    1.   <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     2.   xmlns:tools="http://schemas.android.com/tools"
      3.  android:layout_width="match_parent"
     4.   android:layout_height="match_parent"
      5.  tools:context=".MainActivity" >
    1.   This line is default which actually import pacakages.
    2. This line defines the where to import the android tools.
    3. android:layout_width defines the width of our app on emulator.
    4. android:layout_height defines height of our app on emulator.
    5. This line defines where to start ie, MainActivity
    The second segment we have is 
          1.  <TextView
          2.    android:layout_width="wrap_content"
          3.  android:layout_height="wrap_content"
          4.  android:layout_centerHorizontal="true"
          5.  android:layout_centerVertical="true"
          6.  android:text="@string/hello_world" />
    1. It marks the beginning of Textview tag which actually contains the features about how things are to be arranged in text view
    2. the other tags are preety self explainatory , you may try on some of them yourself by deleting the values upto = and eclipse will come to your service.
    3. in last one android:text="@string/hello_world" we actually referenced the string hello world saved in values. in other places too we will be using the same .