简体   繁体   English

Xamarin Android背景指南

[英]Xamarin Android Backgrounding Guidance

I thank everyone that helped me on my last question. 我感谢在我最后一个问题上对我有帮助的所有人。 I have been reading a lot about Android programming and backgrounding tasks and I have a few doubts about this diagram: http://docs.xamarin.com/guides/cross-platform/application_fundamentals/backgrounding/part_9_android_backgrounding_guidance/Images/image22.png 我已经阅读了很多有关Android编程和后台任务的信息,对此图我有一些疑问: http : //docs.xamarin.com/guides/cross-platform/application_fundamentals/backgrounding/part_9_android_backgrounding_guidance/Images/image22.png

Which can be found on : http://docs.xamarin.com/guides/cross-platform/application_fundamentals/backgrounding/part_9_android_backgrounding_guidance/ 可以在以下网址找到: http : //docs.xamarin.com/guides/cross-platform/application_fundamentals/backgrounding/part_9_android_backgrounding_guidance/

  1. According to the diagram if I want to do cleanup tasks on an Activity I should de them on the "OnPause" event but make it fast: if it thakes them a long time it will freeze the layout? 根据该图,如果我想在一个Activity上执行清理任务,则应在“ OnPause”事件上将其删除,但要使其速度更快:如果长时间拖延它们,它将冻结布局吗? Is there a chance my app will be forcefully finished before the cleanup can finish? 我的应用程序是否有可能在清理完成之前被强制完成?

  2. Why I don't want to run a task on an Activity when it is backgrounded? 为什么我不想在有背景的活动上运行任务? At first I thought that it was because it would stop working but I see that if I don't stop my code it will keep running but it is not the case. 起初我以为是因为它将停止工作,但是我看到如果不停止我的代码,它将继续运行,但事实并非如此。 Why should I use a service if a I can keep doing tasks even if my Activity is backgrounded? 如果即使我的活动处于后台也可以继续执行任务,为什么还要使用服务?

  3. In the case of the remote services branch of the diagram: the Messenger serves what purpose other than send Messages to the Service? 对于该图的远程服务分支:Messenger除了将消息发送到服务之外,还起到什么作用? Can I receive information from the service using Messages or I need another way to get answers from the service? 我可以使用消息从服务中接收信息,还是需要另一种方式来从服务中获取答案?

  4. Another about remote: I read the AIDL that is mentioned is not supported by Xamarin at the moment, how can I implement it? 关于远程的另一个问题:我阅读了Xamarin目前不支持的提到的AIDL,我该如何实现呢?

  5. In the case of starting a long-running task: I should use a service so to ensure that my task will be done? 在启动长期运行的任务时:我应该使用服务来确保我的任务能够完成吗?

  6. How can I start a Service at device boot-up? 在设备启动时如何启动服务?

  7. If Android forces a sticky service to restart: all objects bound to it are still bound? 如果Android强制重新启动粘性服务:绑定到该服务的所有对象仍然都绑定了? Or I have to bound them again? 还是我必须再次束缚他们?

  8. Can I send objects to a Service? 我可以将对象发送到服务吗?

I know, a lot of questions. 我知道,很多问题。 Most of them were asked by my boss so I want to give him the best answers. 他们中的大多数是我老板问的,所以我想给他最好的答案。

Thanks in advance!!! 提前致谢!!!

[Edit: 20140320] Some answers, if I am wrong please tell me. [编辑:20140320]一些答案,如果我错了,请告诉我。

  1. Android can Destroy backgrounded activities if it sees fit. 如果合适,Android可以销毁后台活动。

  2. Same as 1 与1相同

  3. Do any of you have a nice example using Server Messengers in Xamarin? 你们中有没有人在Xamarin中使用Server Messengers有一个很好的例子?

  4. Guess that it is same as 1 and 2. A backgrounded Activity will be destroyed if Android sees fit. 猜猜它与1和2相同。如果Android认为合适,背景化的Activity将被销毁。 A Service could survive more than the calling activity. 服务可以比呼叫活动生存更多。

[Edit: 20140320] Some answers, if I am wrong please tell me. [编辑:20140320]一些答案,如果我错了,请告诉我。

Android can Destroy backgrounded activities if it sees fit. 如果合适,Android可以销毁后台活动。

Same as 1 与1相同

Do any of you have a nice example using Server Messengers in Xamarin? 你们中有没有人在Xamarin中使用Server Messengers有一个很好的例子?

Guess that it is same as 1 and 2. A backgrounded Activity will be destroyed if Android sees fit. 猜猜它与1和2相同。如果Android认为合适,背景化的Activity将被销毁。 A Service could survive more than the calling activity. 服务可以比呼叫活动生存更多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM