Intent和PendingIntent
2011-05-04 17:53
253 查看
1.Intent是及时启动的,它随着它所在的Activity消失而消失。
Intent一般用作Activity、Service、BroadcastReceiver之间传递数据。
2.PendingIntent是延时执行的Intent。
PendingIntent通常是由getActivity、getBroadcast、getService来获取实例的。当前的Activity不能马上启动它所包含的Intent,而由外部执行PendingIntent时,调用它所包含的Intent。
PendingIntent保存有当前App的Context,使得它可以赋予外部App一种能力,让外部App如同当前App一样执行PendingIntent中的Intent,即使当前App已经不存在了。
Intent一般用作Activity、Service、BroadcastReceiver之间传递数据。
Intent reg = new Intent("com.hp.ui.ScreenHome"); reg.putExtra("method", "call"); reg.putExtra("number", phoneNum); Main.this.sendBroadcast(reg);
2.PendingIntent是延时执行的Intent。
PendingIntent通常是由getActivity、getBroadcast、getService来获取实例的。当前的Activity不能马上启动它所包含的Intent,而由外部执行PendingIntent时,调用它所包含的Intent。
PendingIntent保存有当前App的Context,使得它可以赋予外部App一种能力,让外部App如同当前App一样执行PendingIntent中的Intent,即使当前App已经不存在了。
private Notification newNotification; AlarmManager alarms; PendingIntent alarmIntent; String tickerText = "Here is a New TNews"; long when = System.currentTimeMillis(); newTNewsNotification = new Notification(R.drawable.icon, tickerText, when); alarms = (AlarmManager)getSystemService(Context.ALARM_SERVICE); String ALARM_ACTION; ALARM_ACTION = TNewsAlarmReceiver.ACTION_REFRESH_TNEWS_ALARM; Intent intentToFire = new Intent(ALARM_ACTION); alarmIntent = PendingIntent.getBroadcast(this, 0, intentToFire, 0);
相关文章推荐
- Intent和PendingIntent的区别
- pendingIntent初步_什么是pendingIntent
- 【Android 界面效果24】Intent和PendingIntent的区别
- Intent和PendingIntent的区别
- Intent与PendingIntent的区别
- Android Intent和PendingIntent的区别详细分析
- Intent和PendingIntent的区别【转】
- Android Intent和PendingIntent的区别
- PendingIntent和Intent的区别
- [转]Intent和PendingIntent的区别
- Intent和PendingIntent的区别
- IntentFilter,PendingIntent
- Intent和PendingIntent的区别
- Intent和PendingIntent的区别
- Intent和PendingIntent的关系
- Intent和PendingIntent的区别
- PendingIntent(延迟执行的 Intent)
- Android Intent和PendingIntent的区别详细分析
- Intent和PendingIntent的区别
- Intent和PendingIntent的区别