zoukankan      html  css  js  c++  java
  • android之location01

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/container"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        tools:context="com.example.mars_3200_location01.MainActivity"
        tools:ignore="MergeRootFrame" 
        android:orientation="vertical">
    <TextView android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="hello"/>
        
    <Button android:id="@+id/locationButtonId"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="绑定监听器"/>
    </LinearLayout>
    private class ButtonListener implements OnClickListener
        {
            @Override
            public void onClick(View v) {        
                //绑定位置对象,得到LocationManager对象
                LocationManager locationManager=(LocationManager)MainActivity.this.getSystemService(Context.LOCATION_SERVICE);
                //定义当前所使用的Location Provider
                locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, new TestLocationListener());
            }
        }
        
        class TestLocationListener implements LocationListener
        {
    
            @Override
            public void onLocationChanged(Location location) {
                System.out.println("onLocationChanged");
                
                System.out.println(location.getLongitude());//获取经度
                System.out.println(location.getLatitude());//获取纬度
            }
    
            @Override
            public void onStatusChanged(String provider, int status, Bundle extras) {
                System.out.println("onStatusChanged");
                
            }
    
            @Override
            public void onProviderEnabled(String provider) {
                System.out.println("onProviderEnabled");
                
            }
    
            @Override
            public void onProviderDisabled(String provider) {
                System.out.println("onProviderDisabled");
                
            }
            
        }
  • 相关阅读:
    vue组件间传值
    Kth MIN-MAX 反演
    BZOJ4671 异或图(容斥+线性基)
    hihoCoder #1646 : Rikka with String II(容斥原理)
    字符串小结
    LOJ# 572. 「LibreOJ Round #11」Misaka Network 与求和(min25筛,杜教筛,莫比乌斯反演)
    SPOJ divcntk(min25筛)
    LA3490 Generator(KMP + 高斯消元)
    ExKMP(Z Algorithm) 讲解
    BZOJ 2728: [HNOI2012]与非(位运算)
  • 原文地址:https://www.cnblogs.com/zhuawang/p/3690335.html
Copyright © 2011-2022 走看看