简体   繁体   English

如何创建可以确定用户何时离开家的 android 应用程序?

[英]How can I create an android application which can determine when a user has left their house?

I want to create an application that can determine when a user is leaving their house and remind them to take a plastic bag.我想创建一个可以确定用户何时离开家并提醒他们带上塑料袋的应用程序。 I have never created an application which uses the Google Maps SDK and am stumped as to how I can make the user set their location.我从未创建过使用 Google 地图 SDK 的应用程序,并且对于如何让用户设置他们的位置感到困惑。 Are there any resources like websites or books from where I can learn the skills I need to create such an app?是否有任何资源,例如网站或书籍,我可以从中学习创建此类应用程序所需的技能?

I want the final application to simply send a notification when the user has left their house.我希望最终应用程序在用户离开家时简单地发送通知。

Please do suggest an alternate method if you know one.如果您知道,请建议另一种方法。 For example, I thought of using wifi to send a notification, if the user leaves their house and disconnects from the wifi they will receive a notification.例如,我想使用 wifi 发送通知,如果用户离开家并断开 wifi 连接,他们将收到通知。

Don't ask for location permission in your app, users are often reluctant to give this permission, unless they have a very good reason to do so.不要在你的应用中请求位置权限,用户通常不愿意给予这个权限,除非他们有很好的理由这样做。

Checking for WiFi disconnection seems like a good idea.检查 WiFi 断开连接似乎是个好主意。

You can listen for changes in network connectivity using an intent filter with ConnectivityManager.CONNECTIVITY_ACTION .您可以使用带有ConnectivityManager.CONNECTIVITY_ACTION的意图过滤器来监听网络连接的变化。 Register for these events in your main activity's onResume() :在主要活动的onResume()中注册这些事件:

IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
this.getApplicationContext().registerReceiver(yourWifiBroadcastListener, filter);

And don't forget to unregister in onPause()并且不要忘记在onPause()中取消注册

@Override
public void onPause() {
    this.getApplicationContext().unregisterReceiver(yourWifiBroadcastListener);
}

yourWifiBroadcastListener is an instance of your subclass of android.content.BroadcastReceiver in which you override onReceive() as needed: yourWifiBroadcastListenerandroid.content.BroadcastReceiver的子类的一个实例,您可以根据需要在其中覆盖onReceive()

@Override
public void onReceive(Context context, Intent intent) {

    //Check wether device is connected to WiFi network 
    //and notify user on disconnection 
}

This is actually a really difficult thing to do, especially just with software.这实际上是一件非常困难的事情,尤其是对于软件而言。


GPS is maybe not the way - Consider that GPS does not work well indoors (it is 2D), and even A-GPS will have issues locating you accurately or at all in some areas, also polling GPS means you will likely get delayed updates, and it also kills battery, and added to that, no one wants you constantly tracking them so you can figure out if they need to bring a plastic bag, so perhaps you need some kind of proximity indicator instead. GPS 可能不是这样 - 考虑到 GPS 在室内不能很好地工作(它是 2D 的),甚至 A-GPS 也会在某些区域准确定位或根本无法定位您,轮询 Z8C578DE37278ADA488D763EAZC 意味着您可能会延迟更新,5208D763EAZC而且它还会消耗电池,此外,没有人希望你经常跟踪它们,这样你就可以确定他们是否需要带一个塑料袋,所以也许你需要某种接近指示器。

Maybe listen for some kind of RF?也许听某种射频? - You could consider using BLE or UWB, and the User having a "beacon" in their home, that would be great in theory, but again no one will buy a beacon just to be reminded to bring a plastic bag. - 您可以考虑使用 BLE 或 UWB,并且用户在家中有一个“信标”,理论上这会很棒,但没有人会购买信标只是为了提醒带一个塑料袋。

Perhaps you could use the RSSI to their home wifi network (get them to identify it in your app), and when they are "far enough away" for a few seconds (or whatever works), send the notification - it's not perfect but if you combine it with other location solutions you could do something也许您可以将 RSSI 用于他们的家庭 wifi 网络(让他们在您的应用程序中识别它),当他们“足够远”几秒钟(或其他任何工作)时,发送通知 - 这并不完美,但如果您将它与其他定位解决方案结合起来,您可以做一些事情

You could combine approaches like these with the actual times that users typically leave their house - most people will go to work at the same time every day, maybe you could also set some kind of job to kick off at a "typical" time people leave the house, that might improve your performance a little您可以将这些方法与用户通常离开家的实际时间结合起来 - 大多数人会 go 每天在同一时间工作,也许您也可以设置某种工作在人们离开的“典型”时间开始房子,这可能会提高你的表现

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在可以左右滑动的android应用程序中创建GridView - How can I create a GridView in android application which can slide left and right 如何创建从右到左语言的多语言Android应用程序? - How can I create a multilingual android application for right to left languages? 如何确定哪个用户安装了android应用程序? - How to determine which user installed the android application? 安卓 如何确定用户闲置了多长时间? - Android. how can I determine how long a user has been inactive? 如何确定我的Android应用程序是否有内存泄漏? - How can I determine if my android app has memory leak? Android:如何确定应用程序启动时没有信号或没有服务? - Android: How can I determine if Application starts with no signal or no service? Android:如何确定应用程序是否以无GSM信号或低GSM信号启动? - Android: How can I determine if an application starts with no or low GSM signal? 如何在我的Android应用程序中确定Internet速度 - how can i determine internet speed in my android application Android:如何检测用户何时向左触摸视图区域的20%? - android: how can I detect when user touch left 20% of view area? 如何确定应用程序何时运行? - How can i determine when my application is running?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM