Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Using GeomagneticField class


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Oct 20, 2015 10:38 AM Last Post By: Markus Humm
Nicola Zambon

Posts: 1
Registered: 10/7/00
Using GeomagneticField class  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 15, 2015 1:51 AM
Hi,
I need to use getDeclination() method of Android SDK GeomagneticField class. With Java2Op tool I created bridge file.

unit Androidapi.JNI.Interfaces;
 
interface
 
uses
  Androidapi.JNIBridge,
  Androidapi.JNI.JavaTypes;
 
type
// ===== Forward declarations =====
 
  JGeomagneticField = interface;//android.hardware.GeomagneticField
 
// ===== Interface declarations =====
 
  JGeomagneticFieldClass = interface(JObjectClass)
    ['{77F2155B-1F9A-40E0-89FA-FE3422336577}']
    {class} function init(gdLatitudeDeg: Single; gdLongitudeDeg: Single; altitudeMeters: Single; timeMillis: Int64): JGeomagneticField; cdecl;
  end;
 
  [JavaSignature('android/hardware/GeomagneticField')]
  JGeomagneticField = interface(JObject)
    ['{47CF41EC-AAAB-4EE2-867A-884A3EF00407}']
    function getDeclination: Single; cdecl;
    function getFieldStrength: Single; cdecl;
    function getHorizontalStrength: Single; cdecl;
    function getInclination: Single; cdecl;
    function getX: Single; cdecl;
    function getY: Single; cdecl;
    function getZ: Single; cdecl;
  end;
  TJGeomagneticField = class(TJavaGenericImport<JGeomagneticFieldClass, JGeomagneticField>) end;
 
implementation
 
procedure RegisterTypes;
begin
  TRegTypes.RegisterType('Androidapi.JNI.Interfaces.JGeomagneticField', TypeInfo(Androidapi.JNI.Interfaces.JGeomagneticField));
end;
 
initialization
  RegisterTypes;
end.


Then if I use this method I get nonsense numbers (Delphi 10, I obtain 73.29, the same code in a Java example give me the correct value 2.63):

procedure TForm6.DeclinationTest
var
    GeoField: JGeomagneticField;
begin
    // coordinates in Italy
    GeoField := TJGeomagneticField.JavaClass.init(45.4102, 11.8803, 10.0, TJGregorianCalendar.JavaClass.init(2015, 1, 1).getTimeInMillis);
    Label1.Text := FloatToStr(GeoField.getDeclination());
end;


Where I make some mistake?
Thanks.
Nicola.
Mauricio Junque...

Posts: 1
Registered: 10/26/14
Java2op error compiling XE7  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 19, 2015 12:11 PM   in response to: Nicola Zambon in response to: Nicola Zambon
Hi,

I need help,
An error on deployment.

Error in the file create "JavaInterfaces" before compiling on embarcadero

[Exec Error] The command "PATH C:\Program Files\Java\jdk1.7.0_25; & "C:\Users\Public\Documents\Embarcadero\Studio\15.0\PlatformSDKs\adt-bundle-windows-x86-20131030\sdk\build-tools\android-4.4\dx.bat" --dex --output="C:\Users\Hudson\Desktop\09-10\Android\Debug\Teste-dexed.jar" "C:\Users\Hudson\Desktop\Java\Teste.jar"" exited with code 1.
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: Java2op error compiling XE7  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 20, 2015 10:38 AM   in response to: Mauricio Junque... in response to: Mauricio Junque...
Am 19.10.2015 um 21:11 schrieb Mauricio Junqueira:
Hi,

I need help,
An error on deployment.

Error in the file create "JavaInterfaces" before compiling on embarcadero

[Exec Error] The command "PATH C:\Program Files\Java\jdk1.7.0_25; & "C:\Users\Public\Documents\Embarcadero\Studio\15.0\PlatformSDKs\adt-bundle-windows-x86-20131030\sdk\build-tools\android-4.4\dx.bat" --dex --output="C:\Users\Hudson\Desktop\09-10\Android\Debug\Teste-dexed.jar" "C:\Users\Hudson\Desktop\Java\Teste.jar"" exited with code 1.

Hello,

why are you asking this one as answer to another post?
Would you please create a new thread for your issue?

And could you please give us some more information, e.g.

- Delphi version used
- does a simple sample program compile and deploy to your device?
- which API version of the SDK are you compiling against?
- what kind of application are you building? Does it contain API cals
not supplied by Delphi, so you used some header generation tool?

Greetings

Markus
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02