Thursday, 25 September 2014

Android Bluetooth chat source code.


This is a simple and powerful bluetooth app.Using this you can turn_on bluetooth,start discoverable with a simple touch,even turn_off your bluetooth.This will not work on emulator since bluetooth support is not added.



Here the class name is MainActivity. The data fields used are (out,button,button1,button2,mbluetooth bluetoothAdapter).Usually view occupies a rectangular space or area on the screen and used for event handling purpose. For widgets view is the base class used to create interactive UI components findViewById is the override for the method (R.id.out).BluetoothAdapter.getDefaultAdapter() is the method used to perfom bluetooth tasks like device discovery,get query list,instantiate a  bluetoothdevice using MAC address also to create a bluetooth serversocket.

if (mBluetoothAdapter == null) {
out.append("device not supported"); this conditions checks for bluetooth device.If no hardware devices are founding in the device . It displays device not found [Note:This especially happens in android emulator, because there is no support for bluetooth hardware in android emulator].   if (!mBluetoothAdapter.isEnabled()) { when button turn_on is clicked this method will request the bluetooth adapter to enable bluetooth then the activity gets started .

 if (!mBluetoothAdapter.isDiscovering()) {
Context context = getApplicationContext();This returns context for the entire application. We can also use this instead of the current Activitycontext. If user needs a context tied to the lifecycle of the entire application,not just for the current activity.

context.Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
startActivityForResult(enableBtIntent, REQUEST_DISCOVERABLE_BT); This method instantiate bluetooth discoverable .We can also set the time for turning on discoverable.

mBluetoothAdapter.disable();This method will turn off the bluetooth and exists the application.

Xml code

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/ic_launcher"
    tools:context=".MainActivity" >

       The Android compiler considers everything inside the relative layout tag to be a parameter or a customization option until it reaches a closing tag(/>).
android:layout_width="wrap_content"
The wrap_content parameter tiles the content. The layout used for this program is relative layout.


Manifest.xml

In manifest file these to permission’s has to be added in order to start the activity without any crash.

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

 


Java source code



package com.example.bluetooth;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {
      private static final int REQUEST_ENABLE_BT = 0;
        private static final int REQUEST_DISCOVERABLE_BT = 0;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    final TextView out=(TextView)findViewById(R.id.out);
    final Button button = (Button) findViewById(R.id.button1);
    final Button button1 = (Button) findViewById(R.id.button2);
    final Button button2 = (Button) findViewById(R.id.button3);
    final BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    if (mBluetoothAdapter == null) {
       out.append("device not supported");
    }
    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if (!mBluetoothAdapter.isEnabled()) {
                Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
                startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
            }
        }
    });
    button1.setOnClickListener(new View.OnClickListener() {
     @Override
        public void onClick(View arg0) {
            if (!mBluetoothAdapter.isDiscovering()) {
//                   out.append("MAKING YOUR DEVICE DISCOVERABLE");
                   Context context = getApplicationContext();
                   CharSequence text = "MAKING YOUR DEVICE DISCOVERABLE";
                   int duration = Toast.LENGTH_SHORT;

                   Toast toast = Toast.makeText(context, text, duration);
                   toast.show();
                Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
                startActivityForResult(enableBtIntent, REQUEST_DISCOVERABLE_BT);
                 
            }
        }
    });
    button2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View arg0) {  
            mBluetoothAdapter.disable();
//            out.append("TURN_OFF BLUETOOTH");
            Context context = getApplicationContext();
               CharSequence text = "TURNING_OFF BLUETOOTH";
               int duration = Toast.LENGTH_LONG;
               Toast toast = Toast.makeText(context, text, 15);
               toast.show();
            }
    });
}

}



Xml code



<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/ic_launcher"
    tools:context=".MainActivity" >

<TextView android:text="" android:id="@+id/out" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="30dp"
        android:layout_marginTop="49dp"
        android:text="TURN_ON" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/button1"
        android:layout_below="@+id/button1"
        android:layout_marginTop="27dp"
        android:text="DISCOVERABLE" />

    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/button2"
        android:layout_below="@+id/button2"
        android:layout_marginTop="28dp"
        android:text="TURN_OFF" />

</RelativeLayout>

Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.example.bluetooth"
    android:versionCode="1"
    android:versionName="1.0" xmlns:android="http://schemas.android.com/apk/res/android">

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.bluetooth.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>









Download.apk file

http://www.4shared.com/zip/7OHBkCE_ce/Bluetooth.html





Android Copying sample data files into sdcard partition.

Copying sample data files into sdcard partition.

Requirements for copying sample files to SDcard:
1.Android sdk(software development kit).
Link to Download: http://developer.android.com/sdk/index.html

Steps:
1.Connect LAN cable to host and target machines.You should connect to RJ45 port in system.
2.Using ifconfig cmd. Configure the manual ip address for both the machines
Cmd: ifconfig eth0 <ip address> <net mask address> up
ex: ifconfig eth0 192.168.1.15 net mask 255.255.255.0 up
3.Enter into Android sdk path
ex: e:/eclipse/android-sdk/platform-tools/


4.Using adb connect command you can connect host and target
Cmd:adb connect <ip address:port address>
ex:adb connect<192.168.1.15:5555>
Screenshot:

5.Check for connected devices.
Cmd:adb devices
as soon you type this command it will list the connect devices.

6.After connecting devices try to push the files into platform-tools folder.

7.Once the files are copied into platform-tools folder .Use adb push cmd to push the files to target.
Cmd:adb push file name /sdcard/file name..
ex:adb push abc.txt /sdcard/abc.txt


Thursday, 21 March 2013

Android Bluetooth UUID Sample.

This program uses BluetoothAdapter to get default adapter.
Broadcast Intent(ACTION_REQUEST_ENABLE) method is used to turnon bluetooth.

We can get UUID(Universally unique identifier) and MAC address from textview.

Before setting up bluetooth. We need to verify that the bluetooth is supported by the device only then  bluetooth turns on.

To turn on bluetooth the bluetooth adapter is required
(BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) {
    // Device does not support Bluetooth
}.
 By calling static method .getDefaultAdapter();will return a bluetooth adapter that represents the device.

After getting the bluetooth adapter. We have to enable bluetooth .
This can be done by calling .isEnabled().Even after this if the method returns false.
We can request bluetooth to be enabled by calling startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);

Once bluetooth is enabled .
We can start device discovery .getBondedDevices this will get list of connected devices.

To start discovering devices just call startDiscovery() .
This application has to register a BroadcastReceiver for ACTION_FOUND intent.
Inorder to receive information about all the connected devices.


Finally Out.Append method is used to list the devices and address of the devices.
                     
   

JAVA PROGRAM 


package com.example.bluetoothlist;

import java.util.Set;

import android.os.Bundle;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class Bluetoothlist extends Activity implements OnClickListener, android.view.View.OnClickListener {
    //private static final int REQUEST_ENABLE_BT = 0;
    TextView out;
    Button turnon;
    Button list;
    Button turnoff;
    int REQUEST_ENABLE_BT = 0;
    BluetoothAdapter mBluetoothAdapter = null;
   
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_bluetoothlist);
        turnon=(Button)findViewById(R.id.button1);
        list=(Button)findViewById(R.id.list);
        turnoff=(Button)findViewById(R.id.turnoff);
         out = (TextView) findViewById(R.id.add);
       
        final BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
        mBluetoothAdapter.startDiscovery();
        if (mBluetoothAdapter == null) {
         //  out.append("device not supported");
        }
       
       
   

   
      turnon.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                if (!mBluetoothAdapter.isEnabled()) {
                    Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
                    startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
                   
                    Set<BluetoothDevice> devices = mBluetoothAdapter.getBondedDevices();
                    for (BluetoothDevice device : devices) {
                        out.append("\nFound device: " + device);
                    
                    }
                }
            }
        });
      list.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
             
                    Set<BluetoothDevice> devices = mBluetoothAdapter.getBondedDevices();
                    for (BluetoothDevice device : devices) {
                       
                        //Menu mArrayAdapter = null;
                        out.append("\nFound device: " + device.getName()+ "\n" +"\nDevice name"+ device.getAddress());
                       
                    
                    }
                }
            });
       
        turnoff.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                  mBluetoothAdapter.disable();
              
            }
        });}

    @Override
    public void onClick(View arg0) {
        // TODO Auto-generated method stub
       
    }

    @Override
    public void onClick(DialogInterface arg0, int arg1) {
        // TODO Auto-generated method stub
       
    }}
   
   

    XML CODE

 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Bluetoothlist" >

    <Button
        android:id="@+id/list"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_alignLeft="@+id/button1"
        android:layout_alignParentTop="true"
        android:text="List" />

    <TextView
        android:id="@+id/add"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/button1"
        android:layout_marginTop="52dp"
        android:text="List of devices" />

    <Button
        android:id="@+id/button1"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_below="@+id/list"
        android:layout_centerHorizontal="true"
        android:onClick="showMessage"
        android:text="TURN ON BT" />

    <Button
        android:id="@+id/turnoff"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/button1"
        android:layout_below="@+id/list"
        android:layout_toRightOf="@+id/list"
        android:text="TURN OFF" />

