fork download
  1. package com.example.thomas.beacontesting;
  2.  
  3. import android.os.RemoteException;
  4. import android.support.v7.app.ActionBarActivity;
  5. import android.os.Bundle;
  6. import android.util.Log;
  7. import android.view.Menu;
  8. import android.view.MenuItem;
  9.  
  10. import com.estimote.sdk.Beacon;
  11. import com.estimote.sdk.BeaconManager;
  12. import com.estimote.sdk.Region;
  13.  
  14. import java.util.List;
  15.  
  16.  
  17. public class MainActivity extends ActionBarActivity {
  18.  
  19. private static final String ESTIMOTE_PROXIMITY_UUID = "B9407F30-F5F8-466E-AFF9-25556B57FE6D";
  20. private static final Region ALL_ESTIMOTE_BEACONS = new Region("regionId", ESTIMOTE_PROXIMITY_UUID, null, null);
  21. private static final String TAG = "Estimote";
  22.  
  23. private BeaconManager beaconManager = new BeaconManager(this);
  24.  
  25. @Override
  26. protected void onCreate(Bundle savedInstanceState) {
  27. super.onCreate(savedInstanceState);
  28. setContentView(R.layout.activity_main);
  29.  
  30. beaconManager.setMonitoringListener(new BeaconManager.MonitoringListener() {
  31. @Override
  32. public void onEnteredRegion(Region region, List<Beacon> list) {
  33. Log.d(TAG, "ENTER: " + list.size());
  34. }
  35.  
  36. @Override
  37. public void onExitedRegion(Region region) {
  38. Log.d(TAG, "EXIT");
  39. }
  40. });
  41.  
  42. beaconManager.setBackgroundScanPeriod(5000, 2000);
  43.  
  44.  
  45. /*
  46.   beaconManager.setRangingListener(new BeaconManager.RangingListener() {
  47.   @Override
  48.   public void onBeaconsDiscovered(Region region, List<Beacon> beacons) {
  49.   Log.d(TAG, "Ranged beacons: " + beacons);
  50.   }
  51.   });
  52.   */
  53.  
  54. }
  55.  
  56. @Override
  57. protected void onStart() {
  58. super.onStart();
  59.  
  60. beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
  61. @Override public void onServiceReady() {
  62. try {
  63. beaconManager.startMonitoring(ALL_ESTIMOTE_BEACONS);
  64. } catch (RemoteException e) {
  65. e.printStackTrace();
  66. }
  67. }
  68. });
  69.  
  70. }
  71.  
  72. @Override
  73. protected void onStop() {
  74. super.onStop();
  75.  
  76. try {
  77. beaconManager.stopMonitoring(ALL_ESTIMOTE_BEACONS);
  78. } catch (RemoteException e) {
  79. e.printStackTrace();
  80. }
  81.  
  82. /*
  83.   try {
  84.   beaconManager.stopRanging(ALL_ESTIMOTE_BEACONS);
  85.   } catch (RemoteException e) {
  86.   Log.e(TAG, "Cannot stop but it does not matter now", e);
  87.   }
  88.   */
  89. }
  90.  
  91. @Override
  92. protected void onDestroy() {
  93. super.onDestroy();
  94. beaconManager.disconnect();
  95. }
  96.  
  97. @Override
  98. public boolean onCreateOptionsMenu(Menu menu) {
  99. // Inflate the menu; this adds items to the action bar if it is present.
  100. getMenuInflater().inflate(R.menu.menu_main, menu);
  101. return true;
  102. }
  103.  
  104. @Override
  105. public boolean onOptionsItemSelected(MenuItem item) {
  106. // Handle action bar item clicks here. The action bar will
  107. // automatically handle clicks on the Home/Up button, so long
  108. // as you specify a parent activity in AndroidManifest.xml.
  109. int id = item.getItemId();
  110.  
  111. //noinspection SimplifiableIfStatement
  112. if (id == R.id.action_settings) {
  113. return true;
  114. }
  115.  
  116. return super.onOptionsItemSelected(item);
  117. }
  118. }
  119.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:17: error: class MainActivity is public, should be declared in a file named MainActivity.java
