teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

4

log文の位置を修正

2017/11/21 13:55

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -117,7 +117,7 @@
117
117
  public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
118
118
  Log.d("log", "didEnterRegion5");
119
119
  for (Beacon beacon : beacons) {
120
- Log.d("log", "didEnterRegion5-2");
120
+              Log.d("log", "didEnterRegion5-2");
121
121
  // ログの出力
122
122
  Log.d("log", "UUID:" + beacon.getId1() + ", major:" + beacon.getId2() + ", minor:" );
123
123
 

3

ログ文の追加、本文を間違って消してしまったため再度記述

2017/11/21 13:55

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -1,5 +1,9 @@
1
+ Beaconの情報をandroidで受信しようとしています。
2
+ その前段階として、log文で情報が出力されているか確認しているところです。
3
+ エラーはおきていないのですが、情報を出力するログが出ず困っています。
4
+ 詳しい方がいらっしゃいましたらお願いします。
5
+ ```java
1
6
  package com.example.beacontest12;
2
- ```ここに言語を入力
3
7
  import android.os.Bundle;
4
8
  import android.os.RemoteException;
5
9
  import android.support.v7.app.AppCompatActivity;

2

ログ文の追加

2017/11/21 13:53

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -1,5 +1,5 @@
1
1
  package com.example.beacontest12;
2
-
2
+ ```ここに言語を入力
3
3
  import android.os.Bundle;
4
4
  import android.os.RemoteException;
5
5
  import android.support.v7.app.AppCompatActivity;
@@ -113,6 +113,7 @@
113
113
  public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
114
114
  Log.d("log", "didEnterRegion5");
115
115
  for (Beacon beacon : beacons) {
116
+ Log.d("log", "didEnterRegion5-2");
116
117
  // ログの出力
117
118
  Log.d("log", "UUID:" + beacon.getId1() + ", major:" + beacon.getId2() + ", minor:" );
118
119
 
@@ -167,4 +168,5 @@
167
168
  });
168
169
  Log.d("log", "didEnterRegion13");
169
170
  }
170
- }
171
+ }
172
+ ```

1

ログ文の追加

2017/11/21 13:48

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -1,12 +1,5 @@
1
- androidでbeaconの情報を取得したいと思っています。
1
+ package com.example.beacontest12;
2
- 最終的には情報をデータベースに情報を出力したいのですが、その前段階として情報をログに出力するアプリを作っています。
3
- エラーは出ていないのですが、ログが出力されず困っています。
4
- 誰か詳しい方がいたらお願いします。
5
2
 
6
- 以下コード
7
- ```java
8
- package com.example.beacon14;
9
-
10
3
  import android.os.Bundle;
11
4
  import android.os.RemoteException;
12
5
  import android.support.v7.app.AppCompatActivity;
@@ -33,6 +26,7 @@
33
26
  public static final String IBEACON_FORMAT = "m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24";
34
27
 
35
28
  public static final String UUID = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
29
+
36
30
 
37
31
 
38
32
  public BeaconManager beaconManager;
@@ -70,19 +64,20 @@
70
64
 
71
65
  @Override
72
66
  public void onBeaconServiceConnect() {
67
+ //受信するbeaconのuuid,major,minor設定
73
68
  //Identifier uuid = Identifier.parse(UUID);
74
- Identifier uuid = Identifier.parse("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
69
+ Identifier uuid = Identifier.parse("00000000-5896-1001-B000-001C4DE59704");
75
70
  Identifier major = Identifier.parse("1");
76
71
  Identifier minor = Identifier.parse("1");
77
72
  Region mRegion = new Region("ibeacon", uuid, major, minor);
78
73
 
79
74
 
80
-
75
+
81
76
  beaconManager.addMonitorNotifier(new MonitorNotifier() {
82
77
 
83
78
  @Override
84
79
  public void didEnterRegion(Region region) {
85
-
80
+ Log.d("log", "didEnterRegion1");
86
81
  try {
87
82
  beaconManager.startRangingBeaconsInRegion(region);
88
83
  } catch (RemoteException e) {
@@ -94,13 +89,15 @@
94
89
 
95
90
  @Override
96
91
  public void didExitRegion(Region region) {
97
-
92
+ Log.d("log", "didEnterRegion2");
93
+
98
94
  // 領域退出
99
95
  }
100
96
 
101
97
  @Override
102
98
  public void didDetermineStateForRegion(int i, Region region) {
103
-
99
+ Log.d("log", "didEnterRegion3");
100
+
104
101
  //レンジング開始
105
102
  //BeaconManager.startRangingBeaconsInRegion(Region);だとエラー
106
103
 
@@ -109,55 +106,65 @@
109
106
  } catch (RemoteException e) {
110
107
  e.printStackTrace();
111
108
  }
112
-
109
+ Log.d("log", "didEnterRegion4");
113
110
  beaconManager.addRangeNotifier(new RangeNotifier() {
111
+
114
112
  @Override
115
113
  public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
114
+ Log.d("log", "didEnterRegion5");
116
115
  for (Beacon beacon : beacons) {
117
116
  // ログの出力
118
117
  Log.d("log", "UUID:" + beacon.getId1() + ", major:" + beacon.getId2() + ", minor:" );
119
118
 
120
- //@Override
119
+ //@Override
121
- //public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
120
+ //public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
122
121
 
123
- // 検出したビーコンの情報
122
+ // 検出したビーコンの情報
124
123
  }
124
+ Log.d("log", "didEnterRegion6");
125
125
  }
126
126
 
127
127
 
128
+
128
129
  });
130
+ Log.d("log", "didEnterRegion7");
129
131
 
130
132
  }
133
+
131
134
  });
132
135
 
133
-
136
+ Log.d("log", "didEnterRegion8");
134
137
  try {
135
138
  // ビーコン情報の監視を開始
136
139
  beaconManager.startMonitoringBeaconsInRegion(new Region("unique-id-001", null, null, null));
137
140
  } catch (RemoteException e) {
138
141
  e.printStackTrace();
139
142
  }
143
+ Log.d("log", "didEnterRegion9");
140
144
  beaconManager.addRangeNotifier(new RangeNotifier() {
145
+
141
146
  @Override
142
147
  public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
143
-
148
+ Log.d("log", "didEnterRegion10");
144
149
  for (Beacon beacon : beacons) {
150
+ Log.d("log", "didEnterRegion11");
145
151
  // ログの出力
146
-
152
+
147
153
  Log.d("log", "UUID:" + beacon.getId1() + ", major:" + beacon.getId2() + ", minor:" + beacon.getId3());
148
154
  }
155
+
156
+ Log.d("log", "didEnterRegion12");
149
157
  //@Override
150
158
  //public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
151
159
 
152
160
  // 検出したビーコンの情報
153
-
154
161
 
162
+
155
163
  }
156
164
 
157
165
 
158
166
 
159
167
  });
160
-
168
+ Log.d("log", "didEnterRegion13");
161
169
  }
162
- }
170
+ }
163
- ```