Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
ab487b9a
Commit
ab487b9a
authored
May 31, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Android: use startForegroundService() in Android 8+
Fixes the error: IllegalStateException: Not allowed to start service Intent { cmp=org.musicpd/.Main (has extras) }: app is in background
parent
ac59ec34
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletion
+12
-1
NEWS
NEWS
+2
-0
Main.java
android/src/Main.java
+10
-1
No files found.
NEWS
View file @
ab487b9a
...
@@ -4,6 +4,8 @@ ver 0.22.9 (not yet released)
...
@@ -4,6 +4,8 @@ ver 0.22.9 (not yet released)
* decoder
* decoder
- ffmpeg: support the tags "sort_album", "album-sort", "artist-sort"
- ffmpeg: support the tags "sort_album", "album-sort", "artist-sort"
- ffmpeg: fix build failure with FFmpeg 3.4
- ffmpeg: fix build failure with FFmpeg 3.4
* Android
- fix auto-start on boot in Android 8 or later
* Windows
* Windows
- fix build failure with SQLite
- fix build failure with SQLite
...
...
android/src/Main.java
View file @
ab487b9a
...
@@ -414,6 +414,15 @@ public class Main extends Service implements Runnable {
...
@@ -414,6 +414,15 @@ public class Main extends Service implements Runnable {
* start Main service without any callback
* start Main service without any callback
*/
*/
public
static
void
start
(
Context
context
,
boolean
wakelock
)
{
public
static
void
start
(
Context
context
,
boolean
wakelock
)
{
context
.
startService
(
new
Intent
(
context
,
Main
.
class
).
putExtra
(
"wakelock"
,
wakelock
));
Intent
intent
=
new
Intent
(
context
,
Main
.
class
)
.
putExtra
(
"wakelock"
,
wakelock
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
/* in Android 8+, we need to use this method
or else we'll get "IllegalStateException:
app is in background" */
context
.
startForegroundService
(
intent
);
else
context
.
startService
(
intent
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment