Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
General Tech Technology & Software 2 years ago
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.
Turn Your Knowledge into Earnings.
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; public class AlarmManagerBroadcastReceiver extends BroadcastReceiver { private static final String ACTION = "android.provider.Telephony.SMS_RECEIVED"; @Override public void onReceive(Context context, Intent intent) { doWork(context,intent); } private void doWork(Context context, Intent intent){ //It will running a long time. } }
AndroidManifest.xml
xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.enabledisablebroadcastreceiver" android:versionCode="1" android:versionName="1.0" > android:minSdkVersion="8" android:targetSdkVersion="8" /> android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > android:name="com.code4reference.enabledisablebroadcastreceiver.EnableDisableBroadcastReceiver" android:label="@string/title_activity_enable_disable_boradcast_receiver" > <intent-filter> android:name="android.intent.action.MAIN" /> android:name="android.intent.category.LAUNCHER" /> intent-filter> android:name="com.code4reference.enabledisablebroadcastreceiver.AlarmManagerBroadcastReceiver" > <intent-filter> android:name="android.provider.Telephony.SMS_RECEIVED" /> intent-filter> android:name="android.permission.SEND_SMS"/> android:name="android.permission.RECEIVE_SMS"/>
EnableDisableBroadcastReceiver.java
package com.code4reference.enabledisablebroadcastreceiver; import android.app.Activity; import android.content.ComponentName; import android.content.pm.PackageManager; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android. REPLY 0 views 0 likes 0 shares Facebook Twitter Linked In WhatsApp
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.
General Tech 10 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 9 Answers
General Tech 2 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.