Normal Intent
Normal Intent will die as soon as the app being killed.
An Android Intent is an object carrying an intent, i.e a message from one Component to another
Component either inside or outside of the application.Intent can communicate message among
any of the three core Components of an application -- Activities, Services,and BroadcastReceivers.
Two types of Intent in Android
1. Explicit Intent.
2.Implicit Intent
Explicit Intent is an Intent which is used to Call the another component Explicitly in your application
Like :We are calling Next activity on button click of First activity using Intent
Example
Like:- We are calling Webpage in your Activity
Example
Pending intents
Two types of Intent in Android
1. Explicit Intent.
2.Implicit Intent
Explicit Intent is an Intent which is used to Call the another component Explicitly in your application
Like :We are calling Next activity on button click of First activity using Intent
Example
// Explicit Intent by specifying its class name
Intent i = new Intent(this, TargetActivity.class);
i.putExtra("Key1", "ABC");
i.putExtra("Key2", "123");
// Starts TargetActivity
startActivity(i);
Implicit Intent Intent is use to call Intent with in the Single ActicityLike:- We are calling Webpage in your Activity
Example
// Implicit Intent by specifying a URI
Intent i = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://www.example.com"));
// Starts Implicit Activity
startActivity(i);
Pending intents
Pending Intents never die .They will be alive as long as it needed by Alarm Service, Location
Service or any other Services.
A pending intent is a token that you give to another application.For example, the notification
manager, alarm manger or the other 3rd party applications). This allows the other application to
restore the permissions of your application to execute a predefined piece of code.
A pending intent is a token that you give to another application.For example, the notification
manager, alarm manger or the other 3rd party applications). This allows the other application to
restore the permissions of your application to execute a predefined piece of code.
The meaning of Pending intent is that ,you can handle it to other Application that later can be use it
as Youself.
as Youself.
Example
Calendar cal = Calendar.getInstance();
Intent intent = new Intent(this, MyService.class);
PendingIntent pintent = PendingIntent.getService(this, 0, intent, 0);
AlarmManager alarm = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
alarm.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 30*1000, pintent);
Nice article..
ReplyDeleteandroid online training
Awesome
ReplyDeleteThe distinction between Pending Intent and Intent lies in their purposes within Android development. How Use VPN While both encapsulate an action to be performed, Pending Intent defers execution until a later time, often for use in notifications.
ReplyDelete