Skip to content
This repository has been archived by the owner on Jan 5, 2025. It is now read-only.

Commit

Permalink
Fix crash finally
Browse files Browse the repository at this point in the history
  • Loading branch information
Live-block committed Aug 11, 2024
1 parent 58bd920 commit 0f544ad
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
Expand Down Expand Up @@ -102,15 +103,15 @@
</service>
<service android:name=".ui.freeform.FreeformService"
android:enabled="true"
android:exported="true">
android:exported="false">
<intent-filter>
<action android:name="com.sunshine.freeform.ui.freeform.FreeformService"/>
</intent-filter>
</service>

<service
android:name=".service.ForegroundService"
android:foregroundServiceType="dataSync"
android:foregroundServiceType="dataSync|mediaPlayback"
android:enabled="true"
android:exported="false" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ import android.graphics.PixelFormat
import android.hardware.SensorManager
import android.hardware.display.DisplayManager
import android.net.Uri
import android.os.Build
import android.os.IBinder
import android.provider.Settings
import android.util.DisplayMetrics
import android.util.Log
import android.view.*
import android.widget.Toast
import androidx.annotation.RequiresApi
import com.sunshine.freeform.R
import com.sunshine.freeform.app.MiFreeform
import com.sunshine.freeform.broadcast.StartFreeformReceiver
Expand Down Expand Up @@ -178,6 +180,7 @@ class ForegroundService : Service(), SharedPreferences.OnSharedPreferenceChangeL
}
}

@RequiresApi(Build.VERSION_CODES.Q)
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val notificationIntent = Intent(this, FloatingActivity::class.java)
Expand All @@ -202,7 +205,7 @@ class ForegroundService : Service(), SharedPreferences.OnSharedPreferenceChangeL
val notification = builder.build()
notification.flags = Notification.FLAG_ONGOING_EVENT or Notification.FLAG_NO_CLEAR

startForeground(3, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC)
startForeground(3, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_MANIFEST)

return START_STICKY
}
Expand Down

0 comments on commit 0f544ad

Please sign in to comment.