</RelativeLayout>

 

Manifest File

 

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.bluetoothlist"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

  <uses-permission android:name="android.permission.BLUETOOTH" />
  <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
 
   
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.bluetoothlist.Bluetoothlist"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>


 
 
 
 

Tuesday, 25 December 2012

Android phone call program.



This program helps you to call . Code used is very simple and easy to understand.


Code: (MainActivity)



package com.example.dialnumber;

import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;


public class MainActivity extends Activity {
    private Button buttonte1;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        buttonte1 = (Button)findViewById(R.id.button1);
        buttonte1.setOnClickListener(new Button.OnClickListener() { public void onClick (View v){
            Intent callIntent = new Intent(Intent.ACTION_CALL);
            callIntent.setData(Uri.parse("tel:123"));
            startActivity(callIntent);


        }});
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

}
Code:(Activity_main.xml)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        />

    <Button
        android:id="@+id/button1"
        android:layout_width="500px"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="14dp"
        android:text="CustomerCare" />

</RelativeLayout>

Thursday, 13 October 2011

Android Simple calculator program

Hi all,

This is a small calculator program for beginners.With this program you can learn adding buttons to UI,adding sliders to UI.This program uses simple functions like add(),sub(),div(),mul().



JAVA CODE

package simple.calculator;

//import sip.com.calc.R;
import android.app.Activity;
import android.os.Bundle;
import android.text.InputType;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;

