Friday, 31 May 2013
SIMPLE PROGRAMME ON PENDINGINTENT IN ANDROID
PendingintentActivity.java
package com.mypendingintent;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class PendingintentActivity extends Activity {
/** Called when the activity is first created. */
EditText et1;
Button b1;
String s1;
long t1, t2;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
et1 = (EditText) findViewById(R.id.editText1);
b1 = (Button) findViewById(R.id.button1);
}
public void start(View v) {
AlarmManager am=(AlarmManager)getSystemService(Context.ALARM_SERVICE);
s1=et1.getText().toString();
t1=Integer.parseInt(s1);
long t2=System.currentTimeMillis()+(t1*1000);
Intent i=new Intent(this,Next2.class);
PendingIntent pi=PendingIntent.getBroadcast(getBaseContext(), 0, i, 0);
am.set(AlarmManager.RTC_WAKEUP, t2, pi);
Toast.makeText(getBaseContext(), "alarm ready", 2000).show();
}
}
Next2,java
package com.mypendingintent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
public class Next2 extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context,"alarm mogindi",3000).show();
}
}
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mypendingintent"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".PendingintentActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Next2"></activity>
</application>
</manifest>
WHAT IS A PENDING INTENT IN ANDROID
PENDING INTENT IS A EXPLICIT INTENT ,,,,,,,,
WE ARE USING THIS INTENT INVOKING THE ACTIONS FOR LATER TIME ,,,,,
PendingintentActivity.java
package com.mypendingintent;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class PendingintentActivity extends Activity {
/** Called when the activity is first created. */
EditText et1;
Button b1;
String s1;
long t1, t2;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
et1 = (EditText) findViewById(R.id.editText1);
b1 = (Button) findViewById(R.id.button1);
}
public void start(View v) {
AlarmManager am=(AlarmManager)getSystemService(Context.ALARM_SERVICE);
s1=et1.getText().toString();
t1=Integer.parseInt(s1);
long t2=System.currentTimeMillis()+(t1*1000);
Intent i=new Intent(this,Next2.class);
PendingIntent pi=PendingIntent.getBroadcast(getBaseContext(), 0, i, 0);
am.set(AlarmManager.RTC_WAKEUP, t2, pi);
Toast.makeText(getBaseContext(), "alarm ready", 2000).show();
}
}
Next2,java
package com.mypendingintent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
public class Next2 extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context,"alarm mogindi",3000).show();
}
}
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mypendingintent"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".PendingintentActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Next2"></activity>
</application>
</manifest>
WE ARE USING THIS INTENT INVOKING THE ACTIONS FOR LATER TIME ,,,,,
PendingintentActivity.java
package com.mypendingintent;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class PendingintentActivity extends Activity {
/** Called when the activity is first created. */
EditText et1;
Button b1;
String s1;
long t1, t2;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
et1 = (EditText) findViewById(R.id.editText1);
b1 = (Button) findViewById(R.id.button1);
}
public void start(View v) {
AlarmManager am=(AlarmManager)getSystemService(Context.ALARM_SERVICE);
s1=et1.getText().toString();
t1=Integer.parseInt(s1);
long t2=System.currentTimeMillis()+(t1*1000);
Intent i=new Intent(this,Next2.class);
PendingIntent pi=PendingIntent.getBroadcast(getBaseContext(), 0, i, 0);
am.set(AlarmManager.RTC_WAKEUP, t2, pi);
Toast.makeText(getBaseContext(), "alarm ready", 2000).show();
}
}
Next2,java
package com.mypendingintent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
public class Next2 extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context,"alarm mogindi",3000).show();
}
}
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mypendingintent"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".PendingintentActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Next2"></activity>
</application>
</manifest>
SIMPLE PROGRAMME ON SMS BROADCAST RECVER IN ANDROID
SMSReceiver.Java
package com.broadsmsrx;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract.PhoneLookup;
import android.telephony.SmsMessage;
import android.util.Log;
import android.widget.Toast;
public class SMSReceiver extends BroadcastReceiver {
private NotificationManager mManager;
Cursor c;
Context context1;
@Override
public void onReceive(Context context, Intent intent) {
context1=context;
Bundle bundle = intent.getExtras();
if (bundle != null) {
Object[] pdus = (Object[])bundle.get("pdus");
final SmsMessage[] messages = new SmsMessage[pdus.length];
for (int i = 0; i < pdus.length; i++) {
messages[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
}
if (messages.length > -1) {
Log.i("TAG###################################", "Message recieved: " + messages[0].getMessageBody());
Toast toast = Toast.makeText(context,
"from: "+getContactNameFromNumber(messages[0].getOriginatingAddress().toString()).toString()+": " +messages[0].getMessageBody(), Toast.LENGTH_LONG);
toast.show();
}
}
}
private String getContactNameFromNumber(String number) {
// define the columns I want the query to return
String conname=number;
Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
Cursor c = context1.getContentResolver().query(lookupUri, new String[]{PhoneLookup.DISPLAY_NAME}, null, null, null);
while(c.moveToNext()){
/* If we find a match we put it in a String.*/
conname = c.getString(c.getColumnIndexOrThrow(PhoneLookup.DISPLAY_NAME));
}
return conname;
}
}
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.broadsmsrx"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".SMSBraodCastReceiverExActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
</application>
</manifest>
package com.broadsmsrx;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract.PhoneLookup;
import android.telephony.SmsMessage;
import android.util.Log;
import android.widget.Toast;
public class SMSReceiver extends BroadcastReceiver {
private NotificationManager mManager;
Cursor c;
Context context1;
@Override
public void onReceive(Context context, Intent intent) {
context1=context;
Bundle bundle = intent.getExtras();
if (bundle != null) {
Object[] pdus = (Object[])bundle.get("pdus");
final SmsMessage[] messages = new SmsMessage[pdus.length];
for (int i = 0; i < pdus.length; i++) {
messages[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
}
if (messages.length > -1) {
Log.i("TAG###################################", "Message recieved: " + messages[0].getMessageBody());
Toast toast = Toast.makeText(context,
"from: "+getContactNameFromNumber(messages[0].getOriginatingAddress().toString()).toString()+": " +messages[0].getMessageBody(), Toast.LENGTH_LONG);
toast.show();
}
}
}
private String getContactNameFromNumber(String number) {
// define the columns I want the query to return
String conname=number;
Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
Cursor c = context1.getContentResolver().query(lookupUri, new String[]{PhoneLookup.DISPLAY_NAME}, null, null, null);
while(c.moveToNext()){
/* If we find a match we put it in a String.*/
conname = c.getString(c.getColumnIndexOrThrow(PhoneLookup.DISPLAY_NAME));
}
return conname;
}
}
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.broadsmsrx"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".SMSBraodCastReceiverExActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
</application>
</manifest>
SAMPLE PROGRAMME ON IMPLICIT SERVICE IN ANDROID
package com.implicitservise;
import android.app.Activity;
import android.content.Context;
import android.media.RingtoneManager;
import android.os.Bundle;
import android.os.Vibrator;
import android.telephony.TelephonyManager;
import android.view.View;
import android.widget.TextView;
public class ImplicitserviceActivity extends Activity {
TextView tv;
String s;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv = (TextView) findViewById(R.id.textview1);
}
public void cell(View v) {
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
s = tm.getDeviceId().toString();
tv.setText(s);
}
public void vibrat(View v) {
Vibrator v1 = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
v1.vibrate(5000);
}
public void ring(View v) {
RingtoneManager rm = (RingtoneManager) getSystemService(Context.RINGTONE_SERVICE);
}
}
MANIFESTFILE.XML:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.implicitservise"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".ImplicitserviceActivity"
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>
import android.app.Activity;
import android.content.Context;
import android.media.RingtoneManager;
import android.os.Bundle;
import android.os.Vibrator;
import android.telephony.TelephonyManager;
import android.view.View;
import android.widget.TextView;
public class ImplicitserviceActivity extends Activity {
TextView tv;
String s;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv = (TextView) findViewById(R.id.textview1);
}
public void cell(View v) {
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
s = tm.getDeviceId().toString();
tv.setText(s);
}
public void vibrat(View v) {
Vibrator v1 = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
v1.vibrate(5000);
}
public void ring(View v) {
RingtoneManager rm = (RingtoneManager) getSystemService(Context.RINGTONE_SERVICE);
}
}
MANIFESTFILE.XML:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.implicitservise"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".ImplicitserviceActivity"
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>
SIMPLE PROGRAMME ON EXPLICIT SERVICE IN ANDROID
ExplicitServiceActivity.java
package com.service;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class ExplicitServiceActivity extends Activity
implements OnClickListener {
/** Called when the activity is first created. */
Button bstart,bstop;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
bstart=(Button)findViewById(R.id.button1);
bstop=(Button)findViewById(R.id.button2);
bstart.setOnClickListener(this);
bstop.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(v.getId()==R.id.button1){
startService(new Intent(this,MyService.class));
}else{
stopService(new Intent(this,MyService.class));
}
}
}
Myservice.java
package com.service;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.widget.Toast;
public class MyService extends Service{
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
Toast.makeText(this, "Service Created...",
Toast.LENGTH_LONG).show();
}
@Override
public void onStart(Intent intent, int startId) {
// TODO Auto-generated method stub
super.onStart(intent, startId);
Toast.makeText(this, "Service Started...",
Toast.LENGTH_LONG).show();
}
@Override
public void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
Toast.makeText(this, "Service Destroyed...",
Toast.LENGTH_LONG).show();
}
}
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.service"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<service android:name=".MyService">
</service>
<activity
android:name=".ExplicitServiceActivity"
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>
package com.service;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class ExplicitServiceActivity extends Activity
implements OnClickListener {
/** Called when the activity is first created. */
Button bstart,bstop;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
bstart=(Button)findViewById(R.id.button1);
bstop=(Button)findViewById(R.id.button2);
bstart.setOnClickListener(this);
bstop.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(v.getId()==R.id.button1){
startService(new Intent(this,MyService.class));
}else{
stopService(new Intent(this,MyService.class));
}
}
}
Myservice.java
package com.service;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.widget.Toast;
public class MyService extends Service{
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
Toast.makeText(this, "Service Created...",
Toast.LENGTH_LONG).show();
}
@Override
public void onStart(Intent intent, int startId) {
// TODO Auto-generated method stub
super.onStart(intent, startId);
Toast.makeText(this, "Service Started...",
Toast.LENGTH_LONG).show();
}
@Override
public void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
Toast.makeText(this, "Service Destroyed...",
Toast.LENGTH_LONG).show();
}
}
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.service"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<service android:name=".MyService">
</service>
<activity
android:name=".ExplicitServiceActivity"
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>
EXAMPLE PROGRAMME ON SERVICE IN ANDROID
ExplicitServiceActivity.java
package com.service;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class ExplicitServiceActivity extends Activity
implements OnClickListener {
/** Called when the activity is first created. */
Button bstart,bstop;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
bstart=(Button)findViewById(R.id.button1);
bstop=(Button)findViewById(R.id.button2);
bstart.setOnClickListener(this);
bstop.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(v.getId()==R.id.button1){
startService(new Intent(this,MyService.class));
}else{
stopService(new Intent(this,MyService.class));
}
}
}
Myservice.java
package com.service;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.widget.Toast;
public class MyService extends Service{
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
Toast.makeText(this, "Service Created...",
Toast.LENGTH_LONG).show();
}
@Override
public void onStart(Intent intent, int startId) {
// TODO Auto-generated method stub
super.onStart(intent, startId);
Toast.makeText(this, "Service Started...",
Toast.LENGTH_LONG).show();
}
@Override
public void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
Toast.makeText(this, "Service Destroyed...",
Toast.LENGTH_LONG).show();
}
}
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.service"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<service android:name=".MyService">
</service>
<activity
android:name=".ExplicitServiceActivity"
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>
package com.service;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class ExplicitServiceActivity extends Activity
implements OnClickListener {
/** Called when the activity is first created. */
Button bstart,bstop;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
bstart=(Button)findViewById(R.id.button1);
bstop=(Button)findViewById(R.id.button2);
bstart.setOnClickListener(this);
bstop.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(v.getId()==R.id.button1){
startService(new Intent(this,MyService.class));
}else{
stopService(new Intent(this,MyService.class));
}
}
}
Myservice.java
package com.service;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.widget.Toast;
public class MyService extends Service{
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
Toast.makeText(this, "Service Created...",
Toast.LENGTH_LONG).show();
}
@Override
public void onStart(Intent intent, int startId) {
// TODO Auto-generated method stub
super.onStart(intent, startId);
Toast.makeText(this, "Service Started...",
Toast.LENGTH_LONG).show();
}
@Override
public void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
Toast.makeText(this, "Service Destroyed...",
Toast.LENGTH_LONG).show();
}
}
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.service"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<service android:name=".MyService">
</service>
<activity
android:name=".ExplicitServiceActivity"
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>
WHAT IS A SERVICE IN ADROID
SERVICE IS A CLASS IN ANDROID,,,,,IT IS RUNNING IN THE BACKGROUND FOR THE ANDROID APPLICATION....
SERVICES ARE TWO TYPES THEY ARE
IMPLCIT SERVICES...
EXPLICIT SERVICES.....
IMPLICIT SERVICES:----
IMPLICIT SERVICES THAT ARE ALLOWED BY SERVICEMANAGER.......
TelephonyManager tm=(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
EXPLICIT SERVICES:-----
EXPLICIT SERVICES ARE ALLOWE WITH EXTENDS WITH THE NAME Service..
WHEN WE ARE EXTENDS WITH THE SERVICE ,,,,,,,
WE NEED TO REGISTER THESE SERVICES WITH THE <service></service>
ExplicitServiceActivity.java
package com.service;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class ExplicitServiceActivity extends Activity
implements OnClickListener {
/** Called when the activity is first created. */
Button bstart,bstop;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
bstart=(Button)findViewById(R.id.button1);
bstop=(Button)findViewById(R.id.button2);
bstart.setOnClickListener(this);
bstop.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(v.getId()==R.id.button1){
startService(new Intent(this,MyService.class));
}else{
stopService(new Intent(this,MyService.class));
}
}
}
Myservice.java
package com.service;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.widget.Toast;
public class MyService extends Service{
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
Toast.makeText(this, "Service Created...",
Toast.LENGTH_LONG).show();
}
@Override
public void onStart(Intent intent, int startId) {
// TODO Auto-generated method stub
super.onStart(intent, startId);
Toast.makeText(this, "Service Started...",
Toast.LENGTH_LONG).show();
}
@Override
public void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
Toast.makeText(this, "Service Destroyed...",
Toast.LENGTH_LONG).show();
}
}
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.service"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<service android:name=".MyService">
</service>
<activity
android:name=".ExplicitServiceActivity"
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>
SERVICES ARE TWO TYPES THEY ARE
IMPLCIT SERVICES...
EXPLICIT SERVICES.....
IMPLICIT SERVICES:----
IMPLICIT SERVICES THAT ARE ALLOWED BY SERVICEMANAGER.......
TelephonyManager tm=(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
EXPLICIT SERVICES:-----
EXPLICIT SERVICES ARE ALLOWE WITH EXTENDS WITH THE NAME Service..
WHEN WE ARE EXTENDS WITH THE SERVICE ,,,,,,,
WE NEED TO REGISTER THESE SERVICES WITH THE <service></service>
ExplicitServiceActivity.java
package com.service;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class ExplicitServiceActivity extends Activity
implements OnClickListener {
/** Called when the activity is first created. */
Button bstart,bstop;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
bstart=(Button)findViewById(R.id.button1);
bstop=(Button)findViewById(R.id.button2);
bstart.setOnClickListener(this);
bstop.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(v.getId()==R.id.button1){
startService(new Intent(this,MyService.class));
}else{
stopService(new Intent(this,MyService.class));
}
}
}
Myservice.java
package com.service;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.widget.Toast;
public class MyService extends Service{
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
Toast.makeText(this, "Service Created...",
Toast.LENGTH_LONG).show();
}
@Override
public void onStart(Intent intent, int startId) {
// TODO Auto-generated method stub
super.onStart(intent, startId);
Toast.makeText(this, "Service Started...",
Toast.LENGTH_LONG).show();
}
@Override
public void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
Toast.makeText(this, "Service Destroyed...",
Toast.LENGTH_LONG).show();
}
}
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.service"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<service android:name=".MyService">
</service>
<activity
android:name=".ExplicitServiceActivity"
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>
A SAMPLE PROGRAMME ON BRDADCAST RECEIVER IN ANDROID
MainActivity.java
package com.example.broadcastreciverex;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.widget.Toast;
public class MainActivity extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
// Second phoneListener = new Second();
Toast.makeText(context, "gahd", 2000).show();
Bundle b = intent.getExtras();
String s = b.getString(TelephonyManager.EXTRA_STATE);
Toast.makeText(context, "hai" + s, 2000).show();
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.broadcastreciverex"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" >
</uses-permission>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<receiver
android:name="com.example.broadcastreciverex.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
</receiver>
</application>
</manifest>
package com.example.broadcastreciverex;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.widget.Toast;
public class MainActivity extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
// Second phoneListener = new Second();
Toast.makeText(context, "gahd", 2000).show();
Bundle b = intent.getExtras();
String s = b.getString(TelephonyManager.EXTRA_STATE);
Toast.makeText(context, "hai" + s, 2000).show();
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.broadcastreciverex"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" >
</uses-permission>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<receiver
android:name="com.example.broadcastreciverex.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
</receiver>
</application>
</manifest>
Thursday, 30 May 2013
A SAMPLE CODE FOR BROADCAST RECIVERS IN ANDROID
MainActivity.java
package com.example.broadcastreciverex;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.widget.Toast;
public class MainActivity extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
// Second phoneListener = new Second();
Toast.makeText(context, "gahd", 2000).show();
Bundle b = intent.getExtras();
String s = b.getString(TelephonyManager.EXTRA_STATE);
Toast.makeText(context, "hai" + s, 2000).show();
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.broadcastreciverex"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" >
</uses-permission>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<receiver
android:name="com.example.broadcastreciverex.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
</receiver>
</application>
</manifest>
package com.example.broadcastreciverex;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.widget.Toast;
public class MainActivity extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
// Second phoneListener = new Second();
Toast.makeText(context, "gahd", 2000).show();
Bundle b = intent.getExtras();
String s = b.getString(TelephonyManager.EXTRA_STATE);
Toast.makeText(context, "hai" + s, 2000).show();
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.broadcastreciverex"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" >
</uses-permission>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<receiver
android:name="com.example.broadcastreciverex.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
</receiver>
</application>
</manifest>
WHAT IS A INTENT FILTER IN ANDROID
INTENT FILTER IN ANDROID ALLOWS THE ACTIONS TO THE
ACTIVITYS,BROADCASTRECIVERS,,,,,
INTENT FILTER IS PRESENT ANDROID MANIFEST FILE,,,,,
THIS FILTER ALLOWS <intent filter>actions</intent filter>
ex:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
ACTIVITYS,BROADCASTRECIVERS,,,,,
INTENT FILTER IS PRESENT ANDROID MANIFEST FILE,,,,,
THIS FILTER ALLOWS <intent filter>actions</intent filter>
ex:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
A SAMPLE OR SIMPLE INTENT PROGRAMME IN ANDROID
MainActivity.java
package com.example.intentex;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity {
Button b1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b1 = (Button) findViewById(R.id.button1);
b1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i = new Intent(MainActivity.this, SecondActivity.class);
startActivity(i);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
SecondActivity.java
package com.example.intentex;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class SecondActivity extends Activity {
Button b2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.second);
b2 = (Button) findViewById(R.id.button2);
b2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub\
Intent i = new Intent(SecondActivity.this, MainActivity.class);
startActivity(i);
}
});
}
}
Android Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.intentex"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.intentex.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>
<activity
android:name=".SecondActivity"/>
</application>
</manifest>
package com.example.intentex;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity {
Button b1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b1 = (Button) findViewById(R.id.button1);
b1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i = new Intent(MainActivity.this, SecondActivity.class);
startActivity(i);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
SecondActivity.java
package com.example.intentex;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class SecondActivity extends Activity {
Button b2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.second);
b2 = (Button) findViewById(R.id.button2);
b2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub\
Intent i = new Intent(SecondActivity.this, MainActivity.class);
startActivity(i);
}
});
}
}
Android Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.intentex"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.intentex.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>
<activity
android:name=".SecondActivity"/>
</application>
</manifest>
WHAT IS A BROADCAST RECIVER IN ANDROID
IN BROADCAST RECIVER,,,IS A CLASS WHICH IS USED TO INTEMATING PURPUSE ...
WHEN WE ARE EXTENDS THE BROADCASTRECIVER WE ARE AUTOMATICALLY GETING THE onReceive() method....
TO WORK WITH THE BROADCAST RECEIVER WE NEED TO REGISTER THIS IN THE MANIFAST FILE
BY USING THE <receiver>
</receiver>tags....
WHEN WE ARE EXTENDS THE BROADCASTRECIVER WE ARE AUTOMATICALLY GETING THE onReceive() method....
TO WORK WITH THE BROADCAST RECEIVER WE NEED TO REGISTER THIS IN THE MANIFAST FILE
BY USING THE <receiver>
</receiver>tags....
WHAT IS THE DIFFERENCE BETWEEN IMPLICIT AND EXPLICIT INTENTS
IMPLICIT_INTENTS:
IMPLICIT INTENT IS THE INTENT ,,,
THAT ALLOWS US TO WORK WITH THE IMPLICIT ACTIONS OF THE DEVICE,,,
THESE ACTIONS ARE ALL STATIC METHODS SO YOU NEED TO CALL THESE
ACTIONS BY USING THE CLASS NAME...Intent...
EX:
Intent i =new Intent( Intent.ACTION_VIEW);
Intent i =new Intent( Intent.ACTION_CALL);
Intent i =new Intent( Intent.ACTION_DIAL);
Intent i =new Intent( Intent.ACTION_VIEW,Uri.parse("http://www.google.com");
HERE ACTION_VIEW,ACTION_CALL,ACTION_DIAL are all the implicit actions
EXPLICIT_INTENTS:
EXPLICIT INTENTS ARE THE INTENTS ,,,THAT ALLOWS THE USER TO JUMP FROM ONE ACTIVITY TO ANOTHER ACTIVITY,,,
EXLPLICIT INTENTS ARE USALLY DEFINED BY EXPLICITLY BY USERS ....
BY USING FOLLOWING SYNTAX:
Intent i = new Intent(ACTIVITY1.this , ACTIVITY2.class);
HERE ACTIVITY1............... MEANS...... CURRENT_ACTIVITY(WHERE YOU ARE NOW) .....
ACTIVITY2 .....MEANS YOU NEED TO SHIFT TO WHERE(WHERE YOU WANT TO JUMP),,,,,
IMPLICIT INTENT IS THE INTENT ,,,
THAT ALLOWS US TO WORK WITH THE IMPLICIT ACTIONS OF THE DEVICE,,,
THESE ACTIONS ARE ALL STATIC METHODS SO YOU NEED TO CALL THESE
ACTIONS BY USING THE CLASS NAME...Intent...
EX:
Intent i =new Intent( Intent.ACTION_VIEW);
Intent i =new Intent( Intent.ACTION_CALL);
Intent i =new Intent( Intent.ACTION_DIAL);
Intent i =new Intent( Intent.ACTION_VIEW,Uri.parse("http://www.google.com");
HERE ACTION_VIEW,ACTION_CALL,ACTION_DIAL are all the implicit actions
EXPLICIT_INTENTS:
EXPLICIT INTENTS ARE THE INTENTS ,,,THAT ALLOWS THE USER TO JUMP FROM ONE ACTIVITY TO ANOTHER ACTIVITY,,,
EXLPLICIT INTENTS ARE USALLY DEFINED BY EXPLICITLY BY USERS ....
BY USING FOLLOWING SYNTAX:
Intent i = new Intent(ACTIVITY1.this , ACTIVITY2.class);
HERE ACTIVITY1............... MEANS...... CURRENT_ACTIVITY(WHERE YOU ARE NOW) .....
ACTIVITY2 .....MEANS YOU NEED TO SHIFT TO WHERE(WHERE YOU WANT TO JUMP),,,,,
WHAT IS EXPLICI INTENT IN ANDROID
EXPLICIT INTENTS ARE THE INTENTS ,,,THAT ALLOWS THE USER TO JUMP FROM ONE ACTIVITY TO ANOTHER ACTIVITY,,,
EXLPLICIT INTENTS ARE USALLY DEFINED BY EXPLICITLY BY USERS ....
BY USING FOLLOWING SYNTAX:
Intent i = new Intent(ACTIVITY1.this , ACTIVITY2.class);
HERE ACTIVITY1............... MEANS...... CURRENT_ACTIVITY(WHERE YOU ARE NOW) .....
ACTIVITY2 .....MEANS YOU NEED TO SHIFT TO WHERE(WHERE YOU WANT TO JUMP),,,,,
EXLPLICIT INTENTS ARE USALLY DEFINED BY EXPLICITLY BY USERS ....
BY USING FOLLOWING SYNTAX:
Intent i = new Intent(ACTIVITY1.this , ACTIVITY2.class);
HERE ACTIVITY1............... MEANS...... CURRENT_ACTIVITY(WHERE YOU ARE NOW) .....
ACTIVITY2 .....MEANS YOU NEED TO SHIFT TO WHERE(WHERE YOU WANT TO JUMP),,,,,
WHAT IS A IMPLICIT INTENT IN ANDROID
IMPLICIT INTENT IS THE INTENT ,,,
THAT ALLOWS US TO WORK WITH THE IMPLICIT ACTIONS OF THE DEVICE,,,
THESE ACTIONS ARE ALL STATIC METHODS SO YOU NEED TO CALL THESE
ACTIONS BY USING THE CLASS NAME...Intent...
EX:
Intent i =new Intent( Intent.ACTION_VIEW);
Intent i =new Intent( Intent.ACTION_CALL);
Intent i =new Intent( Intent.ACTION_DIAL);
Intent i =new Intent( Intent.ACTION_VIEW,Uri.parse("http://www.google.com");
HERE ACTION_VIEW,ACTION_CALL,ACTION_DIAL are all the implicit actions
THAT ALLOWS US TO WORK WITH THE IMPLICIT ACTIONS OF THE DEVICE,,,
THESE ACTIONS ARE ALL STATIC METHODS SO YOU NEED TO CALL THESE
ACTIONS BY USING THE CLASS NAME...Intent...
EX:
Intent i =new Intent( Intent.ACTION_VIEW);
Intent i =new Intent( Intent.ACTION_CALL);
Intent i =new Intent( Intent.ACTION_DIAL);
Intent i =new Intent( Intent.ACTION_VIEW,Uri.parse("http://www.google.com");
HERE ACTION_VIEW,ACTION_CALL,ACTION_DIAL are all the implicit actions
Wednesday, 22 May 2013
WHAT IS A INTENT IN ANDROID
INTENT IS A CLASS THAT ALLOWS TO SWITCH FROM ONE ACTIVITY TO ANOTHER ACTIVITY,,,
IN ANDROID TWO TYPES OF INTENTS ARE AVAILABLE...
THEY ARE IMPLICITINTENT,AND EXPLICIT INTENT,,,
-->
IMPLICIT INTENTS ARE USED FOR USING THE IMPLICIT ACTIONS,,,
THESE ACTIONS ARE ALL STATIC METHODS .SO WE NEED CALL THESE ACTIONS BY USING THE CLASS NAME ..IS Intent ..
-->
EXPLICIT INTENTS ARE THE INTENTS WHICH ARE USED TO SWITCH FROM ONE ACTIVITY TO ANOTHER ACTIVITY,,BY THE USER SPECIFACTIONS...
--->
PENDING INTENT IS THE ALSO A EXPLICITINTENT CALL THIS INTENT TO INVOKE THE ACTION LATERTIME.BY THE USER REQUIREMENT
IN ANDROID TWO TYPES OF INTENTS ARE AVAILABLE...
THEY ARE IMPLICITINTENT,AND EXPLICIT INTENT,,,
-->
IMPLICIT INTENTS ARE USED FOR USING THE IMPLICIT ACTIONS,,,
THESE ACTIONS ARE ALL STATIC METHODS .SO WE NEED CALL THESE ACTIONS BY USING THE CLASS NAME ..IS Intent ..
-->
EXPLICIT INTENTS ARE THE INTENTS WHICH ARE USED TO SWITCH FROM ONE ACTIVITY TO ANOTHER ACTIVITY,,BY THE USER SPECIFACTIONS...
--->
PENDING INTENT IS THE ALSO A EXPLICITINTENT CALL THIS INTENT TO INVOKE THE ACTION LATERTIME.BY THE USER REQUIREMENT
HOW THE .DEX FILE IS GENERATED IN ANDROID
IN ANDROID SDK WE HAVE DX TOOLS,,,,
DX TOOL IS TAKE THE RESPONSIBILITY TOMAKE THE .DEX FILE..IN ANDROID
DX TOOL IS TAKE THE RESPONSIBILITY TOMAKE THE .DEX FILE..IN ANDROID
WHAT ARE THE MOBILES THAT ARE SUPPORTED BY ANDROID
HTC,LG,MOTOROLA,SONY ERRICSUN,BELL,CISCO,ACER,HP,TABILBS..
WHAT IS THE NAME OF ANDRODI SYMBOL ?
New in Labs: Green robot icon
Gmail chat status
(those green, orange, and red bubbles) indicates if your friends are
online or not. But sometimes my buddies appear green when they're not
really "online online" — they just have chat open on their Android
phones.
Turn on Green Robot, a new experiment in Gmail Labs, and you'll see a robot icon next to people who are currently using Android phones. In the case below, Shirley is online with Android, Nicolle R. is using regular Gmail chat, and Chris I. is currently away but also on Android. Slatka is not an angry robot — she's online with Android but currently busy.

These icons can help you decide whether to tailor your conversation to the type of device that your chat buddy is using. For example, when you know the guy on the other end is using his Android phone, you may decide to send shorter, more concise chat messages.
When your chat buddies log into Gmail, their presence icons will revert to the traditional red, green, and orange status bubbles. In addition, if your chat buddy happens to be logged into both Gmail and Android chat then the traditional Gmail status icons will be shown. Try it out and let us know what you think.
Turn on Green Robot, a new experiment in Gmail Labs, and you'll see a robot icon next to people who are currently using Android phones. In the case below, Shirley is online with Android, Nicolle R. is using regular Gmail chat, and Chris I. is currently away but also on Android. Slatka is not an angry robot — she's online with Android but currently busy.

These icons can help you decide whether to tailor your conversation to the type of device that your chat buddy is using. For example, when you know the guy on the other end is using his Android phone, you may decide to send shorter, more concise chat messages.
When your chat buddies log into Gmail, their presence icons will revert to the traditional red, green, and orange status bubbles. In addition, if your chat buddy happens to be logged into both Gmail and Android chat then the traditional Gmail status icons will be shown. Try it out and let us know what you think.
WHY ACTIVITY IS USED IN ANDROID PROGRAMME ?
Activity is a simply a class which is one of the builder for the android application developement..
The main theme of the Activity is used Load the UserInterFace ..
and Visualise the UserInterFace..
The main theme of the Activity is used Load the UserInterFace ..
and Visualise the UserInterFace..
WHAT IS A ACTIVITY IN ANDROID ?
Activity is a simply a class which is one of the builder for the android application developement..
The main theme of the Activity is used Load the UserInterFace ..
and Visualise the UserInterFace..
The main theme of the Activity is used Load the UserInterFace ..
and Visualise the UserInterFace..
Tuesday, 21 May 2013
SIMPLE ANDROID CODE
HaiAndroidActivity.java
package com.fr.gh;
import android.app.Activity;
import android.os.Bundle;
public class HaiandroidActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
</LinearLayout>
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fr.gh"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".HaiandroidActivity"
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>
package com.fr.gh;
import android.app.Activity;
import android.os.Bundle;
public class HaiandroidActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
</LinearLayout>
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fr.gh"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".HaiandroidActivity"
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>
SAMPLE ANDROID PROGRAMME
HaiandroidActivity.java
package com.fr.gh;
import android.app.Activity;
import android.os.Bundle;
public class HaiandroidActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
main.xml
package com.fr.gh;
import android.app.Activity;
import android.os.Bundle;
public class HaiandroidActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fr.gh"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".HaiandroidActivity"
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>
package com.fr.gh;
import android.app.Activity;
import android.os.Bundle;
public class HaiandroidActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
main.xml
package com.fr.gh;
import android.app.Activity;
import android.os.Bundle;
public class HaiandroidActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fr.gh"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".HaiandroidActivity"
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>
SIMPLE EXAMPLE ON ANDROID ACTIVITY
MainActivity.java
package com.fr.gh;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
</LinearLayout>
Manifestfile.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fr.gh"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".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>
package com.fr.gh;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
</LinearLayout>
Manifestfile.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fr.gh"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".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>
SAMPLE ANDROID PROGRAMME
Main.JAVA
package com.fr.gh;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/haiandroid" />
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/haiandroid" />
</LinearLayout>
Subscribe to:
Posts (Atom)