Showing posts with label Android. Show all posts
Showing posts with label Android. Show all posts

16 May 2015

Amazing Random Class Variables



Playing Android Games is an amazing experience as every time one plays the game, s/he comes across new obstacles, new villains of different sizes, different colors, different numbers, new backgrounds and much more. This feature retains the interest of the player in the game by preventing the boredom which is created when the player plays the games which loads the same components every time.

This amazing feature is achieved with the help of Random class variables. These variables generate random values restricted to the limit specified every time they are executed.

Let us learn the use of Random class variables with simple example. Let us create an Android application which will generate random colors in the 3 x 3 grid every time the “Play” button is pressed.

Code:

package com.example.randomcolorsgenerator;

import java.util.Random;
import android.os.Bundle;
import android.app.Activity;
import android.graphics.Color;
import android.view.View;
import android.widget.*;

public class MainActivity extends Activity {

TextView t[] = new TextView [9];
Button b1;
int i,red,green,blue;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        t[0] = (TextView)findViewById(R.id.tv1);
        t[1] = (TextView)findViewById(R.id.tv2);
        t[2] = (TextView)findViewById(R.id.tv3);
        t[3] = (TextView)findViewById(R.id.tv4);
        t[4] = (TextView)findViewById(R.id.tv5);
        t[5] = (TextView)findViewById(R.id.tv6);
        t[6] = (TextView)findViewById(R.id.tv7);
        t[7] = (TextView)findViewById(R.id.tv8);
        t[8] = (TextView)findViewById(R.id.tv9);
        b1 = (Button)findViewById(R.id.button);
   
            b1.setOnClickListener(new View.OnClickListener() {
               
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    try{
                    Random r = new Random();
                    for(i=0;i<9;i++){
                        red = r.nextInt(256);
                        green = r.nextInt(256);
                        blue = r.nextInt(256);
                        t[i].setBackgroundColor(Color.rgb(red,green,blue));
                        t[i].setText(red+","+green+","+blue);
                    }
                    }
                   
                    catch(Exception e){}
                }
           
            });
  
    }
   
}

Layout file:


Snapshots:


15 May 2015

Are you a Java Programmer – If yes, aren’t you an Android Developer?



Developing Android Applications is easier if you are a java programmer. Android Developer Tools comes with a pack of numerous classes which enables you to develop Android Applications. Before starting you should have the basic idea about how you would set up your android development environment. You will require:

  • Java JDK
  • Eclipse IDE
  • Android ADT
  • Android SDK

 I recommend Android Application Development Tutorials playlist (200 videos) by thenewboston on YouTube to learn developing android applications:
               

Here you will learn about:

  • Setting up your android development environment in detail
  • Layouts
  • Use of various inbuilt classes and its methods
And much more..!  

2 Nov 2013

How to store the photos, videos, audios from your bluestack to you computer?

To copy the contents from the bluestacks app player which is received on WhatsApp is very easy. You can do this in five easy steps:

Step-1:
Open your bluestacks app player and download the ES File Explorer File Manager.














Step-2:
Go into the sdcard and select the WhatsApp folder.















Step-3:
In WhatsApp folder, select any of the folder you want to copy by long pressing it and then press the copy button.
















Step-4:
In sdcard, select bstfolder and in that again open BstSharedFolder and press the paste button available.
















Step-5:
Now you are almost ready. Go into run and type the following location:


C:\ProgramData\BlueStacks\UserData\SharedFolder
And here you will find your files you copied from Bluestacks.

You can also add files from your computer to the bluestacks app player for upload.It is also very simple. 
  • You need to copy the images in the Pictures folder of your Library. 
  • And the videos, audios should be copied in the Documents of your Library.
  • After copying, launch bluestacks and open ES file manager.
  • In sdcard\bstfolder you can find your files. Just copy them and paste as we did above.
So it is very easy right..! Enjoy Bluestacks.