Crash on calling requestLocationUpdates

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

Crash on calling requestLocationUpdates

Postby blitz2190 » Thu Oct 07, 2010 10:16 pm

ok i am new to android dev and have been having an issue with calling requestLocationUpdates when it is called it crashes with no information code is below

SMSReciever.java
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package Find.Me;
  2.  
  3. import android.content.BroadcastReceiver;
  4. import android.content.Context;
  5. import android.content.Intent;
  6. import android.os.Bundle;
  7. import android.telephony.SmsMessage;
  8. import java.util.Scanner;
  9. import android.location.Location;
  10. import android.location.LocationListener;
  11. import android.location.LocationManager;
  12.  
  13. public class SMSReceiver extends BroadcastReceiver {
  14.     public FindMe MainApp = new FindMe();
  15.     public LocationManager locmgr = null;
  16.     @Override
  17.     public void onReceive(Context context, Intent intent) {
  18.         Bundle bundle = intent.getExtras();
  19.         Object messages[] = (Object[]) bundle.get("pdus");
  20.         SmsMessage smsMessage[] = new SmsMessage[messages.length];
  21.         for (int n = 0; n < messages.length; n++) {
  22.             smsMessage[n] = SmsMessage.createFromPdu((byte[]) messages[n]);
  23.         }
  24.        
  25.         String txtBody;
  26.         txtBody  =  smsMessage[0].getMessageBody().toString();
  27.         Scanner scanner = new Scanner(txtBody);
  28.         if(scanner.findInLine("Find Me Please") != null){
  29.             locmgr = (LocationManager) MainApp.getSystemService(Context.LOCATION_SERVICE);/*call to main app becuase getSystemService is not know in the file im assuming has something to do with activity being in main app.*/
  30.             locmgr.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,10000.0f,onLocationChange);
  31.         }
  32.         else{
  33.            
  34.         }
  35.     }
  36.    
  37.     LocationListener onLocationChange=new LocationListener() {
  38.         public void onLocationChanged(Location loc) {
  39.             //sets and displays the lat/long when a location is provided
  40.             String latlong = "Lat: " + loc.getLatitude() + " Long: " + loc.getLongitude();  
  41.             MainApp.mytext.setText(latlong);
  42.         }
  43.          
  44.         public void onProviderDisabled(String provider) {
  45.         // required for interface, not used
  46.         }
  47.          
  48.         public void onProviderEnabled(String provider) {
  49.         // required for interface, not used
  50.         }
  51.          
  52.         public void onStatusChanged(String provider, int status,
  53.         Bundle extras) {
  54.         // required for interface, not used
  55.         }
  56.     };
  57.    
  58. }
  59.  
Parsed in 0.039 seconds, using GeSHi 1.0.8.4


FindMe.java

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. import android.app.Activity;
  2. import android.os.Bundle;
  3. import android.widget.TextView;
  4.  
  5.  
  6. public class FindMe extends Activity {
  7.     public TextView mytext;
  8.     public static String MyLoc;
  9.     @Override
  10.     public void onCreate(Bundle savedInstanceState){
  11.         super.onCreate(savedInstanceState);
  12.         setContentView(R.layout.main);
  13.         mytext = (TextView) findViewById(R.id.mytext);
  14.         mytext.setText("waiting for location");
  15.     }
  16. }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


and i did add these to the manifest
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. <uses-permission android:name="android.permission.RECEIVE_SMS" />
  2.     <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
blitz2190
Freshman
Freshman
 
Posts: 2
Joined: Thu Oct 07, 2010 10:06 pm

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 5 guests