@kit000

Как получить новое смс?

я написал класс BroadcastReceiver, и указал его в Манифесте, он выдаёт мне ошибку
ошибка
E/ANR_LOG: >>> msg's executing time is too long
E/ANR_LOG: Blocked msg = { when=-2s425ms what=0 target=android.view.Choreographer$FrameHandler callback=android.view.Choreographer$FrameDisplayEventReceiver } , cost = 1831 ms
E/ANR_LOG: >>>Current msg List is:
E/ANR_LOG: Current msg <1> = { when=-2s399ms what=0 target=android.os.Handler callback=androidx.lifecycle.ProcessLifecycleOwner$1 }
E/ANR_LOG: Current msg <2> = { when=-1s981ms what=5 target=android.view.ViewRootImpl$ViewRootHandler obj=com.android.internal.os.SomeArgs@fcf66e }
E/ANR_LOG: Current msg <3> = { when=-1s529ms what=159 target=android.app.ActivityThread$H obj=ClientTransaction hashCode, mActivityToken = android.os.BinderProxy@2f984f9 }
E/ANR_LOG: Current msg <4> = { when=-1s529ms what=6 target=android.view.ViewRootImpl$ViewRootHandler }
E/ANR_LOG: Current msg <5> = { when=-1s422ms what=149 target=android.app.ActivityThread$H obj=android.os.BinderProxy@2f984f9 }
E/ANR_LOG: Current msg <6> = { when=-563ms what=0 target=android.view.ViewRootImpl$ViewRootHandler callback=android.app.ActivityThread$1 }
E/ANR_LOG: Current msg <7> = { when=-553ms barrier=2 }
E/ANR_LOG: Current msg <8> = { when=-475ms what=159 target=android.app.ActivityThread$H obj=ClientTransaction hashCode, mActivityToken = android.os.BinderProxy@2f984f9 }
E/ANR_LOG: Current msg <9> = { when=-415ms what=131 target=android.app.ActivityThread$H obj=android.app.ActivityThread$ProviderRefCount@5dea10f }
E/ANR_LOG: Current msg <10> = { when=+141ms what=132 target=android.app.ActivityThread$H }
E/ANR_LOG: >>>CURRENT MSG DUMP OVER<<<


мой код
class Sms : BroadcastReceiver() {
    override fun onReceive(context: Context, intent: Intent) {
        if (Telephony.Sms.Intents.SMS_RECEIVED_ACTION == intent.action) {
            for (smsMessage in Telephony.Sms.Intents.getMessagesFromIntent(intent)) {
                val message = smsMessage.messageBody
                Log.e("Message", message)
            }
        }
    }
}


манифест
spoiler

<receiver android:name=".Sms"
            android:exported="true">
            <intent-filter android:priority="100">
                <action android:name="android.provider.Telephony.SMS_RECEIVED" />
            </intent-filter>
        </receiver
>
  • Вопрос задан
  • 107 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы