我遵循了本教程:https : //developer.android.com/training/location/geofencing,并且在Android <8上可以正常工作,但是在Oreo中,由于新的操作系统背景限制,我遇到了问题。
How can I get geofence transition triggers when app is in background?
I also tried to use a BroadcastReceiver instead of IntentService, but the result is the same.
Pending Intent:
private val geofencePendingIntent: PendingIntent by lazy {
val intent = Intent(context, GeofenceBroadcastReceiver::class.java)
intent.action = "com.example.GEOFENCE_TRANSITION"
PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)
}
Run Code Online (Sandbox Code Playgroud)
Register geofence:
geofencingClient.addGeofences(request, geofencePendingIntent).run {
addOnSuccessListener {
Log.d(TAG, "Geofence added")
}
addOnFailureListener {
Log.e(TAG, "Failed to create geofence")
}
}
Run Code Online (Sandbox Code Playgroud)
Broadcast Receiver:
class GeofenceBroadcastReceiver …Run Code Online (Sandbox Code Playgroud) 我有一个带有子模块的 Flutter 项目:
- root Flutter project
- Flutter module 1
- Flutter module 2
...
- Flutter module N
Run Code Online (Sandbox Code Playgroud)
每个模块都包含用 注释的类@JsonSerializable()。
目前我用这个脚本构建模型:
for dir in [DIR_LIST]
do
echo "Building models in ${dir}"
cd ${BASE_DIR}/${dir}
flutter packages pub run build_runner build --delete-conflicting-outputs
done
Run Code Online (Sandbox Code Playgroud)
有没有办法在根目录中使用单个命令构建项目中的每个子模块,而不是循环每个目录?