Compare commits

...

10 Commits

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="11" />
</component>
</project>

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="BintrayJCenter" />
<option name="name" value="BintrayJCenter" />
<option name="url" value="https://jcenter.bintray.com/" />
</remote-repository>
<remote-repository>
<option name="id" value="Google" />
<option name="name" value="Google" />
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
</remote-repository>
</component>
</project>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

@ -0,0 +1,35 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '25.0.2'
defaultConfig {
applicationId 'com.example.cauc.falldetecion'
minSdkVersion 23
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
api fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
api 'com.android.support:appcompat-v7:23.4.0'
testImplementation 'junit:junit:4.12'
api 'com.android.support:design:23.2.0'
api 'de.hdodenhof:circleimageview:2.1.0'
api 'com.github.zcweng:switch-button:0.0.3@aar'
api files('libs/AMap3DMap_4.1.3_AMapLocation_3.2.0_20161208.jar')
}

@ -0,0 +1,16 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

@ -0,0 +1,26 @@
package com.example.cauc.falldetecion;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.example.wellxiang.falldetecion", appContext.getPackageName());
}
}

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.cauc.falldetecion">
<!--允许手机发送SMS短息-->
<uses-permission android:name="android.permission.SEND_SMS" />
<!--允许手机振动-->
<uses-permission android:name="android.permission.VIBRATE" />
<!-- 允许一个程序打开窗口使用 TYPE_SYSTEM_ALERT显示在其他所有程序的顶层 -->
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<!-- 文本转语音相关权限 -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- 用于进行网络定位 -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!-- 用于访问GPS定位 -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- 用于获取运营商信息,用于支持提供运营商信息相关的接口 -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- 用于访问wifi网络信息wifi信息会用于进行网络定位 -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<!-- 用于获取wifi的获取权限wifi信息会用来进行网络定位 -->
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<!-- 用于访问网络,网络定位需要上网 -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- 用于读取手机当前的状态 -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!-- 用于写入缓存数据到扩展存储卡 -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- 用于申请调用A-GPS模块 -->
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<!-- 用于申请获取蓝牙信息进行室内定位 -->
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_app"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data
android:name="com.amap.api.v2.apikey"
android:value="10ecc604d6bb7d83f90c74709be1d238" />
<activity
android:name="com.example.cauc.falldetecion.MainActivity"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.example.cauc.falldetecion.MapActivity" />
<service android:name="com.amap.api.location.APSService" />
<service
android:name="com.example.cauc.falldetecion.FallDetectionService"
android:enabled="true"
android:exported="true" />
<receiver
android:name="com.example.cauc.falldetecion.FallLocalReceiver"
android:enabled="true"
android:exported="true">
</receiver>
</application>
</manifest>

@ -0,0 +1,83 @@
package com.example.cauc.falldetecion;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.view.WindowManager;
import android.widget.TextView;
import java.util.Timer;
import java.util.TimerTask;
public class AlertDialogFragment extends DialogFragment {
private TextView textView;
private AlertDialog.Builder builder;
private AlertDialog alertDialog;
private Timer timer;
private Handler handler;
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
textView = new TextView(getContext());
builder = new AlertDialog.Builder(getActivity())
.setTitle("跌倒警报")
.setView(textView)
.setMessage("检测到跌倒发生,是否发出警报?")
.setIcon(R.drawable.ic_warning)
.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dismiss();
}
});
alertDialog = builder.create();
alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
alertDialog.setCanceledOnTouchOutside(false);
countDown();
handler = new Handler(){
@Override
public void handleMessage(Message msg) {
if(msg.what > 0){
Log.v("time", msg.what + "");
//动态显示倒计时
textView.setText(" " + msg.what + "秒后自动报警");
}else{
//倒计时结束自动关闭
if(alertDialog != null){
alertDialog.dismiss();
Log.d("Shawn","alertDialog.dismiss()");
}
timer.cancel();
Log.d("Shawn", "timer.cancel()");
}
}
};
return alertDialog;
}
private void countDown(){
Log.d("Shawn", "CountDown()");
timer = new Timer();
TimerTask timerTask = new TimerTask() {
int countTime = 8;
@Override
public void run() {
if (countTime > 0){
countTime --;
}
Message msg = handler.obtainMessage();
msg.what = countTime;
handler.sendMessage(msg);
}
};
timer.schedule(timerTask, 100, 1000);
}
}

