【发布时间】:2013-06-30 12:40:06
【问题描述】:
请注意,我对 Android 非常陌生。
我正在尝试通过限制位置感应等来研究节省电池寿命的方法...为此,我想“搭载”多个基于位置的应用程序的位置感应。我想要实现的是模拟多个这样的应用程序,每个应用程序都有自己的 LocationListener - LocationManager 来自应用程序上下文,我想尝试生成新的应用程序,就好像我正在实例化对象一样 - 从单个活动。 这里重要的是,我可以将大量不同的应用程序上下文存储在数组或列表中。
所以,简而言之,一种按照以下方式做事的方法:
Vector<Application> applications = new Vector<Application>();
applications.add( new Application() );
applications.add( new Application() );
// here new Application would only be an object which extends Application
等等......当然,应用程序可以是一个活动或服务......我只是不确定如何去做,所以我可以通过 LocationManager 在每个中运行位置感应 - 单独且独立于每个其他。
谢谢,保重! :)
真诚地, 彼得。
================================================ ================================
编辑:
那么为了节省电池寿命,以下是多余的吗?:
"的以下六个场景。为简单起见,我们使用符号 {(Maintained states), Incoming state} 表示每个场景。我们 使用 (t, T0, D0) 表示传入的请求,其中 t 是时间, T0 为请求的更新时间间隔,D0 为请求的更新时间间隔 距离间隔。对于维护的状态,我们使用 (Gps, T1, D1) 表示 Gps 状态,最佳时间间隔为 T1 和 最佳距离区间为 D1。我们用 (Net, T2, D2) 来表示 最佳时间间隔为 T2 和最佳时间间隔的网络状态 距离间隔为 D2。”
• {(Gps), Gps}: The prototype checks whether the (Gps, T1, D1)
state is valid. If so, then it compares (T1, D1) to (T0, D0). If
T1 < T0 and D1 < D0, then piggybacking is enabled, and the
piggybacking time is calculated.
• {(Gps), Net}: As Net typically has coarser location information
than Gps, the operations are similar to the ({Gps},Gps) scenario,
but the comparison is between (T2, D2) and (T0, D0).
• {(Net), Net}: Similar to {(Gps), Gps} case by replacing Gps
with Net.
• {(Net), Gps}: Since Gps is typically finer than Net, the request
cannot piggyback on existing Net registrations. The new registration is passed through immediately.
• {(Gps, Net), Gps}: Similar to {(Gps), Gps}.
• {(Gps,Net), Net}: The prototype firstly checks the Net state,
which is similar to that of {(Net), Net}. If not possible to piggyback, then it checks the Gps state, which is similar to {(Gps),
Net} scenario.
伪代码:
(c) Sensing Piggybacking (SP)
Variables
StateGps: Gps registration state
StateNet: Net registration state
time: Requested location sensing frequency
dist: Requested location sensing distance
1 Received requestLocationUpdate(provider, time, dist,...)
2 Store information about provider, time, distance
3 Check validity of StateGps and StateNet
4 If provider == Gps
5 Compare StateGps to time and dist
6 If StateGps allows piggybacking
7 Delays the registration to enable piggybacking
8 End
9 Else // provider == Net
10 Compare StateNet to time and dist
11 If StateNet allows piggybacking
12 Delays the registration to enable piggybacking
13 Else
14 Compare StateGps to time and dist
15 If StateGps allows piggybacking
16 Delays the registration to enable piggybacking
17 End
18 End
19 End
如果这不是多余的,那么如何实施呢? :)
再次感谢!
【问题讨论】:
-
您是否正在尝试即时启动新的应用程序实例并向它们提供您的“缓存”位置数据?
-
我想要的本质上是从一个动态的对象中实例化它们——一个包含位置感应功能的对象,然后将每个实例存储在一个列表中以供访问。
标签: android android-activity android-service android-location