public class SimpleCalculatorActivity extends Activity {
    private EditText txtinput1;
    private EditText txtinput2;
    private EditText txtinput3;
    private Button buttonte;
    private Button buttonte1;
    private Button buttonte2;
    private Button buttonte3;
  //  private Button buttonte4;
    private Button buttonte46;
    private Button buttonte47;
    private Button buttonte48;
    private Button buttonte49;
    private Button buttonte50;
    private Button buttonte51;
    private Button buttonte52;
    private Button buttonte53;
    private Button buttonte54;
    private Button buttonte55;
    private ImageView imageView;
    private double input1 =0;
    private double input2 =0;
    private double input3 =0;
   
   
   
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.calc);
        initctrls();
    }
    public void onCreate1(Bundle bundle) {
        super.onCreate(bundle);
        /**Hello World Image JFD*/
        /**BEGIN
        */
        /**Create the ImageView */
        ImageView HelloWorldImageView = new ImageView(this);
        /**Set the ImageView to helloworld.png */
        imageView.setImageResource(R.drawable.icon);
        /**Set the ContentView to the ImageView */
        setContentView(HelloWorldImageView);
        /**END
        */
        }

   private void initctrls(){
       txtinput1 = (EditText)findViewById(R.id.widget41);
       txtinput2 = (EditText)findViewById(R.id.widget43);
       txtinput3 = (EditText)findViewById(R.id.widget45);
       buttonte = (Button)findViewById(R.id.widget56);
       buttonte1 = (Button)findViewById(R.id.widget57);
       buttonte2 = (Button)findViewById(R.id.widget58);
       buttonte3 = (Button)findViewById(R.id.widget59);
       buttonte46 = (Button)findViewById(R.id.widget46);
       buttonte47 = (Button)findViewById(R.id.widget47);
       buttonte48 = (Button)findViewById(R.id.widget48);
       buttonte49 = (Button)findViewById(R.id.widget49);
       buttonte50 = (Button)findViewById(R.id.widget50);
       buttonte51 = (Button)findViewById(R.id.widget51);
       buttonte52 = (Button)findViewById(R.id.widget52);
       buttonte53 = (Button)findViewById(R.id.widget53);
       buttonte54 = (Button)findViewById(R.id.widget54);
       buttonte55 = (Button)findViewById(R.id.widget55);
       buttonte.setOnClickListener(new Button.OnClickListener() { public void onClick (View v){ add(); }});
       buttonte1.setOnClickListener(new Button.OnClickListener() { public void onClick (View v){ sub(); }});
       buttonte2.setOnClickListener(new Button.OnClickListener() { public void onClick (View v){ mul(); }});
       buttonte3.setOnClickListener(new Button.OnClickListener() { public void onClick (View v){ div(); }});
       buttonte46.setOnClickListener(new Button.OnClickListener() { public void onClick (View v){ num(1); }});
       buttonte47.setOnClickListener(new Button.OnClickListener() { public void onClick (View v){ num(2); }});
       buttonte48.setOnClickListener(new Button.OnClickListener() { public void onClick (View v){ num(3); }});
       buttonte49.setOnClickListener(new Button.OnClickListener() { public void onClick (View v){ num(4); }});
       buttonte50.setOnClickListener(new Button.OnClickListener() { public void onClick (View v){ num(5); }});
       buttonte51.setOnClickListener(new Button.OnClickListener() { public void onClick (View v){ num(6); }});
       buttonte52.setOnClickListener(new Button.OnClickListener() { public void onClick (View v){ num(7); }});
       buttonte53.setOnClickListener(new Button.OnClickListener() { public void onClick (View v){ num(8); }});
       buttonte54.setOnClickListener(new Button.OnClickListener() { public void onClick (View v){ num(9); }});
       buttonte55.setOnClickListener(new Button.OnClickListener() { public void onClick (View v){ num(0); }});
     txtinput1.setInputType(InputType.TYPE_CLASS_NUMBER);
     txtinput2.setInputType(InputType.TYPE_CLASS_NUMBER);
     txtinput3.setInputType(InputType.TYPE_CLASS_NUMBER);
  }
  
   void num(int y){
      // int i =Integer.parseInt(txtinput1.getText().toString());
        if(txtinput1.isFocused()){
           
             txtinput1.append(String.valueOf(y));
        }
        if(txtinput2.isFocused()){
             txtinput2.append(String.valueOf(y));
        }
       
      // txtinput1.setText("1");
      // txtinput2.setText("1");
   }

   private void add(){
       input1=Double.parseDouble(txtinput1.getText().toString());
      
      
      
       input2=Double.parseDouble(txtinput2.getText().toString());
      
       input3 = (input1+input2);
      
       txtinput3.setText(Double.toString(input3));
      
      
   }
   private void sub(){
       input1=Double.parseDouble(txtinput1.getText().toString());
       input2=Double.parseDouble(txtinput2.getText().toString());
       input3=(input1-input2);
       txtinput3.setText(Double.toString(input3));
      
      
   }
   private void mul(){
       input1=Double.parseDouble(txtinput1.getText().toString());
       input2=Double.parseDouble(txtinput2.getText().toString());
       input3=(input1*input2);
       txtinput3.setText(Double.toString(input3));
      
      
   }
   private void div(){
       input1=Double.parseDouble(txtinput1.getText().toString());
       input2=Double.parseDouble(txtinput2.getText().toString());
       input3=(input1/input2);
       txtinput3.setText(Double.toString(input3));
      
      
   }
  
}

Sourcecode

XML CODE



