locked
怎样使程序保持运行状态? RRS feed

  • 问题

  • 我有个重力感应的程序, 手机一黑屏,程序就停止运行了, 有什么办法能保持运行? 就像挂qq一样
    2011年8月29日 2:11

答案

  • 更简单的实现方法是设定应用程序运行时,手机不执行自动锁屏。即设置应用程序的属性,使手机设备自动忽略用户闲置状态。

    PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disable;


    Cedar
    2011年8月29日 6:45
    版主

全部回复

  • 可以考虑设定程序后台代理执行Background Agents 。

    Scheduled Task Type

    Description

    PeriodicTask

    Periodic agents run for a small amount of time on a regular recurring interval. Typical scenarios for this type of task include uploading the device’s location and performing small amounts of data synchronization.

    ResourceIntensiveTask

    Resource-intensive agents run for a relatively long period of time when the phone meets a set of requirements relating to processor activity, power source, and network connection. A typical scenario for this type of task is synchronizing large amounts of data to the phone while it is not being actively used by the user.

     

    Noteworthy APIs for Use with Scheduled Tasks

    GeoCoordinateWatcher

    This API, used for obtaining the geographic coordinates of the device, is supported for use in background agents, but it uses a cached location value instead of real-time data. The cached location value is updated by the device every 15 minutes.

     

    请参考

    Background Agent Best Practices for Windows Phone

    http://msdn.microsoft.com/en-us/library/hh202944(v=VS.92).aspx

    Background Agents Overview for Windows Phone

    http://msdn.microsoft.com/en-us/library/hh202942(v=VS.92).aspx


    Cedar
    2011年8月29日 6:36
    版主
  • 更简单的实现方法是设定应用程序运行时,手机不执行自动锁屏。即设置应用程序的属性,使手机设备自动忽略用户闲置状态。

    PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disable;


    Cedar
    2011年8月29日 6:45
    版主
  • 谢谢解答, 讲得很清楚

    2011年8月30日 3:00