Friday, November 29, 2013

Learn Development of Button

Hello,
Todays we will develop an application that contains two attributes "Button" and "EditText"
 we will manage a simple activity that serves to display your sex,
 you must press the "male" or "female" button and then display it in the "EditText",


the purpose of this article is to learn how to manage a Button,

 <EditText android:id="@+id/EditText01"
        android:layout_width="250dp"
        android:layout_height="55dp"
        android:textSize="20px"
        android:editable="false"
        android:cursorVisible="false">
 </EditText>

 <Button
       android:text="Male"
       android:id="@+id/button1"
       android:layout_width="100dp"
       android:layout_height="60dp"
       android:textSize="20dp">
  </Button>
   
 <Button
      android:text="Female"
      android:id="@+id/button2"
      android:layout_width="100dp"
      android:layout_height="60dp"
      android:textSize="20dp">
  </Button>












package electro.droid;
import android.app.Activity;
import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;

public class act1 extends Activity {
 private EditText Screan;
 private Button Male;
 private Button Female;
    
public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        Screan=(EditText)findViewById(R.id.EditText01);
        Male = (Button) findViewById(R.id.button1);
        Female= (Button) findViewById(R.id.button2);
       
        Male.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                 Screan.setText("I'm a Man :)");
            }
        });
       
        Female.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                 Screan.setText("I'm a Woman :)");
            }
        });
       
    }
}





Tuesday, November 19, 2013

Embedded Systems


If we look around, we will find ourselves to be surrounded by computing systems. Every year millions of computing systems are built destined for desktop computers Embedded Systems (Personal Computers, workstations, mainframes and servers) but surprisingly, billions of computing systems are built every year embedded within larger electronic devices and still goes unnoticed. Any device running on electric power either already has computing system or will soon have computing system embedded in it.
Today, embedded systems are found in cell phones, digital cameras, camcorders, portable video games, calculators, and personal digital assistants, microwave ovens, answering machines, home security systems, washing machines, lighting systems, fax machines, copiers, printers, and scanners, cash registers, alarm systems, automated teller machines, transmission control, cruise control, fuel injection, anti-lock brakes, active suspension and many other devices/ gadgets.

What is Embedded System?
all computing systems other than general purpose computer (with monitor, keyboard, etc.) are embedded systems.

System is a way of working, organizing or performing one or many tasks according to a fixed set of rules, program or plan. In other words, an arrangement in which all units assemble and work together according to a program or plan. An embedded system is a system that has software embedded into hardware, which makes a system dedicated for an application (s) or specific part of an application or product or part of a larger system. It processes a fixed set of pre-programmed instructions to control electromechanical equipment which may be part of an even larger system (not a computer with keyboard, display, etc).


Block diagram of a typical embedded system is shown in fig :


CHARACTERISTICS  
a)    Embedded systems are application specific & single functioned; application is known apriori, the programs are executed repeatedly.
b)    Efficiency is of paramount importance for embedded systems. They are optimized for energy, code size, execution time, weight & dimensions, and cost.
c)    Embedded systems are typically designed to meet real time constraints; a real time system reacts to stimuli from the controlled object/ operator within the time interval dictated by the environment. For real time systems, right answers arriving too late (or even too early) are wrong.
d)   Embedded systems often interact (sense, manipulate & communicate) with external world through sensor and actuators and hence are typically reactive systems; a reactive system is in continual interaction with the environment and executes at a pace determined by that environment.


Transition from Activity to another

To create a new activity, you must follow these steps:
Create a new class in your package that inherits from the Activity class.
Generate the onCreate () method.
Create a new layout file, and add the desired graphics.
Associate the layout file to your activity in the onCreate () method.

 

the purpose of this article is to manage a passage from one activity to another
The passage between two activities requires an Intent. An Intent is a container for information. 
It used to pass messages between two activities.  
The appellant activity can thus transmit information to the application called,and the Android system.

  1. There are several ways to create an Intent. We will choose the following:
                 MyIntent intent = new Intent (<context>, < class  of the activity target);

      2.  To start another activity, you must run the method :

                 startActivity (Intent i) the initial Activity class. 
 
      3.  In the target activity, we get the Intent :

                 getIntent();


 <TextView
        android:text="Activity 1"
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="40dp">
  </TextView>
    


    <Button
         android:id="@+id/toact2"
         android:layout_width="70dp"
         android:layout_height="50dp"
         android:text="Act2"
         android:textSize="30dp"
         android:background="@drawable/bpassage"
      />
      
     <Button
         android:id="@+id/toact3"
         android:layout_width="70dp"
         android:layout_height="50dp"
         android:text="Act3"
         android:textSize="30dp"
         android:background="@drawable/bpassage"
      /> 


 we will create an application that consists of 3 Activity, each activity has the same
 graphical interface