<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout android:id="@+id/LinearLayout1"
xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<HorizontalScrollView
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 xmlns:android="http://schemas.android.com/apk/res/android">
 <ScrollView
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 xmlns:android="http://schemas.android.com/apk/res/android">
<AbsoluteLayout android:id="@+id/AbsoluteLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent">
<AbsoluteLayout android:id="@+id/AbsoluteLayout1" android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="vertical">
<TextView android:id="@+id/widget40"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I1"
android:layout_x="15px"
android:layout_y="16px"
>
</TextView>
<EditText android:id="@+id/widget41"
android:layout_width="350px"
android:layout_height="80px"
android:inputType="number"
android:text=""
android:textSize="18sp"
android:layout_x="40px"
android:layout_y="16px"
>
</EditText>
<TextView android:id="@+id/widget42"
android:layout_width="350px"
android:layout_height="wrap_content"
android:text="I2"
android:layout_x="15px"
android:layout_y="100px"
>
</TextView>
<EditText android:id="@+id/widget43"
android:layout_width="350px"
android:layout_height="80px"
android:text=""
android:textSize="18sp"
android:layout_x="40px"
android:layout_y="90px"
>
</EditText>
<TextView android:id="@+id/widget44"
android:layout_width="wrap_content"
android:layout_height="28px"
android:text="Output"
android:layout_x="2px"
android:layout_y="190px"
>
</TextView>
<EditText android:id="@+id/widget45"
android:layout_width="425px"
android:layout_height="80px"
android:text=""
android:textSize="18sp"
android:layout_x="19px"
android:layout_y="205px"
>
</EditText>
<Button android:id="@+id/widget46"
android:layout_width="55px"
android:layout_height="55px"
android:text="1"
android:layout_x="40px"
android:layout_y="323px"
>
</Button>
<Button android:layout_width="55px"
android:layout_height="55px"
android:text="2"
android:layout_x="138px"
android:layout_y="321px"
android:id="@+id/widget47">
</Button>
<Button android:id="@+id/widget48"
android:layout_width="55px"
android:layout_height="55px"
android:text="3"
android:layout_x="236px"
android:layout_y="321px"
>
</Button>
<Button android:id="@+id/widget49"
android:layout_width="55px"
android:layout_height="55px"
android:text="4"
android:layout_x="40px"
android:layout_y="383px"
>
</Button>
<Button android:id="@+id/widget50"
android:layout_width="55px"
android:layout_height="55px"
android:text="5"
android:layout_x="138px"
android:layout_y="381px"
>
</Button>
<Button android:id="@+id/widget51"
android:layout_width="55px"
android:layout_height="55px"
android:text="6"
android:layout_x="236px"
android:layout_y="381px"
>
</Button>
<Button android:id="@+id/widget52"
android:layout_width="55px"
android:layout_height="55px"
android:text="7"
android:layout_x="40px"
android:layout_y="443px"
>
</Button>
<Button android:id="@+id/widget53"
android:layout_width="55px"
android:layout_height="55px"
android:text="8"
android:layout_x="138px"
android:layout_y="441px"
>
</Button>
<Button android:id="@+id/widget54"
android:layout_width="55px"
android:layout_height="55px"
android:text="9"
android:layout_x="236px"
android:layout_y="441px"
>
</Button>
<Button android:id="@+id/widget55"
android:layout_width="55px"
android:layout_height="55px"
android:text="0"
android:layout_x="138px"
android:layout_y="501px"
>
</Button>
<Button android:layout_width="105px"
android:layout_height="55px"
android:text="+"
android:layout_x="361px"
android:layout_y="321px"
android:id="@+id/widget56">
</Button>
<Button android:id="@+id/widget57"
android:layout_width="105px"
android:layout_height="55px"
android:text="-"
android:layout_x="361px"
android:layout_y="381px"
>
</Button>
<Button android:id="@+id/widget58"
android:layout_width="105px"
android:layout_height="55px"
android:text="*"
android:layout_x="361px"
android:layout_y="441px"
>
</Button>
<Button android:id="@+id/widget59"
android:layout_width="105px"
android:layout_height="55px"
android:text="/"
android:layout_x="361px"
android:layout_y="501px"
>
</Button>
<ImageView android:src="@drawable/icon"
android:layout_width="wrap_content"
 android:layout_height="wrap_content"
  android:layout_x="-5dip"
  android:layout_y="380dip"
   android:id="@+id/imageView1">
   </ImageView>
</AbsoluteLayout>
</AbsoluteLayout>
</ScrollView>
</HorizontalScrollView>

</AbsoluteLayout>

Friday, 16 September 2011

Installing new apk in android emulator using ubuntu.

Steps:

1.Go to sdk/platform-tools

Cmd:   cd  /home/android-sdk/platform-tools

2. List the devices

Cmd:   ./adb devices

Ex:    ./adb devices
List of devices attached
emulator-5554    device


3.To install

Cmd:  ./adb install .filename.apk

Ex:   ./adb install AndExplorer.apk
1083 KB/s (338651 bytes in 0.305s)
    pkg: /data/local/tmp/AndExplorer.apk
Success




Before Installation


 After Installation.



Work Done:


tec@tec-G41M-Combo:~$ sudo su
root@tec-G41M-Combo:/home/tec# cd /home/tec/
root@tec-G41M-Combo:/home/tec# chmod 777 -R android-sdk-linux_x86/
root@tec-G41M-Combo:/home/tec# clear

