Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android iBeacon示例代码无法生成_Android_Ibeacon Android_Altbeacon_Android Ibeacon - Fatal编程技术网

Android iBeacon示例代码无法生成

Android iBeacon示例代码无法生成,android,ibeacon-android,altbeacon,android-ibeacon,Android,Ibeacon Android,Altbeacon,Android Ibeacon,嗨,我正在使用来自的示例代码,但在构建应用程序时出错。我已经下载了最新的iBeacon库android-beacon-library-2.7.tar.gz,并按照网站上的解释添加到项目中 这是主要的活动 package com.example.ibeacontest; import android.util.Log; import org.altbeacon.beacon.BeaconConsumer; import org.altbeacon.beacon.BeaconManager; i

嗨,我正在使用来自的示例代码,但在构建应用程序时出错。我已经下载了最新的iBeacon库
android-beacon-library-2.7.tar.gz
,并按照网站上的解释添加到项目中

这是主要的活动

package com.example.ibeacontest;

import android.util.Log;

import org.altbeacon.beacon.BeaconConsumer;
import org.altbeacon.beacon.BeaconManager;
import org.altbeacon.beacon.MonitorNotifier;
import org.altbeacon.beacon.startup.BootstrapNotifier;

import android.app.Activity;
import android.graphics.Region;
import android.os.Bundle;
import android.os.RemoteException;
import android.view.Menu;
import android.view.MenuItem;

public class MainActivity extends Activity  implements BeaconConsumer {
    protected static final String TAG = "MonitoringActivity";
    private BeaconManager beaconManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
                beaconManager = BeaconManager.getInstanceForApplication(this);
        // To detect proprietary beacons, you must add a line like below corresponding to your beacon
        // type.  Do a web search for "setBeaconLayout" to get the proper expression.
        // beaconManager.getBeaconParsers().add(new BeaconParser().
        //        setBeaconLayout("m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"));
        beaconManager.bind(this);
    }
    @Override 
    protected void onDestroy() {
        super.onDestroy();
        beaconManager.unbind(this);
    }


    public void onBeaconServiceConnect() {
        beaconManager.setMonitorNotifier(new MonitorNotifier() {

        public void didEnterRegion(Region region) {
            Log.i(TAG, "I just saw an beacon for the first time!");        
        }

        public void didExitRegion(Region region) {
            Log.i(TAG, "I no longer see an beacon");
        }

        public void didDetermineStateForRegion(int state, Region region) {
            Log.i(TAG, "I have just switched from seeing/not seeing beacons: "+state);        
            }
        });

        try {
            beaconManager.startMonitoringBeaconsInRegion(new Region("myMonitoringUniqueId", null, null, null));
        } catch (RemoteException e) {    }
    }

}
错误:

Description Resource    Path    Location    Type
The constructor Region(String, null, null, null) is undefined   MainActivity.java   /iBeaconTest/src/com/example/ibeacontest    line 56 Java Problem
The method startMonitoringBeaconsInRegion(org.altbeacon.beacon.Region) in the type BeaconManager is not applicable for the arguments (android.graphics.Region)  MainActivity.java   /iBeaconTest/src/com/example/ibeacontest    line 56 Java Problem
The type new MonitorNotifier(){} must implement the inherited abstract method MonitorNotifier.didDetermineStateForRegion(int, Region)   MainActivity.java   /iBeaconTest/src/com/example/ibeacontest    line 40 Java Problem
The type new MonitorNotifier(){} must implement the inherited abstract method MonitorNotifier.didEnterRegion(Region)    MainActivity.java   /iBeaconTest/src/com/example/ibeacontest    line 40 Java Problem
The type new MonitorNotifier(){} must implement the inherited abstract method MonitorNotifier.didExitRegion(Region) MainActivity.java   /iBeaconTest/src/com/example/ibeacontest    line 40 Java Problem

可能是什么问题?

其中一个
import
语句引用了错误的包。简单更改:

导入android.graphics.Region导入org.altbeacon.beacon.Region


在我做出改变之前,我犯了与问题中相同的错误。之后,代码编译成功。

这是在使用Eclipse,是吗?是的,我在使用Eclipse。