Activity 1 :

package electro.droid;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class act1 extends Activity {
    /** Called when the activity is first created. */
    private Button act2;
    private Button act3;
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main1);
        getIntent();
        act2 = (Button) findViewById(R.id.toact2);
        act3 = (Button) findViewById(R.id.toact3);
       
        act2.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Intent i = new Intent (act1.this, act2.class);
                startActivity(i);
            }
        });
       
        act3.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                       Intent i1 = new Intent (act1.this, act3.class);
                       startActivity(i1);

                       finish();
            }
        });
    }
}

  1.  we will copy this code and paste it in  activity number 2 , 3.
     2.  we have to change the activity target : 
  •  Example in the second activity :
                       Intent i1 = new Intent (act2.this, act3.class); // from 2 to 3
                       startActivity(i1);

  • activity number 3 :
                       Intent i1 = new Intent (act3.this, act1.class); // from 3  to 1
                       startActivity(i1);

My first Android app

To create an Android project:
  • go to File ---> New ---> Android Projec
  • Specify the project name: HelloWorld, and click Next 
  • Choose the Android platform to use (in this case 2.3.3), click Next
  • In the next window, you must specify a package to use, which must be unique. This package must contain at least two levels. In our case, you can type i.helloworld   
  • Click Finish. A new project appears. 
  •  tree of an Android project:  

  •  onCreate() :  This method is called to create an activity. It allows you to initialize. This is  where the graphical interface is specified.
  • onStart (): This method is called when the application is started.
  • onResume (): This method is called when the application passes (or returns) in the foreground.
  • onPause (): Called when the application moves to the background and another application goes ahead.
  • onStop (): Called when the application is no longer visible.
  • OnStart (): Called when the application becomes visible.
  •  onDestroy (): Called when your application is closed by the system due to a lack of resources, or by the user using a finish ().
 It is therefore possible to specify a behavior for each of these events. To do this, simply add the corresponding methods (in the same way as the onCreate method) already generated by ADT.



 Click on the method that is proposed. Its code will be automatically generated.

  1. Adding graphic elements :
The graphical interface is managed through xml files in the directory layout. ADT offers a friendly interface to manage these files and graphically manipulate the elements of the interface.
 
  • In the code file main.xml, associate a name and a title for your button:          
            <Button 
                   android: id = "@ + id / buttonDisplay" 
                   android: text = "Show" 
            ... />
 

It is possible to create all the elements of the interface through the drag-and-drop.

To set the behavior of your button, follow these steps: 

package i.HelloWorld;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class helloworldActivity extends Activity {
    /** Called when the activity is first created. */
  
/**Create an attribute in your activity type Button:**/
      private Button bDisplay;
     public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);


     2.  Behavior of a button : 
  •  In the onCreate () method:
          - Initialize the attribute bAfficher by associating the button created in the main.xml:
                    this.bDisplay = (Button) this.findViewById ("buttonDisplay");
          - Attach a behavior to your button:
                    this.closeButton.setOnClickListener (OnClickListener new () {
                    public void onClick (View v) 

                    {
                         / / behavior of your button
                    }
                     });

Monday, November 18, 2013

Initiation to Programming with Android



This article is an introduction to Android.  
We will carry out the first steps for writing applications: installation environment, and creating the first simple applications.

Introduction :

Android is an open-source operating system for smartphones, PDA and mobile devices, and based on Linux. It was designed by the Android start up, which was acquired by Google in 2005.
This is the first mobile open source and fully customizable platform., and fully customizable
It allows the developer to make the most of everything that can provide a mobile device, allowing an application to initiate a call, email or SMS, use the phone's camera ...
Android is constantly evolving thanks to innovative applications developers realize. In eight months,
more than 6,000 applications and games have been developed and published in the market. You can get the source Android from the site: http://source.android.com
For developers, consult the http://developer.android.com site. You will find downloads required, documentation, how to publish your application ...
 
 

Installations and tools :

To create applications for Android, it is necessary to install the following:
  1. JDK :  Java Development Kit: Java Development Environment, which allows you to compile   and run applications written in Java.                                                                                                                                                    
  2. Eclipse IDE Integrated Developement Environment : for simplified writing code. Is used with Eclipse the ADT plugin (Android Developement Tools) suitable for Android.                                                                                         
  3. Android SDK Android Software Development Kit: The SDK provides an API and a set of tools for application development on Android. It mainly contains an emulator (AVD for Android Virtua Device) to model a real mobile device by defining hardware and software options desired. The SDK is available for download for Linux, Mac and Windows platforms at the following address  :  http://developer.android.com/sdk/index.html
 Installing Eclipse and the ADT plugin :

