質問編集履歴

3

Android に変更

2016/07/19 10:41

投稿

arutaka
arutaka

スコア29

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,4 @@
1
- ```Java
1
+ ```Android
2
2
 
3
3
  import android.Manifest;
4
4
 
@@ -92,7 +92,7 @@
92
92
 
93
93
 
94
94
 
95
- 上記のクラスを他のクラスで
95
+ リスト上記のクラスを他のクラスで
96
96
 
97
97
 
98
98
 

2

質問を読みやすく編集

2016/07/19 10:41

投稿

arutaka
arutaka

スコア29

test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,4 @@
1
- package sec01.com.be.kan.aru.h280718mapapp;
1
+ ```Java
2
-
3
-
4
2
 
5
3
  import android.Manifest;
6
4
 
@@ -17,12 +15,6 @@
17
15
  import android.support.v4.app.FragmentActivity;
18
16
 
19
17
 
20
-
21
- /**
22
-
23
- * Created by yo194 on 2016/07/17.
24
-
25
- */
26
18
 
27
19
  public class MapAns extends FragmentActivity {
28
20
 
@@ -96,6 +88,8 @@
96
88
 
97
89
 
98
90
 
91
+ ```
92
+
99
93
 
100
94
 
101
95
  上記のクラスを他のクラスで

1

内容が不明に見えたので...

2016/07/19 10:39

投稿

arutaka
arutaka

スコア29

test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,42 @@
1
+ package sec01.com.be.kan.aru.h280718mapapp;
2
+
3
+
4
+
5
+ import android.Manifest;
6
+
7
+ import android.content.Context;
8
+
9
+ import android.content.pm.PackageManager;
10
+
11
+ import android.location.Location;
12
+
13
+ import android.location.LocationManager;
14
+
15
+ import android.support.v4.app.ActivityCompat;
16
+
17
+ import android.support.v4.app.FragmentActivity;
18
+
19
+
20
+
21
+ /**
22
+
23
+ * Created by yo194 on 2016/07/17.
24
+
25
+ */
26
+
1
27
  public class MapAns extends FragmentActivity {
2
28
 
29
+ static double ido = 0.0;
3
30
 
31
+ static double kei = 0.0;
32
+
33
+ static double spi = 0.0;
34
+
35
+
36
+
37
+
38
+
39
+ //現在地の数値データ地図点を返答するメソッド ->
4
40
 
5
41
  public MapAns() {
6
42
 
@@ -10,15 +46,55 @@
10
46
 
11
47
 
12
48
 
13
- public void mapans(){
49
+ public void mapans(){
14
50
 
15
- //ToDo
51
+ //LocationManagerの取得
16
52
 
17
- }
53
+ LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
54
+
55
+ //GPSから現在地の情報を取得
56
+
57
+ if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
58
+
59
+ // TODO: Consider calling
60
+
61
+ // ActivityCompat#requestPermissions
62
+
63
+ // here to request the missing permissions, and then overriding
64
+
65
+ // public void onRequestPermissionsResult(int requestCode, String[] permissions,
66
+
67
+ // int[] grantResults)
68
+
69
+ // to handle the case where the user grants the permission. See the documentation
70
+
71
+ // for ActivityCompat#requestPermissions for more details.
72
+
73
+ }
74
+
75
+ Location myLocate = locationManager.getLastKnownLocation("gps");
18
76
 
19
77
 
20
78
 
79
+ try{
80
+
81
+ ido = myLocate.getLatitude();
82
+
83
+ kei = myLocate.getLongitude();
84
+
85
+ spi = myLocate.getSpeed();
86
+
87
+ }catch (NullPointerException e){
88
+
89
+
90
+
91
+ }
92
+
93
+ }
94
+
21
95
  }
96
+
97
+
22
98
 
23
99
 
24
100