GPS 연구 18
2579 단어 nmeaandroid2.1GPS
개요
GPS를 이해하고 싶었습니다.
android2.1에서 NMEA를 바라 보는 앱.
사진
샘플 코드
package com.ohisamallc.ohiapo9;
import android.app.Activity;
import android.location.GpsStatus;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.TableLayout;
import android.widget.TextView;
import android.view.ViewGroup;
public class ohiapo9 extends Activity
{
private LocationManager mLocationManager;
private LocationListener mLocationListener;
private TextView textView;
@Override public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
textView = new TextView(this);
textView.setWidth(200);
textView.setText("ok");
TableLayout tableLayout = new TableLayout(this);
tableLayout.addView(textView, new TableLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
setContentView(tableLayout);
}
@Override protected void onDestroy()
{
super.onDestroy();
mLocationManager.removeUpdates(mLocationListener);
}
@Override public void onStart()
{
super.onStart();
mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
if (!mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER))
{
}
mLocationListener = new locationListener();
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 5, mLocationListener);
mLocationManager.addNmeaListener(nmeaListener);
}
private final GpsStatus.NmeaListener nmeaListener = new GpsStatus.NmeaListener()
{
public void onNmeaReceived(long timestamp, String nmea)
{
String s = nmea + textView.getText().toString();
textView.setText(s);
}
};
private class locationListener implements LocationListener
{
public void onLocationChanged(Location loc)
{
}
public void onProviderDisabled(String arg0)
{
}
public void onProviderEnabled(String provider)
{
}
public void onStatusChanged(String provider, int status, Bundle extras)
{
}
}
}
이상.
Reference
이 문제에 관하여(GPS 연구 18), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/ohisama@github/items/3af30a1f2102246a147a
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
샘플 코드
package com.ohisamallc.ohiapo9;
import android.app.Activity;
import android.location.GpsStatus;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.TableLayout;
import android.widget.TextView;
import android.view.ViewGroup;
public class ohiapo9 extends Activity
{
private LocationManager mLocationManager;
private LocationListener mLocationListener;
private TextView textView;
@Override public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
textView = new TextView(this);
textView.setWidth(200);
textView.setText("ok");
TableLayout tableLayout = new TableLayout(this);
tableLayout.addView(textView, new TableLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
setContentView(tableLayout);
}
@Override protected void onDestroy()
{
super.onDestroy();
mLocationManager.removeUpdates(mLocationListener);
}
@Override public void onStart()
{
super.onStart();
mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
if (!mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER))
{
}
mLocationListener = new locationListener();
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 5, mLocationListener);
mLocationManager.addNmeaListener(nmeaListener);
}
private final GpsStatus.NmeaListener nmeaListener = new GpsStatus.NmeaListener()
{
public void onNmeaReceived(long timestamp, String nmea)
{
String s = nmea + textView.getText().toString();
textView.setText(s);
}
};
private class locationListener implements LocationListener
{
public void onLocationChanged(Location loc)
{
}
public void onProviderDisabled(String arg0)
{
}
public void onProviderEnabled(String provider)
{
}
public void onStatusChanged(String provider, int status, Bundle extras)
{
}
}
}
이상.
Reference
이 문제에 관하여(GPS 연구 18), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/ohisama@github/items/3af30a1f2102246a147a
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
package com.ohisamallc.ohiapo9;
import android.app.Activity;
import android.location.GpsStatus;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.TableLayout;
import android.widget.TextView;
import android.view.ViewGroup;
public class ohiapo9 extends Activity
{
private LocationManager mLocationManager;
private LocationListener mLocationListener;
private TextView textView;
@Override public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
textView = new TextView(this);
textView.setWidth(200);
textView.setText("ok");
TableLayout tableLayout = new TableLayout(this);
tableLayout.addView(textView, new TableLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
setContentView(tableLayout);
}
@Override protected void onDestroy()
{
super.onDestroy();
mLocationManager.removeUpdates(mLocationListener);
}
@Override public void onStart()
{
super.onStart();
mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
if (!mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER))
{
}
mLocationListener = new locationListener();
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 5, mLocationListener);
mLocationManager.addNmeaListener(nmeaListener);
}
private final GpsStatus.NmeaListener nmeaListener = new GpsStatus.NmeaListener()
{
public void onNmeaReceived(long timestamp, String nmea)
{
String s = nmea + textView.getText().toString();
textView.setText(s);
}
};
private class locationListener implements LocationListener
{
public void onLocationChanged(Location loc)
{
}
public void onProviderDisabled(String arg0)
{
}
public void onProviderEnabled(String provider)
{
}
public void onStatusChanged(String provider, int status, Bundle extras)
{
}
}
}
Reference
이 문제에 관하여(GPS 연구 18), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/ohisama@github/items/3af30a1f2102246a147a텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)