Когда я нажимаю кнопку, он вызывает функцию setProximityAlert()
, а затем отображается тост. Я не понимаю, где проблема,Когда я нажимаю кнопку «Пуск» для реакции близости, он сбрасывает мое приложение
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.locations);
Button start = (Button) findViewById(R.id.startl);
start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setProximityAlert();
Toast.makeText(getBaseContext(), "Started", Toast.LENGTH_LONG).show();
}
});
}
private static final String MMH_PROXIMITY_ALERT = "com.example.ProximityAlert";
private void setProximityAlert() {
Cursor c = db.rawQuery("SELECT * from locations", null);
Double lng = c.getDouble(c.getColumnIndex("longitude"));
c.moveToNext();
Double lat = c.getDouble(c.getColumnIndex("latitude"));
c.moveToNext();
Float rds = c.getFloat(c.getColumnIndex("radius"));
c.moveToNext();
String locService = Context.LOCATION_SERVICE;
LocationManager locationManager;
locationManager = (LocationManager)getSystemService(locService);
long expiration = -1; // do not expire
Intent intent = new Intent(MMH_PROXIMITY_ALERT);
PendingIntent proximityIntent = PendingIntent.getBroadcast(this, -1, intent, 0);
locationManager.addProximityAlert(lat, lng, rds, expiration, proximityIntent);
c.close();
locationManager.addProximityAlert(
lat, // the latitude of the central point of the alert region
lng, // the longitude of the central point of the alert region
rds, // the radius of the central point of the alert region, in meters
expiration, // time for this proximity alert, in milliseconds, or -1 to indicate no expiration
proximityIntent // will be used to generate an Intent to fire when entry to or exit from the alert region is detected
);
IntentFilter filter = new IntentFilter(MMH_PROXIMITY_ALERT);
registerReceiver(new ProximityIntentReceiver(), filter);
}
Какая ошибка в окне logcat? –
И можете ли вы предоставить свой файл манифеста здесь? –
как отправить журнал cat plz help слишком большой для комментариев – sarfraz