@ -0,0 +1,158 @@
package com.example.cauc.falldetecion;
import android.util.Log;
public class Fall{
private float highThresholdValue;
private float lowThresholdValue;
// private int SENSOR_RATE;
private boolean isFell;
public static float[] svmData;
public static float[] svmFilteringData;
public static int svmCount = 0;
public static final String TAG = "cauc";
public Fall(){
svmData = new float[150];
svmFilteringData = new float[150];
isFell = false;
}
/*
*/
public void setThresholdValue(float highThreshold, float lowThreshold){
this.highThresholdValue = highThreshold;
this.lowThresholdValue = lowThreshold;
Log.d(TAG, highThreshold + " " + lowThreshold);
}
/*
*/
// public void setSENSOR_RATE(int sensor_rate){
// SENSOR_RATE = sensor_rate;
// }
/*
*/
public void fallDetection(){
Log.d(TAG, "Fall.fallDetection()");
new Thread(new Runnable() {
@Override
public void run() {
boolean running = true;
while(running){
//阈值法
for(int i = 0; i < svmFilteringData.length; i++){
if(svmFilteringData[i] <= lowThresholdValue){
if(i < svmFilteringData.length-10){
for (int j = i; j < i + 10; j++) {
if (svmFilteringData[j] >= highThresholdValue) {
running = false;
setFell(true);
}
}
}else {
for (int j = i; j < svmFilteringData.length; j++) {
if (svmFilteringData[j] >= highThresholdValue) {
running = false;
setFell(true);
}
}
for (int k = 0; k < (10-(svmFilteringData.length - i)); k++){
if (svmFilteringData[k] >= highThresholdValue) {
running = false;
setFell(true);
}
}
}
}
}
}
}
}).start();
}
/*
3ssvm
*/
public static void svmCollector(float svm){
if(svmCount < svmData.length){
svmData[svmCount] = svm;
}else{
svmCount = 0;
svmData[svmCount] = svm;
}
svmCount++;
// Log.d(TAG, "Fall.svmCollector" + svmData[svmCount]);
}
/*
svm
*/
public static void setSvmFilteringData(){
//中值滤波取的三个值
float s1, s2, s3, temp;
//冒泡排序
for (int i = 0; i < svmFilteringData.length-1; i++){
if(i == 0){
s1 = svmData[i];
s2 = svmData[i + 1];
s3 = svmData[i + 2];
}else if(i < svmFilteringData.length-2){
s1 = svmData[i - 1];
s2 = svmData[i];
s3 = svmData[i + 1];
}else{
s1 = svmData[i - 1];
s2 = svmData[i];
s3 = svmData[0];
}
if(s1 > s2){
temp = s1;
s1 = s2;
s2 = temp;
}
if(s2 > s3){
temp = s2;
s2 = s3;
s3 = temp;
}
svmFilteringData[i] = s2;
Log.d(TAG, s1 + " " + s2 + " " + s3);
// Log.d(TAG, "Fall.setSvmFilteringData" + svmFilteringData[i]);
}
}
public boolean isFell() {
// Log.e(TAG, "isFELL" + isFell);
return isFell;
}
public void setFell(boolean fell) {
isFell = fell;
// Log.e(TAG, "setFELL" + isFell);
}
public void cleanData(){
Log.d(TAG , "Fall.clean()");
for (int i = 0; i < svmData.length; i++){
svmData[i] = 0;
}
//中值滤波
for (int i = 0; i < svmFilteringData.length; i++){
svmFilteringData[i] = 0;
}
}
}

@ -0,0 +1,213 @@
package com.example.cauc.falldetecion;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.Notification;
import android.app.PendingIntent;
import android.app.Service;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.BitmapFactory;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.support.v4.app.NotificationCompat;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import android.view.WindowManager;
import android.widget.TextView;
import java.util.Timer;
import java.util.TimerTask;
public class FallDetectionService extends Service {
private FallSensorManager fallSensorManager;
public Fall fall;
private final int FELL = 0;
private final int TIME = 1;
private boolean running = false;
private TextView countingView;
private Dialog dialog;
private Timer timer;
private final String TAG = "FallDetection";
private DetectThread detectThread;
private IntentFilter intentFilter;
private LocalBroadcastManager localBroadcastManager;
private FallLocalReceiver fallLocalReceiver;
public FallDetectionService() {
}
@Override
public IBinder onBind(Intent intent) {
// TODO: Return the communication channel to the service.
throw new UnsupportedOperationException("Not yet implemented");
}
@Override
public void onCreate() {
super.onCreate();
Log.d(TAG, "FallDetectionService.onCreate()");
fallSensorManager = new FallSensorManager(this);
fallSensorManager.initSensor();
fallSensorManager.registerSensor();
fall = new Fall();
fall.setThresholdValue(25,5);
running = true;
//在通知栏上显示服务运行
showInNotification();
localBroadcastManager = LocalBroadcastManager.getInstance(this);
intentFilter = new IntentFilter();
intentFilter.addAction("com.broadcast.FALL_LOCAL_BROADCAST");
fallLocalReceiver = new FallLocalReceiver();
localBroadcastManager.registerReceiver(fallLocalReceiver, intentFilter);
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.d(TAG, "FallDetectionService.onStartCommand");
detectThread = new DetectThread();
detectThread.start();
return super.onStartCommand(intent, flags, startId);
}
@Override
public void onDestroy() {
fallSensorManager.unregisterSensor();
localBroadcastManager.unregisterReceiver(fallLocalReceiver);
super.onDestroy();
}
//开一个线程用于检测跌倒
class DetectThread extends Thread{
@Override
public void run() {
fall.fallDetection();
Log.d(TAG, "DetectThread.start()");
while (running) {
if (fall.isFell()) {
Log.e(TAG, "跌倒了");
running = false;
Message msg = handler.obtainMessage();
msg.what = FELL;
handler.sendMessage(msg);
fall.setFell(false);
fall.cleanData();
stopSelf();
}
}
}
}
private Handler handler = new Handler(){
@Override
public void handleMessage(Message msg) {
switch(msg.what){
case FELL:
Log.e(TAG, "FELL");
//报警
showAlertDialog();
Intent intent = new Intent("com.broadcast.FALL_LOCAL_BROADCAST");
localBroadcastManager.sendBroadcast(intent);
break;
case TIME:
if(msg.arg1 > 0){
//动态显示倒计时
countingView.setText(" "
+ msg.arg1 + "秒后自动报警");
}else{
//倒计时结束自动关闭
if(dialog != null){
dialog.dismiss();
}
timer.cancel();
}
break;
}
}
};
/*
*/
private void showAlertDialog() {
countingView = new TextView(getApplicationContext());
AlertDialog.Builder builder = new AlertDialog.Builder(
getApplicationContext());
builder.setTitle("跌倒警报");
builder.setView(countingView);
builder.setMessage("检测到跌倒发生,是否发出警报?");
builder.setIcon(R.drawable.ic_warning);
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
timer.cancel();
dialog.dismiss();
running = true;
Log.d(TAG, running + "");
detectThread.interrupt();
detectThread = null;
if(detectThread == null){
detectThread = new DetectThread();
detectThread.start();
}
}
});
dialog = builder.create();
dialog.setCanceledOnTouchOutside(false);
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
countDown();
dialog.show();
Log.d(TAG, "dialog.create()");
}
/*
*/
private void countDown() {
timer = new Timer();
TimerTask timerTask = new TimerTask() {
int countTime = 6;
@Override
public void run() {
if(countTime > 0){
countTime --;
}
Message msgTime = handler.obtainMessage();
msgTime.what = TIME;
msgTime.arg1 = countTime;
handler.sendMessage(msgTime);
}
};
timer.schedule(timerTask, 100, 1000);
}
/*
*/
private void showInNotification() {
Intent intent = new Intent(this,MainActivity.class);
PendingIntent pi = PendingIntent.getActivity(this, 0, intent, 0);
Notification notification = new NotificationCompat.Builder(this)
.setContentTitle("老人跌到检测")
.setContentText("老人跌倒检测正在运行")
.setWhen(System.currentTimeMillis())
.setSmallIcon(R.drawable.ic_app)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_app))
.setContentIntent(pi)
.build();
startForeground(1,notification);
}
}

