Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
499 views
in Technique[技术] by (71.8m points)

java - 为什么后台工作者服务活动处于打开状态时我的应用程序速度变慢?(Why is my app slowing down while a Background Worker Service activity is on?)

I have background service activity for scraping rss from web pages.

(我有后台服务活动,用于从网页上抓取RSS。)

And while the worker activity is on my app starts slowing down and even freezes.

(而且,当工作者活动在我的应用程序上时,它开始变慢甚至冻结。)

On my main fragment I have Recycler View.

(在我的主要片段上,我有Recycler View。)

I've tried disabaling MVVM and the observer and there were no changes.

(我尝试过使MVVM和观察器失去意义,并且没有任何变化。)

So, I guess the app slows down while the background service is running.

(因此,我猜想该应用在后台服务运行时会变慢。)

Is there any way I can fix this?

(有什么办法可以解决这个问题?)

  ask by Trajce Arsovski translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Since a Worker thread starts the activity in the main thread activity, I'll try and use IntentService class because this creates separate thread to execute the activity (independent from the main thread) and from what I red this is used among other things for downloading and uploading large files.

(由于Worker线程在主线程活动中启动了活动,因此我将尝试使用IntentService类,因为这会创建单独的线程来执行活动(独立于主线程),并且根据我的喜好,该线程还用于下载并上传大文件。)

I hope this will resolve the problem of freezing and slowing the activities related to the main thread.

(我希望这将解决冻结和减慢与主线程相关的活动的问题。)

Thank you all for your help.

(谢谢大家的帮助。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...