Various small improvements in sms and location in Android

git-svn-id: trunk@34499 -
This commit is contained in:
sekelsenmat 2011-12-29 16:01:46 +00:00
parent 709ab6984f
commit 728f54b6ad
7 changed files with 49 additions and 25 deletions

View File

@ -435,12 +435,20 @@ public class LCLActivity extends Activity implements SensorEventListener, Locati
}
}, new IntentFilter("SMS_DELIVERED"));
SmsManager sms = SmsManager.getDefault();
Log.i("lclapp", "[LCLDoSendMessage] lcldestination="+lcldestination
+" lcltext="+lcltext);
ArrayList<String> parts = sms.divideMessage(lcltext);
//sms.sendMultipartTextMessage(lcldestination, null, parts, sentPI, deliveredPI);
sms.sendTextMessage(lcldestination, null, lcltext, sentPI, deliveredPI);
// SMS sending seams to cause an awful lot of exceptions
// See: http://stackoverflow.com/questions/4580952/why-do-i-get-nullpointerexception-when-sending-an-sms-on-an-htc-desire-or-what
// See: http://code.google.com/p/android/issues/detail?id=3718
try
{
SmsManager sms = SmsManager.getDefault();
Log.i("lclapp", "[LCLDoSendMessage] lcldestination="+lcldestination+" lcltext="+lcltext);
ArrayList<String> parts = sms.divideMessage(lcltext);
//sms.sendMultipartTextMessage(lcldestination, null, parts, sentPI, deliveredPI);
sms.sendTextMessage(lcldestination, null, lcltext, sentPI, deliveredPI);
}
catch (Exception e)
{
}
}
};
@ -450,9 +458,13 @@ public class LCLActivity extends Activity implements SensorEventListener, Locati
{
if (loc != null)
{
double[] positionArray = new double[2];
double[] positionArray = new double[6];
positionArray[0] = loc.getLatitude();
positionArray[1] = loc.getLongitude();
positionArray[2] = loc.getAltitude();
positionArray[3] = (double)loc.getAccuracy();
positionArray[4] = (double)loc.getSpeed();
positionArray[5] = (double)loc.getTime();
int eventResult = LCLOnSensorChanged(-10, positionArray);
if (((eventResult | 1) != 0) && (lclsurface != null)) lclsurface.postInvalidate();
}
@ -470,10 +482,16 @@ public class LCLActivity extends Activity implements SensorEventListener, Locati
{
}
// input: int lclkind
public void LCLDoRequestPositionInfo()
{
LocationManager mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
switch (lclkind)
{
case 1: mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
case 2: mlocManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
default: Log.i("lclapp", "[LCLDoRequestPositionInfo] Wrong lclkind parameter");
}
}
// -------------------------------------------

View File

@ -84,7 +84,7 @@ end;
procedure TForm2.btnGetPosClick(Sender: TObject);
begin
PositionInfo.RequestPositionInfo([]);
PositionInfo.RequestPositionInfo(pmGPS);
PositionInfo.OnPositionRetrieved := @HandlePositionRetrieved;
end;
@ -93,8 +93,7 @@ begin
DebugLn('[Edit1Exit]');
end;
procedure TForm2.textDestKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState
);
procedure TForm2.textDestKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
DebugLn('[Edit1KeyDown] Key=' + DbgsVKCode(Key));
end;

View File

@ -30,7 +30,7 @@ interface
uses
// RTL
Types, Classes, SysUtils, Math,
fpimage, fpcanvas, fpimgcanv, ctypes,
fpimage, fpcanvas, fpimgcanv, ctypes, dateutils,
{$ifdef CD_Windows}Windows, customdrawn_WinProc,{$endif}
{$ifdef CD_Cocoa}MacOSAll, CocoaAll, CocoaPrivate, CocoaGDIObjects,{$endif}
{$ifdef CD_X11}X, XLib, XUtil, BaseUnix, customdrawn_x11proc,{$ifdef CD_UseNativeText}xft, fontconfig,{$endif}{$endif}

View File

@ -164,7 +164,17 @@ begin
end;
procedure TCDWidgetSet.LazDeviceAPIs_RequestPositionInfo(AMethod: TLazPositionMethod);
var
lPositionMethod: jint;
begin
// Prepare the input
case AMethod of
pmGPS: lPositionMethod := 1;
pmNetwork: lPositionMethod := 2;
else
Exit;
end;
javaEnvRef^^.SetIntField(javaEnvRef, javaActivityObject, JavaField_lclkind, lPositionMethod);
// Call the method
javaEnvRef^^.CallVoidMethod(javaEnvRef, javaActivityObject, javaMethod_LCLDoRequestPositionInfo);
end;

View File

@ -258,6 +258,7 @@ var
lIsCopy: jboolean;
lSensorDataInt: Integer;
lMessagingStatus: TLazMessagingStatus;
lUnixTimeStamp: Int64;
begin
Result := 0;
@ -291,6 +292,13 @@ begin
begin
PositionInfo.latitude := arraydata[0];
PositionInfo.longitude := arraydata[1];
PositionInfo.altitude := arraydata[2];
PositionInfo.accuracy := arraydata[3];
PositionInfo.altitudeAccuracy := PositionInfo.accuracy;
PositionInfo.speed := arraydata[4];
lUnixTimeStamp := Round(arraydata[5]);
PositionInfo.timeStamp := UnixToDateTime(lUnixTimeStamp);
if Assigned(PositionInfo.OnPositionRetrieved) then
PositionInfo.OnPositionRetrieved(PositionInfo);
end;

View File

@ -88,9 +88,9 @@ type
accuracy: Double; // The horizontal accuracy of the position in meters
altitude: Double; // Altitude in meters using the World Geodetic System 1984 (WGS84) datum.
altitudeAccuracy: Double; // The vertical accuracy of the position in meters, or null if not available.
cellID: Double; // This is the id of the cell.
latitude: Double; // Latitude in degrees using the World Geodetic System 1984 (WGS84) datum.
longitude: Double; // Longitude in degrees using the World Geodetic System 1984 (WGS84) datum.
speed: Double; // In meters / second
timeStamp: TDateTime; // The time when the location was established.
procedure RequestPositionInfo(AMethod: TLazPositionMethod);
// Called asynchronously when the position is read

View File

@ -98,18 +98,7 @@ type
// Types for LazDeviceAPIs
TLazPositionMethodCriteria = (
// about quality
pmcBest, // Will try the best available quality
// about price
pmcMightCostMoney, // Might choose a position method which incurs money cost
// about speed
pmFastest,
// about one should try to select a method which gives speed measures
pmMustGiveSpeed
);
TLazPositionMethod = set of TLazPositionMethodCriteria;
TLazPositionMethod = (pmGPS, pmNetwork);
{ TLazDeviceMessage }