@ -0,0 +1,329 @@
package com.example.cauc.falldetecion;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.location.Address;
import android.location.Geocoder;
import android.location.Location;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.Vibrator;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;
import android.telephony.SmsManager;
import android.util.Log;
import android.view.WindowManager;
import android.widget.TextView;
import android.widget.Toast;
import android.Manifest;
import android.content.pm.PackageManager;
import android.location.Address;
import android.location.Geocoder;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;
import com.amap.api.location.AMapLocation;
import com.amap.api.location.AMapLocationClient;
import com.amap.api.location.AMapLocationClientOption;
import com.amap.api.location.AMapLocationListener;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Timer;
import java.util.TimerTask;
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.OnInitListener;
public class FallLocalReceiver extends BroadcastReceiver implements AMapLocationListener,LocationListener {
private TextView countingView;
private Dialog dialog;
private Timer timer;
private SharedPreferences sharedPreferences;
private Vibrator vibrator;
private boolean isVibrate;
private MediaPlayer mediaPlayer;
private AMapLocationClient locationClient;
private AMapLocationClientOption locationClientOption;
public String locationAddress;
public String locationTime;
private Context context;
private final String TAG = "FallDetection";
public FallLocalReceiver() {
}
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "FallLocalReceiver.onReceive()");
this.context = context;
showAlertDialog();
sharedPreferences = PreferenceManager
.getDefaultSharedPreferences(context);
isVibrate = sharedPreferences.getBoolean("pre_key_vibrate", true);
if(isVibrate){
startVibrate();
}
startAlarm();
startLocation();
}
/*
*/
private void showAlertDialog() {
countingView = new TextView(context);
AlertDialog.Builder builder = new AlertDialog.Builder(
context.getApplicationContext());
builder.setTitle("跌倒警报");
builder.setView(countingView);
builder.setMessage("检测到跌倒发生,是否发出警报?");
builder.setIcon(R.drawable.ic_warning);
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
timer.cancel();
dialog.dismiss();
if(isVibrate){
stopVibrate();
}
stopAlarm();
Intent startIntent = new Intent(context, FallDetectionService.class);
context.startService(startIntent);
}
});
dialog = builder.create();
dialog.setCanceledOnTouchOutside(false);
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
countDown();
dialog.show();
Log.d(TAG, "dialog.create()");
}
/*
*/
private void countDown() {
timer = new Timer();
TimerTask timerTask = new TimerTask() {
int countTime = 10;
@Override
public void run() {
if(countTime > 0){
countTime --;
}
Message msgTime = handler.obtainMessage();
msgTime.arg1 = countTime;
handler.sendMessage(msgTime);
}
};
timer.schedule(timerTask, 50, 1000);
}
public Handler handler = new Handler(){
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if(msg.arg1 > 0){
//动态显示倒计时
countingView.setText(" "
+ msg.arg1 + "秒后自动报警");
}else{
//倒计时结束自动关闭
if(dialog != null){
dialog.dismiss();
if(isVibrate){
stopVibrate();
}
stopAlarm();
sendSMS(locationAddress, locationTime);
}
timer.cancel();
}
}
};
/*
*/
private void startVibrate(){
vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
long[] pattern = {100, 500, 100, 500};
vibrator.vibrate(pattern, 2);
}
/*
*/
private void stopVibrate(){
vibrator.cancel();
}
/*
*/
private void startAlarm(){
String ringtone = sharedPreferences.getString("pre_key_alarm" , null);
Log.d(TAG, ringtone + "");
Uri ringtoneUri = Uri.parse(ringtone);
mediaPlayer = MediaPlayer.create(context, ringtoneUri);
mediaPlayer.setLooping(true);//设置循环
mediaPlayer.start();
}
/*
*/
private void stopAlarm(){
mediaPlayer.stop();
}
private void sendSMS(String address, String time){
//获取短信管理器
SmsManager smsManager = SmsManager.getDefault();
String name = sharedPreferences.getString("pre_key_name", null);
String phoneNum = sharedPreferences.getString("pre_key_phone", null);
String smsContent = time + name + "在"+address + "发生跌倒了!";
smsManager.sendTextMessage(phoneNum, null, smsContent ,null, null);
Toast.makeText(context, "短信已经发出", Toast.LENGTH_SHORT).show();
}
public class YourActivity extends AppCompatActivity implements OnInitListener {
private TextToSpeech textToSpeech;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textToSpeech = new TextToSpeech(this, this);
}
@Override
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) {
// TTS引擎初始化成功可以设置相关配置
int result = textToSpeech.setLanguage(Locale.CHINESE); // 设置语言为中文
if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
// 如果语言不支持或数据缺失,可以处理异常情况
}
} else {
// TTS引擎初始化失败可以处理异常情况
}
}
}
private void startLocation(){
Log.d(TAG, "FallLocalReceiver.startLocation()");
locationClient = new AMapLocationClient(context);
//初始化定位参数
locationClientOption = new AMapLocationClientOption();
//设置定位模式为AMapLocationMode.Hight_Accuracy高精度模式。
locationClientOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
//获取最近3s内精度最高的一次定位结果
//设置setOnceLocationLatest(boolean b)接口为true启动定位时SDK会返回最近3s内精度最高的一次定位结果。如果设置其为truesetOnceLocation(boolean b)接口也会被设置为true反之不会默认为false。
locationClientOption.setOnceLocationLatest(true);
//设置定位监听
locationClient.setLocationListener(this);
//启动定位
locationClient.startLocation();
}
public void onLocationChanged(Location location) {
// 当位置发生变化时,更新界面上的位置信息
double latitude = location.getLatitude();
double longitude = location.getLongitude();
// TODO: 在界面上显示位置信息
locationAddress = getFormattedAddress(latitude, longitude); // 获取格式化的位置地址
}
@Override
public void onStatusChanged(String s, int i, Bundle bundle) {
}
@Override
public void onProviderEnabled(String s) {
}
@Override
public void onProviderDisabled(String s) {
}
@Override
public void onLocationChanged(AMapLocation amapLocation) {
if (amapLocation != null) {
if (amapLocation.getErrorCode() == 0) {
//定位成功回调信息,设置相关消息
//locationAddress = amapLocation.getAddress();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date(amapLocation.getTime());
locationTime = df.format(date);//定位时间
} else {
//显示错误信息ErrCode是错误码errInfo是错误信息详见错误码表。
Log.e("AmapError","location Error, ErrCode:"
+ amapLocation.getErrorCode() + ", errInfo:"
+ amapLocation.getErrorInfo());
}
}
}
private String getFormattedAddress(double latitude, double longitude) {
Geocoder geocoder = new Geocoder(context, Locale.getDefault());
List<Address> addresses;
String address = "";
try {
addresses = geocoder.getFromLocation(latitude, longitude, 1);
if (addresses != null && addresses.size() > 0) {
Address returnedAddress = addresses.get(0);
StringBuilder sb = new StringBuilder();
for (int i = 0; i <= returnedAddress.getMaxAddressLineIndex(); i++) {
sb.append(returnedAddress.getAddressLine(i)).append("\n");
}
address = sb.toString();
}
} catch (IOException e) {
e.printStackTrace();
// 处理异常情况
}
return address;
}
}

