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

質問編集履歴

3

Android に変更

2016/07/19 10:41

投稿

arutaka
arutaka

スコア29

title CHANGED
File without changes
body CHANGED
@@ -1,4 +1,4 @@
1
- ```Java
1
+ ```Android
2
2
  import android.Manifest;
3
3
  import android.content.Context;
4
4
  import android.content.pm.PackageManager;
@@ -45,7 +45,7 @@
45
45
 
46
46
  ```
47
47
 
48
- 上記のクラスを他のクラスで
48
+ リスト上記のクラスを他のクラスで
49
49
 
50
50
  MapAns maps = new MapAns();
51
51
 

2

質問を読みやすく編集

2016/07/19 10:41

投稿

arutaka
arutaka

スコア29

title CHANGED
File without changes
body CHANGED
@@ -1,5 +1,4 @@
1
- package sec01.com.be.kan.aru.h280718mapapp;
1
+ ```Java
2
-
3
2
  import android.Manifest;
4
3
  import android.content.Context;
5
4
  import android.content.pm.PackageManager;
@@ -8,9 +7,6 @@
8
7
  import android.support.v4.app.ActivityCompat;
9
8
  import android.support.v4.app.FragmentActivity;
10
9
 
11
- /**
12
- * Created by yo194 on 2016/07/17.
13
- */
14
10
  public class MapAns extends FragmentActivity {
15
11
  static double ido = 0.0;
16
12
  static double kei = 0.0;
@@ -47,6 +43,7 @@
47
43
  }
48
44
  }
49
45
 
46
+ ```
50
47
 
51
48
  上記のクラスを他のクラスで
52
49
 

1

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

2016/07/19 10:39

投稿

arutaka
arutaka

スコア29

title CHANGED
File without changes
body CHANGED
@@ -1,15 +1,53 @@
1
+ package sec01.com.be.kan.aru.h280718mapapp;
2
+
3
+ import android.Manifest;
4
+ import android.content.Context;
5
+ import android.content.pm.PackageManager;
6
+ import android.location.Location;
7
+ import android.location.LocationManager;
8
+ import android.support.v4.app.ActivityCompat;
9
+ import android.support.v4.app.FragmentActivity;
10
+
11
+ /**
12
+ * Created by yo194 on 2016/07/17.
13
+ */
1
14
  public class MapAns extends FragmentActivity {
15
+ static double ido = 0.0;
16
+ static double kei = 0.0;
17
+ static double spi = 0.0;
2
18
 
19
+
20
+ //現在地の数値データ地図点を返答するメソッド ->
3
21
  public MapAns() {
4
22
  mapans();
5
23
  }
6
24
 
7
- public void mapans(){
8
- //ToDo
9
- }
25
+ public void mapans(){
26
+ //LocationManagerの取得
27
+ LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
28
+ //GPSから現在地の情報を取得
29
+ if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
30
+ // TODO: Consider calling
31
+ // ActivityCompat#requestPermissions
32
+ // here to request the missing permissions, and then overriding
33
+ // public void onRequestPermissionsResult(int requestCode, String[] permissions,
34
+ // int[] grantResults)
35
+ // to handle the case where the user grants the permission. See the documentation
36
+ // for ActivityCompat#requestPermissions for more details.
37
+ }
38
+ Location myLocate = locationManager.getLastKnownLocation("gps");
10
39
 
40
+ try{
41
+ ido = myLocate.getLatitude();
42
+ kei = myLocate.getLongitude();
43
+ spi = myLocate.getSpeed();
44
+ }catch (NullPointerException e){
45
+
46
+ }
47
+ }
11
48
  }
12
49
 
50
+
13
51
  上記のクラスを他のクラスで
14
52
 
15
53
  MapAns maps = new MapAns();