我需要根据用户与特定位置的接近程度以及其他一些规则(如果该区域有任何特定消息)向用户发送特定消息.例如,用户上车并开始工作.当他到达工作岗位的那一刻,他会得到某种消息,如果有消息要传递的话.这就是我的想法(当我在我的应用程序的其他部分工作时,没有代码只是试图设计流程)
收听重要的位置更改,每次发生这种情况时,都会将用户的地理位置发送到服务器,以查看是否有任何消息要在该位置附近发送.不行.由于过度使用收音机,这会耗费太多电池.
每天保存消息区域,并在每个重要位置更改对本地存储的数据进行测试.如果有任何匹配那么联系服务器.理论上听起来更好.
问题:
百万感谢任何花时间清理这些东西的人.
编辑:额外问题7.区域监测,添加了大量区域对系统有任何影响?说有2个地区对100个地区?
如何从多个地理位置(长,纬度值)创建多边形地理围栏.此外,如何跟踪用户进入此地理围栏区域或从android上的此区域退出.
我开始使用谷歌播放服务的地理围栏API.我想我理解了一般概念,但我无法确定地理围栏是否存在限制.我将地理列表列表提供给位置客户端,然后处理其余的.但是我可以将多少地理围栏传递给位置客户端?我想要多少?
我正在开发一个接收给定地址的Android应用程序.我想只允许应用程序在设备上运行,如果用户在该地址上,或者更接近它.
这可能只与google maps api有关吗?
您好我正在尝试在Android中添加Geo Fence的功能.我正在使用http://developer.android.com/training/location/geofencing.html来创建和监控Geo Fences.我正在使用IntentService警报(已输入/退出),但对我来说它不起作用.
但是当我离开并回到地区测试它然后它对我不起作用.我已打开设备的GPS,但设备未与互联网连接.
任何人都可以帮助我让它更准确,更完美,没有任何问题.
public class MainActivity extends Activity implements GooglePlayServicesClient.ConnectionCallbacks,
GooglePlayServicesClient.OnConnectionFailedListener,
LocationClient.OnAddGeofencesResultListener {
private LocationClient locationClient;
private String TAG = "MainActivity";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
int resp = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (resp == ConnectionResult.SUCCESS) {
locationClient = new LocationClient(this, this, this);
locationClient.connect();
}
}
@Override
public void onConnected(Bundle bundle) {
ArrayList<Store> storeList = getStoreList();
if (null != storeList && storeList.size() > 0) {
ArrayList<Geofence> geofenceList = new ArrayList<Geofence>();
for (Store store …Run Code Online (Sandbox Code Playgroud) 如何检测Mock LocationAndroid中是否触发了位置Marshmallow?
以前,我用过 Settings.Secure.ALLOW_MOCK_LOCATION
但是,在API级别23中,这已被弃用.
我想检查触发器是否位于假位置或原始GPS?
现在,检查是否Mock Location启用的替代方法是Android Marshmallow什么?
我即将实现地理围栏的功能,在我完成任何认真的工作之前,我需要知道在第一次转换后地理围栏是否仍然有效.
该功能的核心是:
每次我在点P的x米范围内(称之为区域A),我都希望动作B出现.
我需要知道的是
Geofence.NEVER_EXPIRE并确保每次进入指定区域时都会获得PendingIntent,无论是否经过时间,重新启动等等要么
我希望前者是这样的
android geofencing google-play-services android-geofence location-client
我正在调试一个位置感知应用程序,我想得到一个当前正由系统监控的Geofences列表 - 即使我只能看到我自己的软件包的Geofences.代码使用的是GoogleApiClient,因此使用了FusedLocation.
我试过adb shell dumpsys location哪个有"Geofences:"的输出部分,但它总是空的.我假设这是遗留位置/地理围栏/邻近.
我也尝试过只adb shell dumpsys搜索该文件以获取地理围栏,但我一无所获.
这两个命令都是在启动应用程序并成功添加要监视的栅栏后运行的.可以在此处找到实现的示例:https://github.com/androidfu/GeofenceExample
我真的不明白课setInitialTrigger上的功能GeofencingRequest.
我知道我们可以创建一些Geofence不同过渡的对象:
这对我来说没问题,也可以接受.
现在,我的问题是相对于班级GeofencingRequest,更确切地说是方法setInitialTrigger.我真的不明白我们应该放在那里的价值...... Android文档(这里)对于该方法的含义并没有多大帮助.
想象一下,我有这段代码:
private GeofencingRequest getGeofencingRequest() {
GeofencingRequest.Builder builder = new GeofencingRequest.Builder();
builder.setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER);
builder.addGeofences(mGeofenceList);
return builder.build();
}
Run Code Online (Sandbox Code Playgroud)
是什么意思GeofencingRequest.INITIAL_TRIGGER_ENTER?
对我来说,这意味着,GeofencingRequest应该触发任何Geofence具有ENTER转换的对象.
但想象一下,我有多个Geofence,具有不同的行为ENTER或EXIT转换.
我应该如何使用GeofencingRequest Builder处理/实现?
我遵循了本教程: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) geofencing ×10
android ×9
geolocation ×3
gps ×3
adb ×1
google-maps ×1
ios ×1
java ×1
location ×1