@ -0,0 +1,74 @@
package com.example.cauc.falldetecion;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.util.Log;
import static android.content.Context.SENSOR_SERVICE;
public class FallSensorManager {
private SensorManager sensorManager;
private Sensor accelerometer;
private Context context;
private float accX, accY, accZ;
private float svm;
public Fall fall;
private final String TAG = "FallDetection";
public FallSensorManager(Context context){
this.context = context;
fall = new Fall();
}
/*
*/
public void initSensor(){
//获取SensorManager系统的传感器管理服务
sensorManager = (SensorManager) context.getSystemService(SENSOR_SERVICE);
//获取accelerometer加速度传感器
accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
Log.d(TAG, "FallSensorManager.initSensor()");
}
/*
*/
public void registerSensor(){
sensorManager.registerListener(sensorEventListener,
accelerometer, SensorManager.SENSOR_DELAY_GAME);
Log.d(TAG, "FallSensorManager.registerSensor()");
}
/*
*/
public void unregisterSensor(){
sensorManager.unregisterListener(sensorEventListener);
Log.d(TAG, "FallSensorManager.unregisterSensor");
}
public SensorEventListener sensorEventListener = new SensorEventListener() {
@Override
public void onSensorChanged(SensorEvent event) {
switch (event.sensor.getType()) {
case Sensor.TYPE_ACCELEROMETER:
accX = event.values[0];
accY = event.values[1];
accZ = event.values[2];
svm = (float) Math.sqrt(accX * accX + accY * accY + accZ * accZ);
// Log.d(TAG,accX + " " + accY + " " + accZ );
Fall.svmCollector(svm);
Fall.setSvmFilteringData();
break;
}
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
};
}

@ -0,0 +1,36 @@
package com.example.cauc.falldetecion;
import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.suke.widget.SwitchButton;
public class HomeFragment extends Fragment {
private SwitchButton switchButton;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_home,null);
switchButton = (SwitchButton) view.findViewById(R.id.switchButton);
switchButton.setOnCheckedChangeListener(new SwitchButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(SwitchButton view, boolean isChecked) {
if(view.isChecked()){
Intent startIntent = new Intent(getContext(), FallDetectionService.class);
getContext().startService(startIntent);
}else{
Intent stopIntent = new Intent(getContext(), FallDetectionService.class);
getContext().stopService(stopIntent);
}
}
});
return view;
}
}

