0

私は自分の場所を取得しようとしています.以下は、エラーが発生しているコードです. Log Cat を以下に示します。助けてください。また、緯度と経度が格納されている変数を知りたいです。

MyLocation.java

public class MyLocation extends Activity{ 

/** Called when the activity is first created. */ 
@Override 
public void onCreate(Bundle savedInstanceState) 
{ 
  super.onCreate(savedInstanceState); 
  setContentView(R.layout.main); 

  /* Use the LocationManager class to obtain GPS locations */ 
  LocationManager mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); 

  LocationListener mlocListener = new MyLocationListener(); 
  mlocManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, mlocListener); 
} 

/* Class My Location Listener */ 
public class MyLocationListener implements LocationListener 
{ 

  public void onLocationChanged(Location loc) 
  { 

    loc.getLatitude(); 
    loc.getLongitude(); 

    String Text = "My current location is: " + 
    "Latitud = " + loc.getLatitude() + 
    "Longitud = " + loc.getLongitude(); 

    Toast.makeText( getApplicationContext(), Text, Toast.LENGTH_SHORT).show(); 
  } 

  public void onProviderDisabled(String provider) 
  { 
    Toast.makeText( getApplicationContext(), "Gps Disabled", Toast.LENGTH_SHORT ).show(); 
  } 

  public void onProviderEnabled(String provider) 
  { 
    Toast.makeText( getApplicationContext(), "Gps Enabled", Toast.LENGTH_SHORT).show(); 
  } 

  public void onStatusChanged(String provider, int status, Bundle extras) 
  { 

  } 
} 
} 

丸太の猫

04-23 16:41:27.880: E/AndroidRuntime(3250): Uncaught handler: thread main exiting due to uncaught exception
04-23 16:41:27.920: E/AndroidRuntime(3250): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{your.meh.namespace/your.meh.namespace.PostActivity}: java.lang.ClassNotFoundException: your.meh.namespace.PostActivity in loader dalvik.system.PathClassLoader@458a8ad8
04-23 16:41:27.920: E/AndroidRuntime(3250):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2424)
04-23 16:41:27.920: E/AndroidRuntime(3250):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2519)
04-23 16:41:27.920: E/AndroidRuntime(3250):     at android.app.ActivityThread.access$2200(ActivityThread.java:123)
04-23 16:41:27.920: E/AndroidRuntime(3250):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1870)
04-23 16:41:27.920: E/AndroidRuntime(3250):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-23 16:41:27.920: E/AndroidRuntime(3250):     at android.os.Looper.loop(Looper.java:123)
04-23 16:41:27.920: E/AndroidRuntime(3250):     at android.app.ActivityThread.main(ActivityThread.java:4370)
04-23 16:41:27.920: E/AndroidRuntime(3250):     at java.lang.reflect.Method.invokeNative(Native Method)
04-23 16:41:27.920: E/AndroidRuntime(3250):     at java.lang.reflect.Method.invoke(Method.java:521)
04-23 16:41:27.920: E/AndroidRuntime(3250):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-23 16:41:27.920: E/AndroidRuntime(3250):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-23 16:41:27.920: E/AndroidRuntime(3250):     at dalvik.system.NativeStart.main(Native Method)
04-23 16:41:27.920: E/AndroidRuntime(3250): Caused by: java.lang.ClassNotFoundException: your.meh.namespace.PostActivity in loader dalvik.system.PathClassLoader@458a8ad8
04-23 16:41:27.920: E/AndroidRuntime(3250):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
04-23 16:41:27.920: E/AndroidRuntime(3250):     at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
04-23 16:41:27.920: E/AndroidRuntime(3250):     at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
04-23 16:41:27.920: E/AndroidRuntime(3250):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
04-23 16:41:27.920: E/AndroidRuntime(3250):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
04-23 16:41:27.920: E/AndroidRuntime(3250):     ... 11 more
04-23 16:41:28.010: E/SemcCheckin(3250): Get crash dump level : java.io.FileNotFoundException: /data/semc-checkin/crashdump
04-23 16:41:28.040: I/dalvikvm(3250): threadid=7: reacting to signal 3
04-23 16:41:28.100: I/dalvikvm(3250): Wrote stack trace to '/data/anr/traces.txt'
4

1 に答える 1

1

あなたのエラー(貼り付けたスタックトレースによると)は、場所の問題とは何の関係もありません。

クラス PostActivity が見つからないため、ClassNotFoundException が発生します。

実際に失敗するコードを貼り付けていないと思います

于 2012-04-23T11:47:09.850 に答える