- 添加FOREGROUND_SERVICE权限支持前台服务 - 使用startForegroundService替代startService启动服务 - 实现前台服务通知,实时显示GPS经纬度数据 - 在MainActivity添加Switch开关控制服务启停 - GPS位置更新时通过updateNotification实时更新通知内容 - 创建通知渠道适配Android O及以上版本
65 lines
1.8 KiB
XML
65 lines
1.8 KiB
XML
<?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:layout_width="match_parent"
|
|
android:layout_height="match_parent"
|
|
android:orientation="vertical">
|
|
|
|
<com.google.android.material.appbar.AppBarLayout
|
|
android:layout_width="match_parent"
|
|
android:layout_height="wrap_content"
|
|
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
|
|
|
|
<androidx.appcompat.widget.Toolbar
|
|
android:id="@+id/toolbar"
|
|
android:layout_width="match_parent"
|
|
android:layout_height="?attr/actionBarSize"
|
|
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
|
|
|
|
</com.google.android.material.appbar.AppBarLayout>
|
|
|
|
<LinearLayout
|
|
android:orientation="vertical"
|
|
android:layout_width="match_parent"
|
|
android:layout_height="0dp"
|
|
android:layout_weight="1.0"
|
|
android:gravity="center_vertical|center_horizontal">
|
|
|
|
<TextView
|
|
android:layout_width="wrap_content"
|
|
android:layout_height="wrap_content"
|
|
android:text="GPSRelaySentinel"
|
|
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
|
|
|
<Switch
|
|
android:id="@+id/switch_service"
|
|
android:layout_width="wrap_content"
|
|
android:layout_height="wrap_content"
|
|
android:text="GPS Service"
|
|
android:checked="false"/>
|
|
|
|
<Button
|
|
android:layout_width="wrap_content"
|
|
android:layout_height="wrap_content"
|
|
android:text="Open LibraryActivity"
|
|
android:onClick="onLibraryActivity"/>
|
|
|
|
</LinearLayout>
|
|
|
|
<LinearLayout
|
|
android:orientation="vertical"
|
|
android:layout_width="match_parent"
|
|
android:layout_height="0dp"
|
|
android:layout_weight="1.0">
|
|
|
|
<cc.winboll.studio.libappbase.LogView
|
|
android:layout_width="match_parent"
|
|
android:layout_height="match_parent"
|
|
android:id="@+id/logview"/>
|
|
|
|
</LinearLayout>
|
|
|
|
</LinearLayout>
|
|
|