fix: 修复旧版 Android 闪退
This commit is contained in:
parent
5caa0d4c5d
commit
ed4f6e5ddb
|
|
@ -16,6 +16,7 @@ import androidx.compose.animation.ExperimentalAnimationApi
|
||||||
import androidx.compose.material.Surface
|
import androidx.compose.material.Surface
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import com.google.accompanist.navigation.material.ExperimentalMaterialNavigationApi
|
import com.google.accompanist.navigation.material.ExperimentalMaterialNavigationApi
|
||||||
|
|
@ -80,10 +81,11 @@ class MainActivityV2 : BaseComposeActivity() {
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
runCatching {
|
runCatching {
|
||||||
registerReceiver(
|
ContextCompat.registerReceiver(
|
||||||
|
this,
|
||||||
newMessageReceiver,
|
newMessageReceiver,
|
||||||
ReceiverUtil.createIntentFilter(NotifyJobService.ACTION_NEW_MESSAGE),
|
ReceiverUtil.createIntentFilter(NotifyJobService.ACTION_NEW_MESSAGE),
|
||||||
RECEIVER_NOT_EXPORTED
|
ContextCompat.RECEIVER_NOT_EXPORTED
|
||||||
)
|
)
|
||||||
startService(Intent(this, NotifyJobService::class.java))
|
startService(Intent(this, NotifyJobService::class.java))
|
||||||
val builder = JobInfo.Builder(
|
val builder = JobInfo.Builder(
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.widget.Toolbar
|
import androidx.appcompat.widget.Toolbar
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import butterknife.BindView
|
import butterknife.BindView
|
||||||
import butterknife.OnClick
|
import butterknife.OnClick
|
||||||
|
|
@ -62,7 +63,12 @@ class FloorActivity : BaseActivity() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
val filter = IntentFilter()
|
val filter = IntentFilter()
|
||||||
filter.addAction(ThreadActivity.ACTION_REPLY_SUCCESS)
|
filter.addAction(ThreadActivity.ACTION_REPLY_SUCCESS)
|
||||||
registerReceiver(replyReceiver, filter, RECEIVER_NOT_EXPORTED)
|
ContextCompat.registerReceiver(
|
||||||
|
this,
|
||||||
|
replyReceiver,
|
||||||
|
filter,
|
||||||
|
ContextCompat.RECEIVER_NOT_EXPORTED
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import android.widget.ImageView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.widget.Toolbar
|
import androidx.appcompat.widget.Toolbar
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.recyclerview.widget.RecyclerView.OnChildAttachStateChangeListener
|
import androidx.recyclerview.widget.RecyclerView.OnChildAttachStateChangeListener
|
||||||
import butterknife.BindView
|
import butterknife.BindView
|
||||||
|
|
@ -398,9 +399,9 @@ class ThreadActivity : BaseActivity(), View.OnClickListener, IThreadMenuFragment
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
registerReceiver(replyReceiver, IntentFilter().apply {
|
ContextCompat.registerReceiver(this, replyReceiver, IntentFilter().apply {
|
||||||
addAction(ACTION_REPLY_SUCCESS)
|
addAction(ACTION_REPLY_SUCCESS)
|
||||||
}, RECEIVER_NOT_EXPORTED)
|
}, ContextCompat.RECEIVER_NOT_EXPORTED)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ import android.content.IntentFilter
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import androidx.appcompat.widget.Toolbar
|
import androidx.appcompat.widget.Toolbar
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import butterknife.BindView
|
import butterknife.BindView
|
||||||
|
|
@ -97,9 +97,11 @@ class FloorFragment : BaseBottomSheetDialogFragment() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
val filter = IntentFilter()
|
val filter = IntentFilter()
|
||||||
filter.addAction(ThreadActivity.ACTION_REPLY_SUCCESS)
|
filter.addAction(ThreadActivity.ACTION_REPLY_SUCCESS)
|
||||||
attachContext.registerReceiver(
|
ContextCompat.registerReceiver(
|
||||||
replyReceiver, filter,
|
attachContext,
|
||||||
AppCompatActivity.RECEIVER_NOT_EXPORTED
|
replyReceiver,
|
||||||
|
filter,
|
||||||
|
ContextCompat.RECEIVER_NOT_EXPORTED
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue