so now I played a little bit with the code and this is my MainActivity for now.
But I think I am not done yet. The problem is also, that the app not recognizes the region variable in the didEnterRegion - method.
package com.example.walter.him;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Handler;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.app.Application;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.TaskStackBuilder;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import org.altbeacon.beacon.BeaconManager;
import org.altbeacon.beacon.BeaconParser;
import org.altbeacon.beacon.Identifier;
import org.altbeacon.beacon.Region;
import org.altbeacon.beacon.powersave.BackgroundPowerSaver;
import org.altbeacon.beacon.startup.RegionBootstrap;
import org.altbeacon.beacon.startup.BootstrapNotifier;
import java.util.Arrays;
import java.util.List;
public class MainActivity extends ActionBarActivity implements BootstrapNotifier
{
private static final String TAG = "AndroidProximityReferenceApplication";
private RegionBootstrap regionBootstrap;
private BackgroundPowerSaver backgroundPowerSaver;
private boolean haveDetectedBeaconsSinceBoot = false;
private andreasplatz monitoringActivity = null;
private hagentor monitoringActivity2 = null;
Typeface segoe_wp, times;
private static Button liste, info, about_us;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
liste = (Button) findViewById(R.id.liste);
info = (Button) findViewById(R.id.info);
about_us = (Button) findViewById(R.id.about_us);
segoe_wp = Typeface.createFromAsset(getAssets(), "fonts/segoe_wp.ttf");
times = Typeface.createFromAsset(getAssets(), "fonts/times.ttf");
liste.setTypeface(segoe_wp);
info.setTypeface(segoe_wp);
about_us.setTypeface(segoe_wp);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setLogo(R.drawable.ic_launcher);
getSupportActionBar().setDisplayUseLogoEnabled(true);
BeaconManager beaconManager = org.altbeacon.beacon.BeaconManager.getInstanceForApplication(this);
beaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));
Region museumLocation1 = new Region("museumLocation1", Identifier.parse("B9407F30-F5F8-466E-AFF9-25556B57FE6D"), Identifier.parse("56170"), Identifier.parse("42307"));
Region museumLocation2 = new Region("museumLocation2", Identifier.parse("B9407F30-F5F8-466E-AFF9-25556B57FE6D"), Identifier.parse("55787"), Identifier.parse("12089"));
List regionList = Arrays.asList(new Region[]{museumLocation1, museumLocation2});
regionBootstrap = new RegionBootstrap(this, regionList);
backgroundPowerSaver = new BackgroundPowerSaver(this);
onClickOpenInfo();
onClickOpenListe();
onClickOpenAbout();
}
public void didEnterRegion(Region arg0) {
// Cannot resolve symbol 'region'
if (region.getUniqueId().equals("museumLocation1")) {
Intent intent = new Intent(this, andreasplatz.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
}
if (region.getUniqueId().equals("museumLocation2")) {
Intent intent = new Intent(this, hagentor.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
}
haveDetectedBeaconsSinceBoot = true;
}
@Override
public void didExitRegion(Region region) {
}
@Override
public void didDetermineStateForRegion(int i, Region region) {
}
private void sendNotification() {
NotificationCompat.Builder builder =
new NotificationCompat.Builder(this)
.setContentTitle("Beacon Reference Application")
.setContentText("An beacon is nearby.")
.setSmallIcon(R.drawable.ic_launcher);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addNextIntent(new Intent(this, andreasplatz.class));
PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(
0,
PendingIntent.FLAG_UPDATE_CURRENT
);
builder.setContentIntent(resultPendingIntent);
NotificationManager notificationManager =
(NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(1, builder.build());
}
public void setMonitoringActivity(andreasplatz activity) {
this.monitoringActivity = activity;
}
public void onClickOpenInfo()
{
info = (Button)findViewById(R.id.info);
info.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent openInfo = new Intent("com.example.walter.him.info_ausstellung");
startActivity(openInfo);
}
}
);
}
public void onClickOpenListe()
{
liste = (Button) findViewById(R.id.liste);
liste.setOnClickListener(
new View.OnClickListener()
{
public void onClick (View v)
{
Intent openListe = new Intent("com.example.walter.him.liste_orte");
startActivity(openListe);
}
}
);
}
public void onClickOpenAbout()
{
about_us = (Button) findViewById(R.id.about_us);
about_us.setOnClickListener(
new View.OnClickListener()
{
public void onClick (View v)
{
Intent openAbout = new Intent("com.example.walter.him.about_us");
startActivity(openAbout);
}
}
);
}
}