目前状态栏控制大部分已生效,剩余暂停到播放的链路还有问题

This commit is contained in:
2026-08-21 00:03:04 +08:00
parent bb8e4caf48
commit 8ecca4ac01
2 changed files with 118 additions and 40 deletions
+25 -18
View File
@@ -1,9 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- ⭐ 网络(已有) -->
<!-- 权限不变 -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- ⭐ 后台播放 -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
@@ -15,6 +13,7 @@
android:icon="@mipmap/ic_launcher"
android:usesCleartextTraffic="true"
android:foregroundServiceType="mediaPlayback">
<activity
android:name=".MainActivity"
android:exported="true"
@@ -24,38 +23,46 @@
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
android:resource="@style/NormalTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<!-- ⭐ 关键:AudioService 必须同时声明 MediaBrowserService 和 MEDIA_BUTTON -->
<service
android:name="com.ryanheise.audioservice.AudioService"
android:foregroundServiceType="mediaPlayback"
android:exported="false" />
android:exported="true">
<intent-filter>
<!-- 媒体浏览器服务(MediaButtonReceiver 需要) -->
<action android:name="android.media.browse.MediaBrowserService" />
<!-- 媒体按钮(通知栏、蓝牙、耳机按键) -->
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</service>
<!-- ⭐ MediaButtonReceiver 接收系统媒体按钮事件 -->
<receiver
android:name="com.ryanheise.audioservice.MediaButtonReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
<!-- Required to query activities that can process text, see:
https://developer.android.com/training/package-visibility and
https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
<queries>
<intent>
<action android:name="android.intent.action.PROCESS_TEXT"/>
<data android:mimeType="text/plain"/>
</intent>
</queries>
</manifest>
</manifest>