【发布时间】:2014-08-17 02:47:03
【问题描述】:
由于某种原因,我收到了NullPointerException。我已经浏览了有关此问题的所有帖子。我想知道我在这里错过了什么。
我打算调用一个服务,该服务将调用警报管理器来激活应在特定时间(而不是持续时间)调用的延迟意图。
活动代码,调用服务
autoBookingIntent = new Intent(this,
ScheduleAdvanceBookingService.class);
autoBookingIntent.putExtra("startTime", startTime);
autoBookingIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startService(autoBookingIntent) ;
清单
<service
android:name="com.taxeeta.ScheduleAdvanceBookingService"
android:enabled="true"
android:label="@string/app_name"
android:theme="@android:style/Theme.Light.NoTitleBar" />
ScheduleAdvanceBookingService 代码
此处例外==>
package com.taxeeta;
public ScheduleAdvanceBookingService() {
super("ScheduleAdvanceBookingService");
}
@Override
protected void onHandleIntent(Intent intent) {
Intent newIntent = new Intent(this, AutoAdvanceBooking.class);
**==>**newIntent.putExtra("sourceLng",
intent.getDoubleExtra("sourceLng", (Double) null));
Date startTime = (Date) intent.getSerializableExtra("startTime");
newIntent.putExtra("startTime", startTime);
autoBookingAlarm = (AlarmManager) this
.getSystemService(Context.ALARM_SERVICE);
autoBookingPendingIntent = PendingIntent.getBroadcast(this, 0,
newIntent, PendingIntent.FLAG_UPDATE_CURRENT);
autoBookingAlarm.set(AlarmManager.RTC_WAKEUP, startTime.getTime(),
autoBookingPendingIntent);
God.setAdvanceBookingNotification(this, God.CREATE_NOTIFICATION,
startTime);
}
为什么intent为空?
【问题讨论】:
标签: android service broadcastreceiver alarmmanager android-pendingintent