Java Android.os.HandleIntent调用intent服务时没有附加值
我正在开发android应用程序,以便在后台获取用户活动。这是我的密码Java Android.os.HandleIntent调用intent服务时没有附加值,java,android,intentservice,android-os-handler,Java,Android,Intentservice,Android Os Handler,我正在开发android应用程序,以便在后台获取用户活动。这是我的密码 public class ActivityRecognitionService extends IntentService implements GooglePlayServicesClient.ConnectionCallbacks,GooglePlayServicesClient.OnConnectionFailedListener { AbstractWrapper w = null; private Pendin
public class ActivityRecognitionService extends IntentService implements GooglePlayServicesClient.ConnectionCallbacks,GooglePlayServicesClient.OnConnectionFailedListener {
AbstractWrapper w = null;
private PendingIntent pIntent;
private VSensorConfig config = null;
private ActivityRecognitionClient arclient;
private static final String DATE_FORMAT_PATTERN = "yyyy-MM-dd HH:mm:ss.SSSZ";
private static final String LOG_DELIMITER = ";;";
private SimpleDateFormat mDateFormat;
public ActivityRecognitionService() {
super("ActivityRecognitionIntentService");
}
@Override
protected void onHandleIntent(Intent intent) {
Bundle b = intent.getExtras();
config = (VSensorConfig) b.get("config");
try {
mDateFormat = (SimpleDateFormat) DateFormat.getDateTimeInstance();
} catch (Exception e) {
}
mDateFormat.applyPattern(DATE_FORMAT_PATTERN);
mDateFormat.applyLocalizedPattern(mDateFormat.toLocalizedPattern());
int resp =GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
arclient = new ActivityRecognitionClient(this, this, this);
arclient.connect();
if (ActivityRecognitionResult.hasResult(intent)) {
ActivityRecognitionResult result = ActivityRecognitionResult.extractResult(intent);
Log.i("Activity Recived :DDDD", getType(result.getMostProbableActivity().getType()) +"\t" + result.getMostProbableActivity().getConfidence());
DetectedActivity mostProbableActivity = result.getMostProbableActivity();
Double confidence = (double) mostProbableActivity.getConfidence();
Double activityType = (double) mostProbableActivity.getType();
for (InputStream inputStream : config.getInputStreams()) {
for (StreamSource streamSource : inputStream.getSources()) {
w = streamSource.getWrapper();
break;
}
break;
}
((AndroidActivityRecognitionWrapper) w).getLastKnownData();
}
}
private boolean activityChanged(int currentType) {
return false;
}
@Override
public void onConnectionFailed(ConnectionResult arg0) {
// TODO Auto-generated method stub
}
@Override
public void onConnected(Bundle arg0) {
Intent intent = new Intent(this, ActivityRecognitionService.class);
pIntent = PendingIntent.getService(this, 0, intent,PendingIntent.FLAG_UPDATE_CURRENT);
arclient.requestActivityUpdates(1000, pIntent);
}
@Override
public void onDisconnected() {
// TODO Auto-generated method stub
}
}
问题是Android.os.HandleThread类调用在没有额外值的情况下启动此意图,因此我得到了nullPointerException。有人能帮我吗?什么样的手?什么意图?我已经打印了堆栈跟踪,发现我的类不在跟踪中,堆栈中的第一个Obj是针对Android.os.HandletThread的。我得到了null的配置,但我在调用服务时设置了它。我试图在onHandleIntent中记录.d意图?@pskink这是什么意思?