root@tec-G41M-Combo:/home/tec# cd android-sdk-linux_x86/platform-tools/
root@tec-G41M-Combo:/home/tec/android-sdk-linux_x86/platform-tools# ls3dspusbbus         dexdump        Maid with the Flaxen Hair.mp3
3dspusbwlan.ko     dhd.ko         NOTICE.txt
3dspusbwlanpriv    dmesg.log      Ny
aapt               dmesg_mod.txt  pdf
adb                dmesg.txt      sample
aidl               drive          Sleep Away.mp3
apps               Driver         source.properties
binary             driver_src     test2
BlueW-2310U_2.0.0  dx             untitled folder
con                img            uwb
config             lib            uwbtest
config~            llvm-rs-cc     wlan
root@tec-G41M-Combo:/home/tec/android-sdk-linux_x86/platform-tools# ./adb devices
List of devices attached
emulator-5554    offline

root@tec-G41M-Combo:/home/tec/android-sdk-linux_x86/platform-tools# ./adb devices
List of devices attached
emulator-5554    device

root@tec-G41M-Combo:/home/tec/android-sdk-linux_x86/platform-tools# ./adb install AndExplorer.apk
1083 KB/s (338651 bytes in 0.305s)
    pkg: /data/local/tmp/AndExplorer.apk
Success

Sunday, 24 April 2011

Android Platform Debugging:

Process For Platform Debugging:

Steps:

    * Get into the Source Root folder and type environment setup command ------>  "source build/envsetup.sh"
    * Choose which target to build with lunch. The exact configuration can be passed as an argument ----> "lunch"
    * Build the source by make command -------> "make"

Emulator launching:

    * once the build is over launch the emulator with following instruction

For emulator without keypad:

    "sudo out/host/linux-x86/bin/emulator -system out/target/product/generic -kernel prebuilt/android-arm/kernel/kernel-qemu -data out/target/product/generic/userdata.img"


For emulator with keypad:

    "out/host/linux-x86/bin/emulator -data out/target/product/generic/userdata.img"

Using Eclipse:

    * Go to the eclipse Folder and launch Eclipse -------> ./eclipse.
    * copy the .classpath file from "development/ide/eclipse" to root folder. get into your source root folder then type the following with "." in end  --------->  "cp development/ide/eclipse/.classpath ."
    * Then "chmod u+w .classpath"

    * now the .classpath file is copied. To check list all the files on root folder and find the .classpath file on
that -------> "ll"
    * In eclipse now create a new java project   new --> javaproject --> import --> source(path)
    * Check weather source included without any error.
    * If you are getting following error "
        1) 'out/target/common/obj/JAVA_LIBRARIES/google-common_intermediates/javalib.jar'
Generic-Android         Build path      Build Path Problem "
            * If u get the problem .jar(out/target/common/obj/JAVA_LIBRARIES/google-common_intermediates/javalib.jar)  change above jar name to "out/target/common/obj/JAVA_LIBRARIES/android-common_intermediates/javalib.jar" on .classpath.

        2) 'out/target/common/obj/JAVA_LIBRARIES/gsf-client_intermediates/javalib.jar'
Generic-Android         Build path      Build Path Problem
            * If u get the problem .jar file error just delete that line on .classpath.

    once these error is closed you may get error on  "com.android.providers.calendar,   com.android.providers.contacts "
    * To solve that error we need to import "EventLogTags.java" to their corresponding packages.
        1) For error on    "com.android.providers.calendar" eventlogtags  right click on that package  new --> file -->advanced --> link to file in the filesystem --> browse ..your source root -->out -->target --> common -->obj -->Apps -->calenderprovider_intermediates -->srs --> src --> com -->android --> providers --> calender -->EventLogTags.java
        2) For error on    "com.android.providers.contacts" eventlogtags  right click on that package  new --> file -->advanced --> link to file in the filesystem --> browse ..your source root -->out -->target --> common -->obj -->Apps -->contactsprovider_intermediates -->srs --> src --> com -->android --> providers --> contacts -->EventLogTags.java

    * clean and refresh and build again.
    * launch the emulator in another terminal shell.
    
ddms setup:

    * in eclipse goto run --> Debug configuration --> Remote java application --> new
    * In project name give your source name.
    * Change the port number to 8700 and click Debug.
    * Open new terminal shell and start ddms. goto root folder and type ddms.
    * Select the process to debug and start debug.