@ -0,0 +1,215 @@
package com.example.cauc.falldetecion;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.support.annotation.Nullable;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.OnInitListener;
import android.widget.Toast;
import java.util.Locale;
public class MainActivity extends AppCompatActivity implements TextToSpeech.OnInitListener {
private DrawerLayout mDrawerLayout;
private NavigationView mNavigationView;
private Toolbar mToolbar;
// private ActionBarDrawerToggle mDrawerToggle;
private HomeFragment homeFragment;
private SettingsFragment settingsFragment;
private TextToSpeech textToSpeech;
private final int HOME = 1;
private final int SETTINGS = 2;
private final int ABOUT = 3;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textToSpeech = new TextToSpeech(this, this);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
// mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.drawer_open,
// R.string.drawer_close);
// mDrawerToggle.syncState();
// mDrawerLayout.addDrawerListener(mDrawerToggle);
mNavigationView = (NavigationView) findViewById(R.id.navigation_view);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
//为activity窗口设置活动栏
setSupportActionBar(mToolbar);
final ActionBar actionBar = getSupportActionBar();
//设置导航图标
actionBar.setHomeAsUpIndicator(R.drawable.ic_menu);
actionBar.setDisplayHomeAsUpEnabled(true);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mNavigationView = (NavigationView) findViewById(R.id.navigation_view);
if (mNavigationView != null) {
setupDrawerContent(mNavigationView);
}
// switchToHome();
showFragment(HOME);
}
private void setupDrawerContent(NavigationView navigationView) {
//监听navigationView的项目选择
navigationView.setNavigationItemSelectedListener(
new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(MenuItem item) {
switch (item.getItemId()){
case R.id.navigation_item_home:
// switchToHome();
showFragment(HOME);
mToolbar.setTitle(R.string.app_name);
break;
case R.id.navigation_item_place:
switchToPlace();
break;
case R.id.navigation_item_settings:
// switchToSettings();
showFragment(SETTINGS);
mToolbar.setTitle(R.string.navigation_settings);
break;
}
item.setChecked(true);
mDrawerLayout.closeDrawers();
return true;
}
});
}
// private void switchToHome() {
// getSupportFragmentManager().beginTransaction().replace(R.id.frame_content, new HomeFragment()).commit();
// mToolbar.setTitle(R.string.app_name);
// }
//
private void switchToPlace() {
// getSupportFragmentManager().beginTransaction().replace(R.id.frame_content, new PlaceFragment()).commit();
// mToolbar.setTitle(R.string.navigation_place);
mToolbar.setTitle(R.string.app_name);
startActivity(new Intent(this, MapActivity.class));
}
//
// private void switchToSettings() {
// getSupportFragmentManager().beginTransaction().replace(R.id.frame_content, new SettingsFragment()).commit();
// mToolbar.setTitle(R.string.navigation_settings);
// }
//
// private void switchToAbout() {
// getSupportFragmentManager().beginTransaction().replace(R.id.frame_content, new AboutFragment()).commit();
// mToolbar.setTitle(R.string.navigation_about);
//
// }
public void showFragment(int index){
FragmentTransaction ft = getFragmentManager().beginTransaction();
//想要显示一个fragment先隐藏所有fragment防止重叠
hideFragment(ft);
switch (index){
case HOME:
if(homeFragment != null){
ft.show(homeFragment);
}else{
homeFragment = new HomeFragment();
ft.add(R.id.frame_content, homeFragment);
}
break;
case SETTINGS:
if(settingsFragment != null){
ft.show(settingsFragment);
}else{
settingsFragment = new SettingsFragment();
ft.add(R.id.frame_content, settingsFragment);
}
break;
}
ft.commit();
}
/*
fragment
*/
public void hideFragment(FragmentTransaction ft){
if(homeFragment != null){
ft.hide(homeFragment);
}
if(settingsFragment != null){
ft.hide(settingsFragment);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
if(item.getItemId() == android.R.id.home)
{
mDrawerLayout.openDrawer(GravityCompat.START);
return true ;
}
if(item.getItemId() == R.id.id_menu_settings){
showFragment(SETTINGS);
}
return super.onOptionsItemSelected(item);
}
@Override
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) {
int result = textToSpeech.setLanguage(Locale.CHINESE);
if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
Toast.makeText(this, "TTS语音引擎不支持或缺少中文语音数据", Toast.LENGTH_LONG).show();
} else {
String welcomeMessage = "欢迎使用老人跌倒监测系统。";
textToSpeech.speak(welcomeMessage, TextToSpeech.QUEUE_FLUSH, null, null);
}
} else {
Toast.makeText(this, "TTS引擎初始化失败", Toast.LENGTH_LONG).show();
}
}
@Override
protected void onDestroy() {
if (textToSpeech != null) {
textToSpeech.stop();
textToSpeech.shutdown();
}
super.onDestroy();
}
}

