2016-05-25 22 views
0

サンプルアプリケーションでEstimoteビーコンを表示しようとしていますが、動作させることができません。私はこれらの2つのサンプルを見て、ほとんどのコードをコピーして以来、私は彼らとは違ったやり方を見ていません。私が使用していますaltimodeを使ってEstimoteビーコンを見ることができません。android

参考文献:

私はBluetoothが何らかの理由で動作していないように思える私のアプリから、これらの奇妙なログを参照してくださいことを私は何のバグ

https://altbeacon.github.io/android-beacon-library/samples.html

http://www.software7.com/blog/creating-a-beacon-app-for-android-in-less-than-10-minutes-from-scratch/

私は別のアプリがインストールされているので、UUIDは正しいと知っていますが、これは全く同じビーコンを問題なく見ることができますが、自分のアプリを構築するのに疲れたとき、ブルートゥースは間違いなくオンであり、無線LANのオン/オフは関係ありません。

私はHTC、Samsung Galaxy S6とS5(LollipoとMarshmallow)でコードを試したので、誰もが問題を見つけることができるのだろうかと思います。

ログ私のアプリからここ

example.com.beacontest D/BeaconParser: Parsing beacon layout: m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25 
example.com.beacontest D/BeaconParser: Parsing beacon layout: m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24 
example.com.beacontest D/Activity: performCreate Call secproduct feature valuefalse 
example.com.beacontest D/Activity: performCreate Call debug elastic valuetrue 
example.com.beacontest W/BluetoothCrashResolver: Can't read macs from BluetoothCrashResolverState.txt 
example.com.beacontest D/BluetoothAdapter: startLeScan(): null 
example.com.beacontest D/BluetoothLeScanner: onClientRegistered() - status=133 clientIf=0 
example.com.beacontest I/Timeline: Timeline: Activity_idle id: [email protected] time:7966418897 
example.com.beacontest I/Timeline: Timeline: Activity_idle id: [email protected] time:7966418898 
example.com.beacontest D/BluetoothAdapter: stopLeScan() 
example.com.beacontest D/BluetoothLeScanner: could not find callback wrapper 
example.com.beacontest D/BluetoothAdapter: startLeScan(): null 
example.com.beacontest D/BluetoothLeScanner: onClientRegistered() - status=133 clientIf=0 
example.com.beacontest D/BluetoothAdapter: stopLeScan() 

*が(同じ電話、ビーコンとのOSを使用して)*ワークスアプリからログがある(それは、ビーコンを見ることができません)。私のアプリ上でブルートゥース用にセットアップする必要があるように見えますが、実際には何か分かりません。

com.prodcode.dev D/BluetoothAdapter: STATE_ON 
com.prodcode D/BluetoothAdapter: STATE_ON 
com.prodcode D/BluetoothLeScanner: Stop Scan 
com.prodcode D/BluetoothLeScanner: Start Scan 
com.prodcode D/BluetoothAdapter: STATE_ON 
com.prodcode D/BluetoothAdapter: STATE_ON 
com.prodcode D/BluetoothAdapter: STATE_ON 
com.prodcode D/BluetoothAdapter: STATE_ON 
com.prodcode D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=13 

ありがとうございます。

私のサンプルアプリケーションのコード:

public class MonitoringActivity extends AppCompatActivity implements BeaconConsumer { 
    protected static final String TAG = "ESTIMOTE_BEACON"; 
    private BeaconManager beaconManager; 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_ranging); 
     org.altbeacon.beacon.BeaconManager altBeaconManager = org.altbeacon.beacon.BeaconManager.getInstanceForApplication(this); 
     altBeaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24")); 
     altBeaconManager.setBackgroundScanPeriod(5000); 
     altBeaconManager.setBackgroundBetweenScanPeriod(25000); 
     beaconManager = BeaconManager.getInstanceForApplication(this); 
     BeaconManager.setAndroidLScanningDisabled(true); 
     altBeaconManager.bind(this); 
    } 
    @Override 
    protected void onDestroy() { 
     super.onDestroy(); 
     beaconManager.unbind(this); 
    } 
    public static final int BEACON_REGION_MAX = 10; 
    @Override 
    public void onBeaconServiceConnect() { 
     final String beaconID = getApplicationContext().getString(R.string.beaconUUID).toUpperCase(); 
     final Region region = new Region("BEACON_TEST", Identifier.parse(beaconID), Identifier.fromInt(BEACON_REGION_MAX), null); 
     beaconManager.setMonitorNotifier(new MonitorNotifier() { 
      @Override 
      public void didEnterRegion(Region region) { 
       Log.d(TAG, "I just saw an beacon for the first time!"); 
       try { 
        beaconManager.startRangingBeaconsInRegion(region); 
       } catch (RemoteException e) { 
        e.printStackTrace(); 
       } 
      } 
      @Override 
      public void didExitRegion(Region region) { 
       Log.d(TAG, "I no longer see an beacon"); 
       try { 
        beaconManager.stopRangingBeaconsInRegion(region); 
       } catch (RemoteException e) { 
        e.printStackTrace(); 
       } 
      } 
      @Override 
      public void didDetermineStateForRegion(int state, Region region) { 
       Log.d(TAG, "I have just switched from seeing/not seeing beacons: " + state); 
      } 
     }); 

     beaconManager.setRangeNotifier(new RangeNotifier() { 
      @Override 
      public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) { 
       for (Beacon beacon : beacons) { 
        Log.d(TAG, "distance: " + beacon.getDistance() + " , " + 
          "id: " + beacon.getId1() + ", " + 
          "id: " + beacon.getId2() + ", " + 
          "id: " + beacon.getId3() + ", "); 
       } 
      } 
     }); 
     try { 
      beaconManager.startMonitoringBeaconsInRegion(region); 
     } catch (RemoteException e) { 
     } 
    } 
} 

、ここでは私のマニフェストとのGradleです:

<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
<uses-permission android:name="android.permission.WAKE_LOCK" /> 
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> 
<uses-permission android:name="android.permission.BLUETOOTH" /> 
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> 
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
<uses-permission android:name="android.permission.CALL_PHONE" /> 
<application 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 
    <activity android:name=".MainActivity"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
</application> 

のGradle:

apply plugin: 'com.android.application' 
repositories { jcenter() } 
android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.3" 
    defaultConfig { 
     applicationId "example.com.beacontest" 
     minSdkVersion 18 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 
dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:23.3.0' 
    compile 'org.altbeacon:android-beacon-library:2.+' 
    compile 'com.android.support:design:23.3.0' 
} 
+0

アプリに必要な権限がありますか?設定 - >アプリ - >アプリ - >にアクセスし、許可が与えられているかどうかを確認します。あなたがマシュマロで試したことを言っているが、パーミッションに関連するコードは見当たらないので、これを示唆している。 – driftking9987

+0

私はそう信じています。私はマニフェストに追加しました.AppInfoにアクセスすると、「Bluetooth設定にアクセスし、Bluetoothデバイスとペア設定します」というメッセージが表示されます – gmmo

答えて

関連する問題