添加SOS广播接收
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Wed Feb 12 18:04:02 HKT 2025
|
||||
#Wed Feb 12 19:45:53 GMT 2025
|
||||
stageCount=2
|
||||
libraryProject=libappbase
|
||||
baseVersion=1.4
|
||||
publishVersion=1.4.1
|
||||
buildCount=0
|
||||
buildCount=22
|
||||
baseBetaVersion=1.4.2
|
||||
|
@@ -6,18 +6,22 @@ package cc.winboll.studio.appbase;
|
||||
* @Describe APPbase 应用类
|
||||
*/
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.SOSCSBroadcastReceiver;
|
||||
import android.content.IntentFilter;
|
||||
|
||||
public class App extends GlobalApplication {
|
||||
|
||||
public static final String TAG = "App";
|
||||
|
||||
|
||||
SOSCSBroadcastReceiver mSOSCSBroadcastReceiver;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
GlobalApplication.setIsDebuging(this, BuildConfig.DEBUG);
|
||||
super.onCreate();
|
||||
LogUtils.setLogLevel(LogUtils.LOG_LEVEL.Debug);
|
||||
LogUtils.setALlTAGListEnable(true);
|
||||
LogUtils.d(TAG, "LogUtils init");
|
||||
GlobalApplication.setIsDebuging(this, BuildConfig.DEBUG);
|
||||
mSOSCSBroadcastReceiver = new SOSCSBroadcastReceiver();
|
||||
IntentFilter intentFilter = new IntentFilter();
|
||||
intentFilter.addAction(SOSCSBroadcastReceiver.ACTION_SOS);
|
||||
registerReceiver(mSOSCSBroadcastReceiver, intentFilter);
|
||||
}
|
||||
}
|
||||
|
@@ -1,15 +1,23 @@
|
||||
package cc.winboll.studio.appbase;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
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 com.hjq.toast.ToastUtils;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
public static final String TAG = "MainActivity";
|
||||
|
||||
LogView mLogView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -18,13 +26,32 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.activitymainToolbar1);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
|
||||
CheckBox cbIsDebugMode = findViewById(R.id.activitymainCheckBox1);
|
||||
cbIsDebugMode.setChecked(GlobalApplication.isDebuging());
|
||||
|
||||
mLogView = findViewById(R.id.activitymainLogView1);
|
||||
|
||||
if (GlobalApplication.isDebuging()) { mLogView.start(); }
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
LogUtils.d(TAG, "onResume");
|
||||
super.onResume();
|
||||
mLogView.start();
|
||||
}
|
||||
|
||||
public void onSwitchDebugMode(View view) {
|
||||
GlobalApplication.setIsDebuging(this, ((CheckBox)view).isChecked());
|
||||
}
|
||||
|
||||
public void onSOS(View view) {
|
||||
// 创建Intent对象,指定广播的action
|
||||
Intent intent = new Intent("cc.winboll.studio.libappbase.SOSCSBroadcastReceiver.ACTION_SOS");
|
||||
// 可以添加额外的数据
|
||||
intent.putExtra("data", "这是广播携带的数据");
|
||||
// 发送广播
|
||||
sendBroadcast(intent);
|
||||
LogUtils.d(TAG, "onSOS");
|
||||
}
|
||||
}
|
||||
|
@@ -47,6 +47,26 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
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="SOS"
|
||||
android:onClick="onSOS"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<cc.winboll.studio.libappbase.LogView
|
||||
android:layout_weight="1.0"
|
||||
android:layout_height="0dp"
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/activitymainLogView1"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
Reference in New Issue
Block a user