@ -0,0 +1,384 @@
package com.example.cauc.falldetecion;
import android.Manifest;
import android.content.pm.PackageManager;
import android.location.Address;
import android.location.Geocoder;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;
import com.amap.api.location.AMapLocation;
import com.amap.api.location.AMapLocationClient;
import com.amap.api.location.AMapLocationClientOption;
import com.amap.api.location.AMapLocationListener;
import com.amap.api.maps.AMap;
import com.amap.api.maps.CameraUpdateFactory;
import com.amap.api.maps.LocationSource;
import com.amap.api.maps.MapView;
import com.amap.api.maps.UiSettings;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;
public class MapActivity extends AppCompatActivity implements LocationSource, AMapLocationListener, TextToSpeech.OnInitListener, LocationListener {
private MapView mMapView;
private AMap aMap;
private LocationSource.OnLocationChangedListener mListener;
private AMapLocationClient mLocationClient;
private AMapLocationClientOption mLocationOption;
private UiSettings mUiSettings;
private static final int LOCATION_PERMISSION_REQUEST_CODE = 1;
private LocationManager locationManager;
private TextToSpeech textToSpeech;
private String locationAddress;
private ToggleButton tb;
private TextView textView;
private NavigationView mNavigationView;
private Toolbar mToolbar;
public String nowaddress;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
textToSpeech = new TextToSpeech(this, this);
setContentView(R.layout.map_activity);
textView = (TextView) findViewById(R.id.address);
mNavigationView = (NavigationView) findViewById(R.id.navigation_view);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
mToolbar.setTitle(R.string.navigation_place);
//为activity窗口设置活动栏
setSupportActionBar(mToolbar);
final ActionBar actionBar = getSupportActionBar();
//设置返回图标
actionBar.setHomeAsUpIndicator(0);
actionBar.setDisplayHomeAsUpEnabled(true);
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
// 检查定位权限
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) {
// 申请定位权限
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
LOCATION_PERMISSION_REQUEST_CODE);
} else {
// 获取LocationManager实例
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
// 获取TextToSpeech实例并设置初始化监听器
textToSpeech = new TextToSpeech(this, this);
// 开始监听位置变化
startLocationUpdates();
}
//获取地图控件引用
mMapView = (MapView) findViewById(R.id.map);
//在activity执行onCreate时执行mMapView.onCreate(savedInstanceState),创建地图
//实现地图生命周期管理
mMapView.onCreate(savedInstanceState);
//初始化AMap对象
aMap = mMapView.getMap();
// 设置定位监听,如果不设置此定位资源则定位按钮不可点击
aMap.setLocationSource(this);
// 设置为true表示显示定位层并可触发定位false表示隐藏定位层并不可触发定位默认是false
aMap.setMyLocationEnabled(true);
// 设置定位的类型为定位模式,有定位、跟随或地图根据面向方向旋转几种
aMap.setMyLocationType(AMap.LOCATION_TYPE_LOCATE);
//实例化UiSettings类
mUiSettings = aMap.getUiSettings();
//显示指南针
mUiSettings.setCompassEnabled(true);
// 显示默认的定位按钮
mUiSettings.setMyLocationButtonEnabled(true);
//显示比例尺控件
mUiSettings.setScaleControlsEnabled(true);
tb = (ToggleButton) findViewById(R.id.tb);
tb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
//设置使用卫星地图
aMap.setMapType(AMap.MAP_TYPE_SATELLITE);
} else {
//设置使用普通地图
aMap.setMapType(AMap.MAP_TYPE_NORMAL);
}
}
});
}
private void startLocationUpdates() {
// 设置最小时间间隔和最小距离这里设置为1000毫秒和1米
// 这样当位置发生变化时会在接下来的1000毫秒内获取位置信息
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
10000, 10, this);
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
@NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == LOCATION_PERMISSION_REQUEST_CODE) {
// 检查定位权限授权结果
if (grantResults.length > 0 &&
grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// 获取LocationManager实例
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
// 开始监听位置变化
startLocationUpdates();
} else {
// 处理没有授权的情况
}
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}
@Override
protected void onResume() {
super.onResume();
//在activity执行onResume时执行mMapView.onResume(),重新绘制加载地图
//实现地图生命周期管理
mMapView.onResume();
}
@Override
protected void onPause() {
super.onPause();
//在activity执行onPause时执行mMapView.onPause(),暂停地图的绘制
//实现地图生命周期管理
mMapView.onPause();
}
public void onLocationChanged(Location location) {
// 当位置发生变化时,更新界面上的位置信息
double latitude = location.getLatitude();
double longitude = location.getLongitude();
// TODO: 在界面上显示位置信息
locationAddress = getFormattedAddress(latitude, longitude); // 获取格式化的位置地址
//textView.setText(latitude+"\n"+longitude+locationAddress);
speakLocationInformation(); // 开始语音播报位置信息
}
private String getFormattedAddress(double latitude, double longitude) {
Geocoder geocoder = new Geocoder(this, Locale.getDefault());
List<Address> addresses;
String address = "";
try {
addresses = geocoder.getFromLocation(latitude, longitude, 1);
if (addresses != null && addresses.size() > 0) {
Address returnedAddress = addresses.get(0);
StringBuilder sb = new StringBuilder();
for (int i = 0; i <= returnedAddress.getMaxAddressLineIndex(); i++) {
sb.append(returnedAddress.getAddressLine(i)).append("\n");
}
address = sb.toString();
}
} catch (IOException e) {
e.printStackTrace();
// 处理异常情况
}
return address;
}
private void speakLocationInformation() {
if (textToSpeech != null && textToSpeech.isSpeaking()) {
textToSpeech.stop();
}
if (textToSpeech != null) {
textToSpeech.speak("您现在位于" + locationAddress, TextToSpeech.QUEUE_FLUSH, null, null);
}
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// 当位置提供者状态变化时,处理逻辑
}
@Override
public void onProviderEnabled(String provider) {
// 当位置提供者启用时,处理逻辑
}
@Override
public void onProviderDisabled(String provider) {
// 当位置提供者禁用时,处理逻辑
}
@Override
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) {
int result = textToSpeech.setLanguage(Locale.CHINESE);
if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
//Toast.makeText(this, "TTS语音引擎不支持或缺少中文语音数据", Toast.LENGTH_LONG).show();
} else {
speakLocationInformation(); // 当初始化成功后直接开始语音播报位置信息
}
} else {
Toast.makeText(this, "TTS引擎初始化失败", Toast.LENGTH_LONG).show();
}
}
@Override
protected void onDestroy() {
super.onDestroy();
// 停止位置监听
locationManager.removeUpdates(this);
// 释放TextToSpeech资源
if (textToSpeech != null) {
textToSpeech.stop();
textToSpeech.shutdown();
}
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
//在activity执行onSaveInstanceState时执行mMapView.onSaveInstanceState(outState),保存地图当前的状态
//实现地图生命周期管理
mMapView.onSaveInstanceState(outState);
}
/**
*
*/
@Override
public void activate(OnLocationChangedListener onLocationChangedListener) {
mListener = onLocationChangedListener;
if (mLocationClient == null) {
//初始化定位
mLocationClient = new AMapLocationClient(this);
//初始化定位参数
mLocationOption = new AMapLocationClientOption();
//设置定位回调监听
mLocationClient.setLocationListener(this);
//设置为高精度定位模式
mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
//设置定位参数
mLocationClient.setLocationOption(mLocationOption);
// 此方法为每隔固定时间会发起一次定位请求,为了减少电量消耗或网络流量消耗,
// 注意设置合适的定位时间的间隔最小间隔支持为2000ms并且在合适时间调用stopLocation()方法来取消定位请求
// 在定位结束后在合适的生命周期调用onDestroy()方法
// 在单次定位情况下定位无论成功与否都无需调用stopLocation()方法移除请求定位sdk内部会移除
mLocationClient.startLocation();//启动定位
}
}
/**
*
*/
@Override
public void deactivate() {
mListener = null;
if (mLocationClient != null) {
mLocationClient.stopLocation();
mLocationClient.onDestroy();
}
mLocationClient = null;
}
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
if (mListener != null && aMapLocation != null) {
if (aMapLocation != null
&& aMapLocation.getErrorCode() == 0) {
mListener.onLocationChanged(aMapLocation);// 显示系统小蓝点
aMap.moveCamera(CameraUpdateFactory.zoomTo(16));//将地图的缩放级别调整到17级
//定位成功回调信息,设置相关消息
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date(aMapLocation.getTime());
String time = df.format(date);//定位时
StringBuffer address = new StringBuffer();
/*address.append(aMapLocation.getCountry()
+ aMapLocation.getProvince()
+ aMapLocation.getCity()
+ aMapLocation.getDistrict()
+ aMapLocation.getStreet()
+ aMapLocation.getStreetNum());*/
address.append("纬度: "+ aMapLocation.getLatitude() + "\n");
address.append("经度: "+ aMapLocation.getLongitude() + "\n");
//如果option中设置isNeedAddress为false则没有此结果网络定位结果中会有地址信息GPS定位不返回地址信息。
//address.append("地址: "+ aMapLocation.getAddress() + "\n");
//address.append("当前定位点的AOI信息: "+ aMapLocation.getAoiName() + "\n");
//address.append("当前室内定位的建筑物Id: "+ aMapLocation.getBuildingId() + "\n");
//address.append("当前室内定位的楼层: "+ aMapLocation.getFloor() + "\n");
Log.v("older", "address:" + time + address.toString());
textView.setText(time + "\n" + locationAddress+address.toString());
//39.11083224826389
// 经度: 117.35290635850694
} else {
String errText = "定位失败," + aMapLocation.getErrorCode()+ ": " + aMapLocation.getErrorInfo();
Log.e("AmapErr",errText);
}
}
}
}

@ -0,0 +1,74 @@
package com.example.cauc.falldetecion;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.util.Log;
public class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener{
public static final String KEY_NAME = "pre_key_name";
public static final String KEY_SEX = "pre_key_sex";
public static final String KEY_AGE = "pre_key_age";
public static final String KEY_ALERT = "pre_key_alert";
public static final String KEY_VIBRATE = "pre_key_vibrate";
public static final String KEY_PHONE = "pre_key_phone";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
Log.d("FallDetection", "SettingsFragment.onsharedPreferenceChanged");
// System.out.print("key是 " + key);
Log.d("FallDetection", key);
// if(key.equals(KEY_AGE)){
// Preference agePre = findPreference(key);
// agePre.setSummary(sharedPreferences.getString(key, "请输入年龄"));
// }
switch (key){
case KEY_NAME:
Preference namePre = findPreference(key);
namePre.setSummary(sharedPreferences.getString(key, ""));
break;
case KEY_SEX:
Preference sexPre = findPreference(key);
sexPre.setSummary(sharedPreferences.getString(key, ""));
break;
case KEY_AGE:
Preference agePre = findPreference(key);
agePre.setSummary(sharedPreferences.getString(key, ""));
break;
case KEY_ALERT:
Preference alertPre = findPreference(key);
alertPre.setSummary(sharedPreferences.getString(key, ""));
break;
case KEY_VIBRATE:
break;
case KEY_PHONE:
Preference phonePre = findPreference(key);
phonePre.setSummary(sharedPreferences.getString(key, ""));
break;
}
}
@Override
public void onResume() {
super.onResume();
getPreferenceManager().getSharedPreferences()
.registerOnSharedPreferenceChangeListener(this);
}
@Override
public void onPause() {
getPreferenceManager().getSharedPreferences()
.unregisterOnSharedPreferenceChangeListener(this);
super.onPause();
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 835 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 646 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 525 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 437 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 652 B

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/appbar"
layout="@layout/include_toolbar"/>
<FrameLayout
android:id="@+id/frame_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/appbar"
android:scrollbars="none"
app:layout_behavior="@string/appbar_scrolling_view_behavior"></FrameLayout>
</RelativeLayout>
<android.support.design.widget.NavigationView
android:id="@+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/navigation_header"
app:menu="@menu/drawer"></android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="@color/about_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/about_content1"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
<TextView
android:padding="30dp"
android:textSize="17sp"
android:layout_marginBottom="150dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="功能介绍:\n
实时监控用户是否发生跌倒。如果用户发生跌倒,手机会发出警报求助,以便获得及时的救助。"/>
<TextView
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="老人跌倒检测"/>
<TextView
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="当前版本1.0.0"/>
</LinearLayout>

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_marginTop="30dp"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="25sp"
android:textColor="@color/primary_text"
android:text="老人跌倒检测" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="64dp"
android:background="@color/home_back"
android:orientation="horizontal">
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="80dp"
android:padding="5dp"
android:text="跌倒检测开关"
android:textColor="@color/primary_text"
android:textSize="18sp" />
<com.suke.widget.SwitchButton
android:id="@+id/switchButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="45dp" />
</LinearLayout>
<TextView
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textStyle="bold"
android:text="老人安,天下安"
android:textColor="@color/primary_text"
android:layout_marginBottom="20dp"/>
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@drawable/home_content" />
<!--<TextView-->
<!--android:layout_gravity="center_horizontal"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:text="当前版本1.0.0"/>-->
</LinearLayout>

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<include android:id="@+id/appbar"
layout="@layout/include_toolbar"
android:title="@string/navigation_place"
xmlns:android="http://schemas.android.com/apk/res/android" />
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.amap.api.maps.SupportMapFragment" />
</FrameLayout>

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.AppBarLayout>

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map_activity"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include android:id="@+id/appbar"
layout="@layout/include_toolbar"
android:title="@string/navigation_place"
xmlns:android="http://schemas.android.com/apk/res/android" />
<com.amap.api.maps.MapView
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent">
</com.amap.api.maps.MapView>
<ToggleButton
android:id="@+id/tb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:textOff="普通地图"
android:textOn="卫星地图"
android:checked="false"/>
<TextView
android:layout_width="250dp"
android:layout_height="wrap_content"
android:id="@+id/address"
android:textSize="20sp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="?attr/colorPrimaryDark"
android:gravity="center"
android:padding="16dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginBottom="16dp"
android:src="@mipmap/profile_image"/>
<TextView
android:layout_marginTop="10dp"
android:textSize="18sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:gravity="center"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>
</LinearLayout>

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity">
<group android:checkableBehavior="single">
<item
android:id="@+id/navigation_item_home"
android:icon="@drawable/ic_home"
android:title="@string/navigation_home"/>
<item
android:id="@+id/navigation_item_place"
android:icon="@drawable/ic_place"
android:title="@string/navigation_place"/>
<item
android:id="@+id/navigation_item_settings"
android:icon="@drawable/ic_settings"
android:title="@string/navigation_settings"/>
</group>
</menu>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/id_menu_settings"
android:title="@string/navigation_settings"/>
</menu>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

@ -0,0 +1,6 @@
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="primary">#4C637A</color>
<color name="primary_dark">#A2C6EA</color>
<color name="primary_light">#CDE6FA</color>
<color name="accent">#4C637A</color>
<color name="primary_text">#212121</color>
<color name="secondary_text">#727272</color>
<color name="icons">#FFFFFF</color>
<color name="divider">#B6B6B6</color>
<color name="window_background">#FFF5F5F5</color>
<color name="tab_bgcolor">#eeeeee</color>
<color name="home_back">#C4CEB3</color>
<color name="about_content">#AFB79C</color>
</resources>

@ -0,0 +1,5 @@
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>

@ -0,0 +1,15 @@
<resources>
<string name="app_name">老人跌倒检测</string>
<string name="navigation_home">主页</string>
<string name="navigation_place">地图与位置</string>
<string name="navigation_settings">设置</string>
<string name="navigation_about">关于</string>
<string name="appbar_scrolling_view_behavior" translatable="false">android.support.design.widget.AppBarLayout$ScrollingViewBehavior</string>
<string name="drawer_open">open</string>
<string name="drawer_close">close</string>
<string-array name="sex">
<item></item>
<item></item>
</string-array>
</resources>

@ -0,0 +1,12 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/accent</item>
<item name="android:windowBackground">@color/window_background</item>
</style>
</resources>

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="个人信息"
android:summary="个人信息"
android:key="pre_key_personal_settings">
<EditTextPreference
android:maxLines="1"
android:selectAllOnFocus="true"
android:singleLine="true"
android:defaultValue="李奶奶"
android:key="pre_key_name"
android:title="姓名:"
android:summary="请输入姓名"/>
<ListPreference
android:defaultValue="0"
android:key="pre_key_sex"
android:title="性别:"
android:summary="请选择性别"
android:dialogTitle="性别选择"
android:entries="@array/sex"
android:entryValues="@array/sex"/>
<EditTextPreference
android:title="年龄"
android:summary="请输入年龄"
android:key="pre_key_age"/>
</PreferenceCategory>
<PreferenceCategory
android:title="报警设置"
android:summary="报警设置"
android:key="pre_key_alert_settings">
<RingtonePreference
android:title="铃声设置"
android:summary="铃声设置"
android:showSilent="false"
android:key="pre_key_alarm"
android:ringtoneType="alarm"/>
<SwitchPreference
android:title="振动"
android:summary="振动开关"
android:key="pre_key_vibrate"/>
<EditTextPreference
android:title="紧急联系人"
android:summary="紧急联系人电话"
android:key="pre_key_phone"/>
</PreferenceCategory>
</PreferenceScreen>

@ -0,0 +1,17 @@
package com.example.cauc.falldetecion;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}

@ -0,0 +1,27 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
}
}
ext {
defaultApplicationId = 'com.example.cauc.falldetecion'
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

@ -0,0 +1,17 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

@ -0,0 +1,6 @@
#Thu Sep 14 17:41:20 CST 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip

@ -0,0 +1,160 @@
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

@ -0,0 +1,90 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
Loading…
Cancel
Save