Saturday, 23 March 2013

WIFI demonstration in Android

The Wi-Fi APIs provide a means by which applications can communiate with the lower-level wireless stack that provides Wi-Fi network access. Almost all information from the device supplicant is available,include the connected network's link speed, ip address ,negotiation state, and more, plus information about other networks that are available.Some other API features include the ability to scan, add,save,terminate and initiate wi-fi connections.
Here i give the code for accessing and scanning the configuration for wi-fi :


Bluetooth in Android platform

Bluetooth:

The Android platform includes support for the Bluetooth network stack,which allows a device to wirelessly excahnge data with other Bluetooth devices.The application framework provides access to the Bluetooth functionality through the Android Bluetooth APIs. these APIs let applications wirelessly connect to other Bluetooth devices,APIs let applications wirelessly connect to other Bluetooth devices,enabling point-to-point and multpoint wireless features.

 Using Bluetooth APIs, an Android application can perform the following:
scan for the Bluetooth devices.
  • Query the local Bluetooth adapter for paired Bluetooth devices.
  • Establish RFCOMM channels.
  • connect other devices through service discovery.
  • Transfer data to and from other devices.
  • Manage multiple connections.
Here we simply gives the code for Bluetooth enable code the following.

Friday, 22 March 2013

play back media player in android

Media player class can be used to control playback of audio/video files and streams.An example below is shows how to use  and play a video .
the following code will be useful:

How to create my own cotent provider in android

A content provider manages access to a central repository of data.A provider is a part of an Adnroid application,which often provides its own UI for working with the data.However,content providers are primarily intended to be used by other applications, which access the provider using a provider client object.Together,providers and provider clients offer a consistent,standard interfaceto data that also handles inter-process communication and securedata access.

This code describes the basics of the following:

  • How content providers work.
  • The API you use retrieve data from a content provider.
  • The API you use to insert,update,or delete data in a contentprovider.
  • other API features that facilitate working wiht providers.
  • The following code is useful to create content provider 

Texttospeech source code for android

We've inroduced a new feature  in Android platform:Text-To-Speech(TTS),Also known as "speech synthesis",TTs enables your Android device to"speak" text of different languges.
 

 Text-to-speech can help you push your app in new directions.Whether you use TTs to help users with disabilities,to enable the use of your application while looking from the screen,or simply to make it cool, we hope you'll enjoy this new feature.

How to create tab layout

Tablayout demo will exaplains about how to set tabs on your application and operations perform on  tabs by  clicking on the tab buttns .when click on the tab button like Home ,cattagirious,aboutus ....., like the way we have the actual code for the tab layout view and i think this should useful to your applicaions and now these days multiple tabs is used for good layout design .
  Below code could be useful:

Thursday, 21 March 2013

How to send a sms

Sending a sms is a process of containing the methods  that mean if one can send a sms is not easy. Here send a sms is the process of explaing the present situation and we may call it as the neccessity of the situation .But we are gaving the process made easy in android application devlopers for devloping an app with the sms requirement of the users. So, the following code will need you.

     SENDING A SMS IN ANDROID:

Write the following code in your application:
   use this code for send sms:

Tuesday, 12 March 2013

How to create database openhelper in android

creating data base openhelper in android is most importent part in android appolication devlopment and when you write the code for an application then you need to create a data base open helper for your application this should be helpful for your app.

How to create sqlite database in android

Creating database for an application  is more critical part for navigating the data for retreviewing and maintianing the data source in sqlite databse when you are devloping an app then you should create a sqlite database for maintaing our database ,so the following code will helpful for creating sqlite database .

Wednesday, 6 March 2013

How to create menu items with clicklistner in android

Menuitem clicklistner for menu botton. when  click on menu button this shows the menu items and when press on the menu button it will genarate a click listner for an item

how to create listview for android

Creating a listview for an app ,Extends the ListActivity and setListadapter for String values.


write on your project and get the answer easily:

package com.dynamic;

import android.app.Activity;
import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class ListdynamicActivity extends ListActivity{
String [] vals={"aaa","vvv","bbb"};
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
     
        setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, vals));
//        setContentView(R.layout.main);
   
    }
}


How to create a loginpage

Creating the login page for the sqlite database when you are entering the login the page you should type the username and password ,so then we should check your Authentication. here we the following example will helpful to creating  login page.

How to carryvalues in android

How to carry the values of the activity

How to Set background of the layout

Set the background colore of the layout :  when you want to change the back ground color of the layout see the code is useful to you and click on the following link for the code of the colors you want to change.
http://cloford.com/resources/colours/500col.htm

example about button clicklistner


//step1:
drag&drop the button component into  the layout.
//step2:
bind the components with id
 Button b=(Button)findviewByID(R.id.button1);
//step3:
provide event handler action for button.
b.setonclicklistner(this);
//example:when press the button 
toast.maketest(this,"hi i am vijay",30).show();




package com.myfirstlenovoapp;

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

public class MainActivity extends Activity implements OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button b=(Button)findViewById(R.id.button1);
        b.setOnClickListener(this);
    }


@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Toast.makeText(this,"hi i am vijay", 30).show();
    }
}
write the below code in main.xml page :
<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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity"
    android:background="#ffc0cb" >

    <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="102dp"
        android:layout_marginTop="90dp"
        android:text="@string/hi" />

</RelativeLayout>


  following figure illustrates the answer:








Tuesday, 5 March 2013

How to Creating an alertbox

package com.codingonandroid;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;

public class second extends Activity implements OnClickListener{
Intent i1,i2,i3;
EditText ed1,ed2;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ed1=(EditText)findViewById(R.id.editText1);
ed2=(EditText)findViewById(R.id.editText2);
ed1.setOnClickListener(this);  
 
 
 
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
MenuInflater mi=getMenuInflater();
mi.inflate(R.menu.main, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
switch (item.getItemId()) {
case R.id.item1:
i1=new Intent(this,MainActivity.class);
startActivity(i1);
break;
case R.id.item2:
i2=new Intent(this,search.class);
startActivity(i2);
break;
case R.id.item3:
i3=new Intent(this,contact.class);
startActivity(i3);

default:
break;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
AlertDialog.Builder ad=new AlertDialog.Builder(this);
                ad.setTitle("alert box");
                ad.setMessage("enter valid username");
                ad.setPositiveButton("ok",null);
                ad.setNegativeButton("cancle",null);
                ad.show();
}


}

installation of eclipse for android devlopment

To get the android devlopers tool simple gothrough the following way:

first you need to install java jdk on your computer just click andinstall http://www.oracle.com/technetwork/java/javase/downloads/index.html
click the below link:
                          www.android.com
   just click on devlopers and it free of cost to getting and open source for all who are devloping themselves and  click on getsdk then it shows 
                                  downloadsdk adtbundle for windows click on that just read the terms and conditions and accept that if u r wondows is 32 or 64 select one and  click on download the sdkbundle for windows





activity life cycle

there are 7 methods in activity life cycle below are listed:
1)oncreate
2)onstart
3)onresume
4)onpause
5)onstop
6)onrestart
7)ondestroy
 actual life cycle of an activity shown the figure above:
The following code will be helpful  for shows the life cycle of an activity:

package com.activity;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;

public class LifecycleActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Toast.makeText(this, "oncreate", 15).show();
    }
    @Override
    protected void onStart() {
    // TODO Auto-generated method stub
    super.onStart();
    Toast.makeText(this, "onstart", 15).show();
    
    }
    @Override
    protected void onResume() {
    // TODO Auto-generated method stub
    super.onResume();
    Toast.makeText(this, "onresume", 15).show();
    
    }
    @Override
    protected void onPause() {
    // TODO Auto-generated method stub
    super.onPause();
    Toast.makeText(this, "onpause", 15).show();
    
    }
    @Override
    protected void onStop() {
    // TODO Auto-generated method stub
    super.onStop(); 
    Toast.makeText(this, "onstop", 15).show();
    
    }
    @Override
    protected void onRestart() {
    // TODO Auto-generated method stub
    super.onRestart();
    Toast.makeText(this, "onrestart", 15).show();
    }
    @Override
    protected void onDestroy() {
    // TODO Auto-generated method stub
    super.onDestroy();
    Toast.makeText(this, "ondestroy", 15).show();
    
    }
}














How to creating a splash screen


package com.harizontrip;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splashscreen);
        //step 1:
        Thread th=new Thread(){
       
        // step 2:
       
        @Override
        public void run() {
        // TODO Auto-generated method stub
        super.run();
       
        try {
sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
        // step 4:
        finally{
       
       
        startActivity(new Intent(MainActivity.this,second.class));
        }
       
        }
       
       
        };
        // step 3:
        th.start();
   }}  
     
output will be th following:

 


 

click on menu items

writa a program with menu item clicklisner


//write the below code in the main class:

package com.Codingonandroid;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;

public class second extends Activity{
Intent i1,i2,i3;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
MenuInflater mi=getMenuInflater();
mi.inflate(R.menu.main, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
switch (item.getItemId()) {
case R.id.item1:
i1=new Intent(this,MainActivity.class);
startActivity(i1);
break;
case R.id.item2:
i2=new Intent(this,search.class);
startActivity(i2);
break;
case R.id.item3:
i3=new Intent(this,contact.class);
startActivity(i3);

default:
break;
}
return super.onOptionsItemSelected(item);
}


}

//write the below code in  menu.xml 

<menu xmlns:android="http://schemas.android.com/apk/res/android" >

    <item
        android:id="@+id/action_settings"
        android:orderInCategory="100"
        android:showAsAction="never"
        android:title="@string/action_settings"/>
    <item android:id="@+id/item1" android:title="Home" android:showAsAction="ifRoom|withText"></item>
    <item android:id="@+id/item2" android:title="search" android:showAsAction="ifRoom|withText"></item>
    <item android:id="@+id/item3" android:title="contact us" android:showAsAction="ifRoom|withText"></item>

</menu>

register the classes in the manifestfile:
   <activity android:name=".second"></activity>
        <activity android:name=".search"></activity>
        <activity android:name=".contact"></activity>


//output will be  the following :

//when press the home button: