SOS 服务架构基本完成
This commit is contained in:
@@ -29,7 +29,7 @@ android {
|
||||
// versionName 更新后需要手动设置
|
||||
// .winboll/winbollBuildProps.properties 文件的 stageCount=0
|
||||
// Gradle编译环境下合起来的 versionName 就是 "${versionName}.0"
|
||||
versionName "1.4"
|
||||
versionName "1.5"
|
||||
if(true) {
|
||||
versionName = genVersionName("${versionName}")
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Wed Feb 12 19:45:53 GMT 2025
|
||||
stageCount=2
|
||||
#Wed Feb 12 22:48:52 GMT 2025
|
||||
stageCount=0
|
||||
libraryProject=libappbase
|
||||
baseVersion=1.4
|
||||
publishVersion=1.4.1
|
||||
buildCount=22
|
||||
baseBetaVersion=1.4.2
|
||||
baseVersion=1.5
|
||||
publishVersion=1.5.0
|
||||
buildCount=0
|
||||
baseBetaVersion=1.5.1
|
||||
|
@@ -19,7 +19,7 @@ public class App extends GlobalApplication {
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
GlobalApplication.setIsDebuging(this, BuildConfig.DEBUG);
|
||||
mSOSCSBroadcastReceiver = new SOSCSBroadcastReceiver();
|
||||
mSOSCSBroadcastReceiver = new SOSCSBroadcastReceiver(this);
|
||||
IntentFilter intentFilter = new IntentFilter();
|
||||
intentFilter.addAction(SOSCSBroadcastReceiver.ACTION_SOS);
|
||||
registerReceiver(mSOSCSBroadcastReceiver, intentFilter);
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package cc.winboll.studio.appbase;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
@@ -10,7 +11,10 @@ import cc.winboll.studio.appbase.R;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.LogView;
|
||||
import cc.winboll.studio.libappbase.SOSCSBroadcastReceiver;
|
||||
import cc.winboll.studio.libappbase.SimpleOperateSignalCenterService;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import cc.winboll.studio.libappbase.ISOSAPP;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@@ -45,11 +49,41 @@ public class MainActivity extends AppCompatActivity {
|
||||
GlobalApplication.setIsDebuging(this, ((CheckBox)view).isChecked());
|
||||
}
|
||||
|
||||
public void onStartCenter(View view) {
|
||||
SimpleOperateSignalCenterService.startISOSService(this);
|
||||
}
|
||||
|
||||
public void onStopCenter(View view) {
|
||||
SimpleOperateSignalCenterService.stopISOSService(this);
|
||||
}
|
||||
|
||||
public void onTestStopWithoutSettingEnable(View view) {
|
||||
LogUtils.d(TAG, "onTestStopWithoutSettingEnable");
|
||||
stopService(new Intent(this, SimpleOperateSignalCenterService.class));
|
||||
}
|
||||
|
||||
public void onTestStartWithString(View view) {
|
||||
LogUtils.d(TAG, "onTestStartWithString");
|
||||
|
||||
// 目标服务的包名和类名
|
||||
String packageName = this.getPackageName();
|
||||
String serviceClassName = SimpleOperateSignalCenterService.class.getName();
|
||||
|
||||
// 构建Intent
|
||||
Intent intentService = new Intent();
|
||||
intentService.setComponent(new ComponentName(packageName, serviceClassName));
|
||||
|
||||
startService(intentService);
|
||||
}
|
||||
|
||||
public void onSOS(View view) {
|
||||
// 创建Intent对象,指定广播的action
|
||||
Intent intent = new Intent("cc.winboll.studio.libappbase.SOSCSBroadcastReceiver.ACTION_SOS");
|
||||
// 可以添加额外的数据
|
||||
intent.putExtra("data", "这是广播携带的数据");
|
||||
Intent intent = new Intent(SOSCSBroadcastReceiver.ACTION_SOS);
|
||||
// 目标服务的包名和类名
|
||||
String packageName = this.getPackageName();
|
||||
String serviceClassName = SimpleOperateSignalCenterService.class.getName();
|
||||
intent.putExtra(ISOSAPP.EXTRA_PACKAGE, packageName);
|
||||
intent.putExtra(ISOSAPP.EXTRA_SERVICE, serviceClassName);
|
||||
// 发送广播
|
||||
sendBroadcast(intent);
|
||||
LogUtils.d(TAG, "onSOS");
|
||||
|
@@ -48,11 +48,39 @@
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="right">
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="StartCenter"
|
||||
android:textAllCaps="false"
|
||||
android:onClick="onStartCenter"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="StopCenter"
|
||||
android:textAllCaps="false"
|
||||
android:onClick="onStopCenter"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="TestStopWithoutSettingEnable"
|
||||
android:textAllCaps="false"
|
||||
android:onClick="onTestStopWithoutSettingEnable"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="TestStartWithString"
|
||||
android:textAllCaps="false"
|
||||
android:onClick="onTestStartWithString"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
Reference in New Issue
Block a user