SOS广播消息发送与接收完成
This commit is contained in:
parent
3dd4c84602
commit
50490096b4
@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Thu Feb 13 12:38:29 GMT 2025
|
||||
#Thu Feb 13 13:30:31 GMT 2025
|
||||
stageCount=1
|
||||
libraryProject=libappbase
|
||||
baseVersion=1.5
|
||||
publishVersion=1.5.0
|
||||
buildCount=12
|
||||
buildCount=17
|
||||
baseBetaVersion=1.5.1
|
||||
|
@ -12,6 +12,7 @@ import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import cc.winboll.studio.libappbase.ISOSAPP;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.LogView;
|
||||
import cc.winboll.studio.libappbase.SOS;
|
||||
import cc.winboll.studio.libappbase.SOSCSBroadcastReceiver;
|
||||
import cc.winboll.studio.libappbase.SimpleOperateSignalCenterService;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
@ -77,7 +78,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
public void onSOS(View view) {
|
||||
sos2();
|
||||
SOS.sendToWinBoll(this);
|
||||
}
|
||||
|
||||
public void sos() {
|
||||
@ -105,4 +106,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
sendBroadcast(intent);
|
||||
LogUtils.d(TAG, "onSOS2");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Thu Feb 13 12:38:29 GMT 2025
|
||||
#Thu Feb 13 13:30:31 GMT 2025
|
||||
stageCount=1
|
||||
libraryProject=libappbase
|
||||
baseVersion=1.5
|
||||
publishVersion=1.5.0
|
||||
buildCount=12
|
||||
buildCount=17
|
||||
baseBetaVersion=1.5.1
|
||||
|
@ -21,7 +21,13 @@
|
||||
<service android:name=".SimpleOperateSignalCenterService"/>
|
||||
|
||||
<activity android:name=".LogActivity"/>
|
||||
|
||||
|
||||
<receiver android:name=".receiver.MyBroadcastReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="cc.winboll.studio.libappbase.action.SOS" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
@ -0,0 +1,31 @@
|
||||
package cc.winboll.studio.libappbase;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/02/13 21:09:36
|
||||
* @Describe SOS 组件
|
||||
*/
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
|
||||
public class SOS {
|
||||
|
||||
public static final String TAG = "SOS";
|
||||
|
||||
public static void sendToWinBoll(Context context) {
|
||||
Intent intent = new Intent(context.getString(R.string.action_sos));
|
||||
intent.putExtra("sosPackage", context.getPackageName());
|
||||
intent.putExtra("message", "SOS");
|
||||
if (GlobalApplication.isDebuging()) {
|
||||
intent.setPackage("cc.winboll.studio.appbase.beta");
|
||||
} else {
|
||||
intent.setPackage("cc.winboll.studio.appbase");
|
||||
}
|
||||
context.sendBroadcast(intent);
|
||||
|
||||
LogUtils.d(TAG, "SOS Send To WinBoll");
|
||||
//ToastUtils.show("SOS Send To WinBoll");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package cc.winboll.studio.libappbase.receiver;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/02/13 21:19:09
|
||||
* @Describe MyBroadcastReceiver
|
||||
*/
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.R;
|
||||
|
||||
public class MyBroadcastReceiver extends BroadcastReceiver {
|
||||
|
||||
public static final String TAG = "MyBroadcastReceiver";
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (context.getString(R.string.action_sos).equals(intent.getAction())) {
|
||||
String message = intent.getStringExtra("message");
|
||||
String sosPackage = intent.getStringExtra("sosPackage");
|
||||
|
||||
// 处理接收到的广播消息
|
||||
LogUtils.d(TAG, String.format("MyBroadcastReceiver action %s \n%s\n%s", intent.getAction(), sosPackage, message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,5 +3,5 @@
|
||||
|
||||
<string name="lib_name">libappbase</string>
|
||||
<string name="hello_world">Hello world!</string>
|
||||
|
||||
<string name="action_sos">cc.winboll.studio.libappbase.action.SOS</string>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user