capacitor-android
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCapacitor & Android Native Bridge Skill
Capacitor & Android Native Bridge 技能
This skill enables the assistant to handle the complex interaction between the Web layer (React) and the Native layer (Java/Android) specifically for background tracking.
该技能可让助手处理Web层(React)与原生层(Java/Android)之间针对后台追踪的复杂交互。
Knowledge Areas
知识领域
1. Android Foreground Services
1. Android Foreground Services
- Lifecycle Management: Start/stop/restart logic for .
LocationTrackingService.java - Notifications: Maintaining persistent notifications required by Android for foreground tasks.
- Boot Persistence: Implementing receivers to restart tracking on device reboot.
BOOT_COMPLETED
- 生命周期管理: 的启动/停止/重启逻辑。
LocationTrackingService.java - 通知: 维护Android前台任务所需的持久化通知。
- 开机持久化: 实现接收器,在设备重启后重新启动追踪。
BOOT_COMPLETED
2. Battery & Power Management
2. Battery & Power Management
- Wakelocks: Smart management of to balance tracking consistency with battery life.
PARTIAL_WAKE_LOCK - Doze Mode: Using for reliable 60s intervals.
AlarmManager.setExactAndAllowWhileIdle() - Optimization Whitelisting: Handling .
REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
- 唤醒锁: 智能管理,平衡追踪一致性与电池续航。
PARTIAL_WAKE_LOCK - 休眠模式: 使用实现可靠的60秒间隔。
AlarmManager.setExactAndAllowWhileIdle() - 优化白名单: 处理请求。
REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
3. Capacitor Plugin Development
3. Capacitor Plugin Development
- Bridge Communication: Efficiently passing data between and React.
ProTrackingPlugin.java - Native-to-Web Events: Using for real-time status updates in the UI.
notifyListeners
- 桥接通信: 在与React之间高效传递数据。
ProTrackingPlugin.java - 原生到Web事件: 使用在UI中实现实时状态更新。
notifyListeners
4. Background Geolocation
4. Background Geolocation
- Providers: Fine-tuning settings (Priority, Interval, FastestInterval).
FusedLocationProviderClient - Permissions: Managing granular location permissions (Fine, Background) and notification permissions.
- 位置提供商: 微调的设置(优先级、间隔、最快间隔)。
FusedLocationProviderClient - 权限管理: 管理精细化位置权限(精确位置、后台位置)以及通知权限。
Guidelines for Responses
响应指南
- When modifying Java code, ensure Thread Safety (especially for network calls and location updates).
- Always recommend releasing Wakelocks when the GPS fix is obtained or if a timeout occurs.
- Suggest exponential backoff for failed HTTP requests in .
LocationApiClient.java - Keep in mind Android 14+ requirements (Foreground Service Types).
- 修改Java代码时,确保线程安全(尤其是网络调用和位置更新场景)。
- 建议在获取到GPS定位或发生超时后,始终释放唤醒锁。
- 建议为中的失败HTTP请求实现指数退避策略。
LocationApiClient.java - 注意Android 14+的要求(前台服务类型)。