Before installing Eclipse, you must first install the JDK, which will allow us to compile Java programs. 

The JDK also includes a JRE (Java Runtime Environment) runtime environment for running Programs written in Java. As Eclipse is written in Java, it will not start without JRE.You can download the JDK from the following site:
http://www.oracle.com/technetwork/java/javase/downloads/index.html

To install Eclipse, just go to : www.eclipse.org and download the appropriate version for your platform. The version we use is the basic version of Eclipse: Eclipse IDE for Java Developers.

Once Eclipse is installed, you must install the ADT plugin. for this :
  • --- Go to Help ------> Install new software ... 

 In the window that appears, click Add ... and enter the link  : 
https://dl---ssl.google.com/android/eclipse/ 
 in the rental portion as shown in the following figure:

  •  Click OK, and follow the installation procedure of the ADT plugin for Eclipse.
  • Once the plugin is installed, restart Eclipse is required.
  • To verify that the installation was successful,
          go to File ---> New ---> Other ... and verify that new part called Android has 
          been added. 

                                                                                                                                     

Installing the SDK :

The SDK comes as a compressed file. Once unzipped the file, go to the directory
tools and run the android file. The Android Manager application is launched:

The next step is to install the necessary Android platforms. Simply select platforms
you want to install, and click Install Packages ...

Configuring the SDK on Eclipse:

To configure the SDK:
  • Click Window---> Preferences and select Android
  • Specify the path to your SDK directory.

  • By clicking Apply, the list of installed platforms will be displayed.
  • Once the SDK configured, it is possible to start the emulator. To do this, 
           click directly on : 
                         
     congratulations !!! , you are ready to develop your first application ^_^


Sunday, November 10, 2013

How to change font on Samsung Galaxy Android

See how easily change the font on a smartphone or tablet Android.

No need rooter if you have a Galaxy from Samsung, otherwise you need to install an app like Font Installer that requires Roote device.
 
 
Electro Droid : How to change font on Samsung Galaxy AndroidElectro Droid : How to change font on Samsung Galaxy AndroidElectro Droid : How to change font on Samsung Galaxy Android

 
To do this, it is very easy:

     Open the "Settings" application
     Go to "View"
     Go to "Police"
     You just have to choose a different font!
     If you want other fonts, click "get more fonts online" and download what you need

And here you have to customize your Android smartphone or tablet through tips Electro Droid ! Feel free to browse all Android tips and share the link :)

This works for all phones and tablets Samsung Galaxy range as the Galaxy S1, Galaxy S2, Galaxy S3, Galaxy S3 Mini, Galaxy Note, Galaxy Ace, Galaxy Tab, Galaxy Note 2, Galaxy S4 ...

Saturday, November 9, 2013

Calculator



A simple and useful calculator , but with the support of large numbers (more than 30 digits). It can add, subtract, multiply, divide.

Let's start with the graphic interface via the main.xml file. To which will screen appears  
we will use a EditText which have the following properties:   
  1. Result display calculator :


     <EditText android:id="@+id/EditText01"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:textSize="20px"
        android:editable="false"
        android:cursorVisible="false"
     /> 
 
     2.  Buttons calculator : 



     <LinearLayout xmlns:android="http://schemas.android.com/
                                             apk/res/android"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
     > 
 
     <Button android:id="@+id/button1"
        android:text="1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
     />
 
     <Button android:id="@+id/button2"
        android:text="2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
     />
 
     <Button android:id="@+id/button3"
        android:text="3"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
     />
 
     <Button android:id="@+id/buttonPlus"
        android:text="+"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
     />
 
     </LinearLayout>
 



package com.ElectroDroid.android.calculator;
 
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
 
public class Calculator extends Activity {
 
 Button button0;
 Button button1;
 Button button2;
 Button button3;
 Button button4;
 Button button5;
 Button button6;
 Button button7;
 Button button8;
 Button button9;
 Button buttonPlus;
 Button buttonMoins;
 Button buttonDiv;
 Button buttonMul;
 Button buttonC;
 Button buttonEqual;
 Button buttonDot;
 EditText screen;
 
 private double digit1;
 private boolean clicOperator = false;
 private boolean update = false;
 private String operator = "";
 
 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
 
     
        button0 = (Button) findViewById(R.id.button0);
        button1 = (Button) findViewById(R.id.button1);
        button2 = (Button) findViewById(R.id.button2);
        button3 = (Button) findViewById(R.id.button3);
        button4 = (Button) findViewById(R.id.button4);
        button5 = (Button) findViewById(R.id.button5);
        button6 = (Button) findViewById(R.id.button6);
        button7 = (Button) findViewById(R.id.button7);
        button8 = (Button) findViewById(R.id.button8);
        button9 = (Button) findViewById(R.id.button9);
        buttonDot = (Button) findViewById(R.id.buttonDot);
        buttonPlus = (Button) findViewById(R.id.buttonPlus);
        buttonMoins = (Button) findViewById(R.id.buttonMoins);
        buttonDiv = (Button) findViewById(R.id.buttonDivision);
        buttonMul = (Button) findViewById(R.id.buttonMultiplier);
        buttonC = (Button) findViewById(R.id.buttonC);
        buttonEqual = (Button) findViewById(R.id.buttonEqual);
 
        screen = (EditText) findViewById(R.id.EditText01);
 

        buttonPlus.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
          plusClick();
         }
        });
 
        buttonMoins.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
          moinsClick();
         }
        });
 
        buttonDiv.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
          divClick();
         }
        });
 
        buttonMul.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
          mulClick();
         }
        });
 
        buttonC.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
          resetClick();
         }
        });
 
        buttonEqual.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
          egalClick();
         }
        });
 
        buttonDot.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
          chiffreClick(".");
         }
        });
 
        button0.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
          chiffreClick("0");
         }
        });
 
        button1.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
          chiffreClick("1");
         }
        });
 
        button2.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
          chiffreClick("2");
         }
        });
 
        button3.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
          chiffreClick("3");
         }
        });
 
        button4.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
          chiffreClick("4");
         }
        });
 
        button5.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
          chiffreClick("5");
         }
        });
 
        button6.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
          chiffreClick("6");
         }
        });
 
        button7.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
          chiffreClick("7");
         }
        });
 
        button8.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
          chiffreClick("8");
         }
        });
 
        button9.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
          chiffreClick("9");
         }
        });
 
    }
 
    
    public void chiffreClick(String str) {
        if(update){
                update = false;
        }else{
            if(!screen.getText().equals("0"))
             str = screen.getText() + str;
        }
        screen.setText(str);
    }
 
    
    public void plusClick(){
 
     if(clicOperator){
      calcul();
            screen.setText(String.valueOf(digit1));
        }else{
            digit1 = Double.valueOf(screen.getText().toString()).doubleValue();
            clicOperator = true;
        }
        operator = "+";
        update = true;
    }
 
    
    public void moinsClick(){
     if(clicOperator){
      calcul();
            screen.setText(String.valueOf(digit1));
        }else{
            digit1 = Double.valueOf(screen.getText().toString()).doubleValue();
            clicOperator = true;
        }
        operator = "-";
        update = true;
    }
 
    
    public void mulClick(){
     if(clicOperator){
      calcul();
      screen.setText(String.valueOf(digit1));
        }else{
            digit1 = Double.valueOf(screen.getText().toString()).doubleValue();
            clicOperator = true;
        }
        operator = "*";
        update = true;
    }
 
    
    public void divClick(){
      if(clicOperator){
       calcul();
       screen.setText(String.valueOf(digit1));
         }else{
          digit1= Double.valueOf(screen.getText().toString()).doubleValue();
          clicOperator = true;
         }
         operator = "/";
         update = true;
    }
 
    
    public void egalClick(){
     calcul();
        update = true;
        clicOperator = false;
    }
 
   
    public void resetClick(){
      clicOperator = false;
         update = true;
         digit1= 0;
         operator = "";
         screen.setText("");
    }
 
    
  private void calcul(){
   if(operator.equals("+")){
    digit1= digit1 + Double.valueOf(screen.getText().toString()).doubleValue();
         screen.setText(String.valueOf(digit1));
        }
 
   if(operator.equals("-")){
    digit1 = digit1 - Double.valueOf(screen.getText().toString()).doubleValue();
        screen.setText(String.valueOf(digit1));
        }
 
   if(operator.equals("*")){
     digit1 = digit1*Double.valueOf(screen.getText().toString()).doubleValue();
          screen.setText(String.valueOf(digit1));
        }
 
   if(operator.equals("/")){
    try{
    digit1 = digit1 / Double.valueOf(screen.getText().toString()).doubleValue();
              screen.setText(String.valueOf(digit1));
            }catch(ArithmeticException e){
                screen.setText("0");
            }
        }
    }
}
 
 
Calculator : 

 

 

Copyright @ 2013 ELECTRO DROID.

Designed by Atef.A | Deal Commerce