请注意,我对 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
等等......当然,应用程序可以是一个活动或服务......我只是不知道该怎么做,所以我可以通过每个位置管理器运行位置感应 - 单独且彼此独立。
谢谢并保重!:)
真诚的,彼得。
==================================================== ==============================
编辑:
那么以下为了节省电池寿命是多余的吗?:
"下面的六个场景。为简单起见,我们使用 {(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
如果这不是多余的,那么如何实施呢?:)
再次感谢!