Posted on 16 Aug 2022, this text provides information on Technology & Software related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
The function doWork maybe run 20s, I think the system will cause ANR problem. I don't know what kind of technology I need use to prevent ANR, AyncTask, local server, thread, IntentService or others. Could you give me some sample codes? Thanks!
AlarmManagerBroadcastReceiver.java
package com.code4reference.enabledisablebroadcastreceiver;import android.content.BroadcastReceiver;import android.content.Context;import android.content.Intent;publicclassAlarmManagerBroadcastReceiverextendsBroadcastReceiver{privatestaticfinalString ACTION ="android.provider.Telephony.SMS_RECEIVED";@Overridepublicvoid onReceive(Contextcontext,Intentintent){
doWork(context,intent);}privatevoid doWork(Contextcontext,Intentintent){//It will running a long time.}}
No matter what stage you're at in your education or career, TuteeHUB will help you reach the next level that
you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice
sessions to improve your knowledge and scores.
manpreet
Best Answer
2 years ago
The function doWork maybe run 20s, I think the system will cause ANR problem. I don't know what kind of technology I need use to prevent ANR, AyncTask, local server, thread, IntentService or others. Could you give me some sample codes? Thanks!
AlarmManagerBroadcastReceiver.java
AndroidManifest.xml
EnableDisableBroadcastReceiver.java