If you think the Android project Fall_Prevention_2013 listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*******************************************************************************
* Licensed to UbiCollab.org under one or more contributor
* license agreements. See the NOTICE file distributed
* with this work for additional information regarding
* copyright ownership. UbiCollab.org licenses this file
* to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* /*fromwww.java2s.com*/
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
******************************************************************************/package ntnu.stud.valens.stepdetector;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
/**
* The StepMainServiceStarter ensures is a on-boot broadcast receiver, so it is
* started when the mobile boots. It's function is to start the step detector
* service.
*
* @author Elias
*
*/publicclass StepMainServiceStarter extends BroadcastReceiver {
publicstaticfinal String TAG = "StepMainServiceStarter";
@Override
publicvoid onReceive(Context context, Intent intent) {
// Make sure to only start if the broadcast was on-boot.
if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {
ComponentName comp = new ComponentName(context.getPackageName(),
StepMainService.class.getName());
ComponentName service = context.startService(new Intent()
.setComponent(comp));
if (null == service) {
// This should really not happen. This is bad.
Log.e(TAG, "Could not start service " + comp.toString());
}
} else {
Log.e(TAG, "Received unexpected intent " + intent.toString());
}
}
}