我无法让我的闹钟管理员开始我的服务。
private PendingIntent mAlarmSender;
mAlarmSender = PendingIntent.getService(MeetingManager.this,0, new Intent(MeetingManager.this, UpdateData.class), 0);
long firstTime = SystemClock.elapsedRealtime();
AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE);
am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstTime, 1*100, mAlarmSender);
我每隔5分钟就会在LogCat中看到以下内容。不确定它是否与问题有关。
12-13 11:16:17.104: DEBUG/SntpClient(58): request time failed: java.net.SocketException: Address family not supported by protocol
以下是我的UpdateData类:
package com.MeetingManager;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
public class UpdateData extends Service {
public static final String PREFS_NAME = "MyAppData";
private static final String TAG = "MyApp";
public void onCreate(Bundle savedInstanceState) {
super.onCreate();
Log.d(TAG, "HELLO");
}
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
Log.d(TAG, "NOT HELLO ");
return null;
}
}
以下是我的清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.MeetingManager"
android:versionCode="2"
android:versionName="2.0">
<uses-sdk android:minSdkVersion="8" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".GetRoom"
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=".MeetingManager"></activity>
<activity android:name=".XMLfunctions"></activity>
<activity android:name=".CreateMeeting"></activity>
<service android:enabled="true" android:name=".UpdateData" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>