我有一个以Google的地理围栏示例代码开头的应用.它可以工作几天,我得到了所有过渡意图,正如我预期的那样.然而,经过一段时间,比如3天,应用程序停止了这些意图,我不知道为什么.
当我创建我的围栏时,我将到期时间设置为Geofence.NEVER_EXPIRE
这是我的IntentService,我在它停止工作之前获得转换意图:
public class ReceiveTransitionsIntentService extends IntentService {
@Override
protected void onHandleIntent(Intent intent) {
Intent broadcastIntent = new Intent();
broadcastIntent.addCategory(GeofenceUtils.CATEGORY_LOCATION_SERVICES);
// First check for errors
if (LocationClient.hasError(intent)) {
...handle errors
} else {
// Get the type of transition (entry or exit)
int transition = LocationClient.getGeofenceTransition(intent);
// Test that a valid transition was reported
if ((transition == Geofence.GEOFENCE_TRANSITION_ENTER)
|| (transition == Geofence.GEOFENCE_TRANSITION_EXIT)) {
// Post a notification
NEVER GETS HERE
} else {
...log error
}
}
}
} …Run Code Online (Sandbox Code Playgroud) 我是Firemonkey和Android的新手,我不知道我的方法是否错误.我希望有一个应用程序运行并读取NFC标签.
有没有办法在带有firemonkey的Android设备中使用NFC阅读器?
使用FMXExpress的NFCAdapter的一部分(http://www.fmxexpress.com/full-android-sdk-interface-files-in-object-pascal-for-firemonkey/),我可以确定该设备是否具有NFC读卡器如果它已启用.但是要使用所有函数,我必须手动定义所有接口并解决所有循环引用.我不认为这可以导致一个探针解决方案.
我正面临着构建我自己的JavaClass以与nfc适配器通信的解决方案,如本博客文章所述:http://blong.com/Articles/DelphiXE5AndroidActivityResult/ActivityResult.htm#Building
我想在他靠近特定位置时提醒用户.为此,我在我的应用程序中包含了ProxmityAlert和相应的服务.但无论我给出什么样的坐标,它总是向我显示"感谢您访问我的区域!!进入"我这样做是错误的吗?
这就是我这样做的方式:
public class ProxTest extends Activity {
LocationManager lm;
double lat = 30.085514, long1 = 77.082603;
float radius = 50;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lm = (LocationManager) getSystemService(LOCATION_SERVICE);
Intent i = new Intent();
i.setAction("com.example.test.proximityalert");
PendingIntent pi = PendingIntent.getBroadcast(getApplicationContext(),
-1, i, 0);
lm.addProximityAlert(lat, long1, radius, -1, pi);
sendBroadcast(i);
System.out.println("Prox alert added ");
}
Run Code Online (Sandbox Code Playgroud)
}
这是接收者:
public class ProximityReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context arg0, Intent arg1) {
// TODO Auto-generated method stub
String k …Run Code Online (Sandbox Code Playgroud)