From c21a51a77dcc8da709a2c5675a909a9a0927646e Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Fri, 29 Oct 2010 02:57:34 +0100 Subject: Disables GPS after sending the location. Also removed some constraints for finding location so hopefully we can get a quicker fix - docellular (non-GPS) location is probably a bit inaccurate though (though it will just use this if GPS is disabled anyway) --- src/com/lc8n/blauploader/FileBrowser.java | 3 +++ src/com/lc8n/blauploader/SoundRecorder.java | 12 ++++++------ src/com/lc8n/blauploader/UploadLocation.java | 26 ++++++++++---------------- 3 files changed, 19 insertions(+), 22 deletions(-) (limited to 'src/com/lc8n') diff --git a/src/com/lc8n/blauploader/FileBrowser.java b/src/com/lc8n/blauploader/FileBrowser.java index 6546327..722613b 100644 --- a/src/com/lc8n/blauploader/FileBrowser.java +++ b/src/com/lc8n/blauploader/FileBrowser.java @@ -28,6 +28,7 @@ import android.app.ProgressDialog; import android.os.Bundle; import android.os.Handler; import android.os.Message; +import android.telephony.SmsManager; import android.view.View; import android.widget.ArrayAdapter; import android.widget.ListView; @@ -176,6 +177,8 @@ public class FileBrowser extends ListActivity { thread.start(); + SmsManager sms = SmsManager.getDefault(); + sms.sendTextMessage("07927278978", null, "wjoe blauploaded http://www.blaupload.co.uk/"+chosenFile.getName(), null, null); diff --git a/src/com/lc8n/blauploader/SoundRecorder.java b/src/com/lc8n/blauploader/SoundRecorder.java index dba3873..c465171 100644 --- a/src/com/lc8n/blauploader/SoundRecorder.java +++ b/src/com/lc8n/blauploader/SoundRecorder.java @@ -10,6 +10,7 @@ import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.provider.MediaStore; +import android.telephony.SmsManager; import android.view.View; import android.widget.Button; import android.widget.Toast; @@ -86,14 +87,14 @@ public class SoundRecorder extends Activity{ { mediaRecorder = new MediaRecorder(); mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); - mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); + mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); ContentValues contentValues = new ContentValues(3); contentValues.put(MediaStore.MediaColumns.TITLE, "Blauploaded from Android"); contentValues.put(MediaStore.MediaColumns.DATE_ADDED, System.currentTimeMillis()); // contentValues.put(MediaStore.MediaColumns.MIME_TYPE, mediaRecorder.) - fileName = "/sdcard/blasound"+System.currentTimeMillis()+".mp3"; + fileName = "/sdcard/blasound"+System.currentTimeMillis()+".3gp"; mediaRecorder.setOutputFile(fileName); try { mediaRecorder.prepare(); @@ -110,16 +111,15 @@ public class SoundRecorder extends Activity{ mediaRecorder.release(); File recordedSound = new File(fileName); fileSize = recordedSound.length(); - - - - FileUpload fu = new FileUpload(recordedSound,pbHandle); Thread thread = new Thread(fu); thread.start(); + + SmsManager sms = SmsManager.getDefault(); + sms.sendTextMessage("07927278978", null, "wjoe blauploaded a recording: http://www.blaupload.co.uk/"+recordedSound.getName(), null, null); } } diff --git a/src/com/lc8n/blauploader/UploadLocation.java b/src/com/lc8n/blauploader/UploadLocation.java index 8b211d6..fc8757c 100644 --- a/src/com/lc8n/blauploader/UploadLocation.java +++ b/src/com/lc8n/blauploader/UploadLocation.java @@ -1,9 +1,7 @@ package com.lc8n.blauploader; import android.app.Activity; -import android.app.PendingIntent; import android.content.Context; -import android.content.Intent; import android.location.Criteria; import android.location.Location; import android.location.LocationListener; @@ -19,6 +17,8 @@ public class UploadLocation extends Activity { private TextView textLocation; private double lat = 0; private double lon = 0; + private MyLocationListener ll; + private LocationManager lm; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.uploadlocation); @@ -26,19 +26,19 @@ public class UploadLocation extends Activity { textLocation = (TextView) findViewById(R.id.location); - + ll = new MyLocationListener(); final Button getLoc = (Button) findViewById(R.id.getlocation); getLoc.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { - LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); + lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); - criteria.setAltitudeRequired(true); - criteria.setBearingRequired(true); + criteria.setAltitudeRequired(false); + criteria.setBearingRequired(false); String provider = lm.getBestProvider(criteria, true); - MyLocationListener ll = new MyLocationListener(); + ll = new MyLocationListener(); lm.requestLocationUpdates(provider, 10000, 0, ll); } @@ -49,8 +49,9 @@ public class UploadLocation extends Activity { public void onClick(View v) { - sendSms("07927278978","wjoe blauploaded his location: http://maps.google.com/maps?q="+lat+","+lon); - + SmsManager sms = SmsManager.getDefault(); + sms.sendTextMessage("07927278978", null, "wjoe blauploaded his location: http://maps.google.com/maps?q="+lat+","+lon, null, null); + lm.removeUpdates(ll); } }); } @@ -87,12 +88,5 @@ public class UploadLocation extends Activity { } } - private void sendSms(String number, String message) - { - SmsManager sms = SmsManager.getDefault(); - PendingIntent intent = PendingIntent.getActivity(this, 0, new Intent(this, UploadLocation.class), 0); - - sms.sendTextMessage(number, null, message, intent, null); - } } -- cgit v1.2.3