2013-04-02 3 views
0

Nokia 개발에서 처음. 내 현재 위치의 GPS 좌표를 가져 오는 안녕하세요 세계를 쓰려고합니다. 여기서 내가 뭘 잘못하고 있니?Nokia 디바이스에서 getLocation 중 InstantiationException

public class HomeScreen extends MIDlet { 

    public HomeScreen() { 
    } 

    protected void destroyApp(boolean arg0) throws MIDletStateChangeException { 
    } 

    protected void pauseApp() { 
    } 

    protected void startApp() throws MIDletStateChangeException { 
     Displayable current = Display.getDisplay(this).getCurrent() ; 
     if (current == null) { 
      UpdateJourney updateJourney = new UpdateJourney(this) ; 
      Display.getDisplay(this).setCurrent(updateJourney) ; 
     } 
    } 

} 

public class UpdateJourney extends Form implements CommandListener, Runnable { 
    private LocationProvider myLocation; 
    private Criteria myCriteria; 
    private Location myCurrentLocation; 

    private HomeScreen helloScreen; 
    private Command exitCommand; 

    private Thread getLocationThread = new Thread(this);; 

    public UpdateJourney(HomeScreen helloScreen) { 
     super("Taxeeta"); 

     StringItem helloText = new StringItem("", "Taxeeta"); 
     super.append(helloText); 
     this.helloScreen = helloScreen; 
     getLocationThread.start(); 
    } 

    public double getMyLatitude() { 
     return myCurrentLocation.getQualifiedCoordinates().getLatitude(); 
    } 

    public double getMyLongitude() { 
     return myCurrentLocation.getQualifiedCoordinates().getLongitude(); 
    } 

    public void commandAction(Command command, Displayable arg1) { 
     if (command == exitCommand) { 
      helloScreen.notifyDestroyed(); 
     } 
    } 

    public void run() { 
     myCriteria = new Criteria(); 
     myCriteria.setHorizontalAccuracy(500); 
     try { 
      myLocation = LocationProvider.getInstance(myCriteria); 
      myCurrentLocation = myLocation.getLocation(60); 
     } catch (LocationException e) { 
      e.printStackTrace(); 
      System.out 
        .println("Error : Unable to initialize location provider"); 
      return; 
     } catch (InterruptedException e) { 
      e.printStackTrace(); 
      System.out.println("Error: Waited enough for location to return"); 
      return; 
     } 
     System.out.println("Location returned Lat:" 
       + myCurrentLocation.getQualifiedCoordinates().getLatitude() 
       + " Lng:" 
       + myCurrentLocation.getQualifiedCoordinates().getLongitude()); 
     exitCommand = new Command("Location returned Lat:" 
       + myCurrentLocation.getQualifiedCoordinates().getLatitude() 
       + " Lng:" 
       + myCurrentLocation.getQualifiedCoordinates().getLongitude(), 
       Command.EXIT, 1); 
     addCommand(exitCommand); 
     setCommandListener(this); 

    } 

} 

답변

0

응용 프로그램 설명자에서 UpdateJourney를 MIDlet으로 사용하여 HomeScreen으로 변경하고 작동했습니다.

관련 문제