public class MainActivity extends ActionBarActivity {
       ^
Main.java:3: error: package android.os does not exist
import android.os.RemoteException;
                 ^
Main.java:4: error: package android.support.v7.app does not exist
import android.support.v7.app.ActionBarActivity;
                             ^
Main.java:5: error: package android.os does not exist
import android.os.Bundle;
                 ^
Main.java:6: error: package android.util does not exist
import android.util.Log;
                   ^
Main.java:7: error: package android.view does not exist
import android.view.Menu;
                   ^
Main.java:8: error: package android.view does not exist
import android.view.MenuItem;
                   ^
Main.java:10: error: package com.estimote.sdk does not exist
import com.estimote.sdk.Beacon;
                       ^
Main.java:11: error: package com.estimote.sdk does not exist
import com.estimote.sdk.BeaconManager;
                       ^
Main.java:12: error: package com.estimote.sdk does not exist
import com.estimote.sdk.Region;
                       ^
Main.java:17: error: cannot find symbol
public class MainActivity extends ActionBarActivity {
                                  ^
  symbol: class ActionBarActivity
Main.java:20: error: cannot find symbol
    private static final Region ALL_ESTIMOTE_BEACONS = new Region("regionId", ESTIMOTE_PROXIMITY_UUID, null, null);
                         ^
  symbol:   class Region
  location: class MainActivity
Main.java:23: error: cannot find symbol
    private BeaconManager beaconManager = new BeaconManager(this);
            ^
  symbol:   class BeaconManager
  location: class MainActivity
Main.java:26: error: cannot find symbol
    protected void onCreate(Bundle savedInstanceState) {
                            ^
  symbol:   class Bundle
  location: class MainActivity
Main.java:98: error: cannot find symbol
    public boolean onCreateOptionsMenu(Menu menu) {
                                       ^
  symbol:   class Menu
  location: class MainActivity
Main.java:105: error: cannot find symbol
    public boolean onOptionsItemSelected(MenuItem item) {
                                         ^
  symbol:   class MenuItem
  location: class MainActivity
Main.java:20: error: cannot find symbol
    private static final Region ALL_ESTIMOTE_BEACONS = new Region("regionId", ESTIMOTE_PROXIMITY_UUID, null, null);
                                                           ^
  symbol:   class Region
  location: class MainActivity
Main.java:23: error: cannot find symbol
    private BeaconManager beaconManager = new BeaconManager(this);
                                              ^
  symbol:   class BeaconManager
  location: class MainActivity
Main.java:25: error: method does not override or implement a method from a supertype
    @Override
    ^
Main.java:27: error: cannot find symbol
        super.onCreate(savedInstanceState);
        ^
  symbol:   variable super
  location: class MainActivity
Main.java:28: error: package R does not exist
        setContentView(R.layout.activity_main);
                        ^
Main.java:30: error: package BeaconManager does not exist
            beaconManager.setMonitoringListener(new BeaconManager.MonitoringListener() {
                                                                 ^
Main.java:56: error: method does not override or implement a method from a supertype
    @Override
    ^
Main.java:58: error: cannot find symbol
        super.onStart();
        ^
  symbol:   variable super
  location: class MainActivity
Main.java:60: error: package BeaconManager does not exist
        beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
                                               ^
Main.java:72: error: method does not override or implement a method from a supertype
    @Override
    ^
Main.java:74: error: cannot find symbol
        super.onStop();
        ^
  symbol:   variable super
  location: class MainActivity
Main.java:78: error: cannot find symbol
        } catch (RemoteException e) {
                 ^
  symbol:   class RemoteException
  location: class MainActivity
Main.java:91: error: method does not override or implement a method from a supertype
    @Override
    ^
Main.java:93: error: cannot find symbol
        super.onDestroy();
        ^
  symbol:   variable super
  location: class MainActivity
Main.java:97: error: method does not override or implement a method from a supertype
    @Override
    ^
Main.java:100: error: package R does not exist
        getMenuInflater().inflate(R.menu.menu_main, menu);
                                   ^
Main.java:100: error: cannot find symbol
        getMenuInflater().inflate(R.menu.menu_main, menu);
        ^
  symbol:   method getMenuInflater()
  location: class MainActivity
Main.java:104: error: method does not override or implement a method from a supertype
    @Override
    ^
Main.java:112: error: package R does not exist
        if (id == R.id.action_settings) {
                   ^
Main.java:116: error: cannot find symbol
        return super.onOptionsItemSelected(item);
               ^
  symbol:   variable super
  location: class MainActivity
36 errors
stdout
Standard output is empty