Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-08

lazdeviceapis

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Kjow

Hi all,

I would use android sensors (vibration, accelerometer, etc) without LCLBase, is it possible?.

My skill about these things is quite low, so please excuse me if my language is not too technical or my concepts are too trivial.

I can compile for android-arm (latest lazarus/fpc trunk svn revisions at now) and build apk well in lazarus/fpc, both with or without LCL (e.g. androidlcl). Of course, without LCL I haven't forms, etc, but I can use ZenGL that draws in OpenGL very very quickly (60fps stable with a lot of objects [sprites, etc] and 2d physics on Galaxy Note, a two years old device).

I added LCLBase to the project requirements, it compiles well and the app works, of course no calls are made.
Now, if I just add lazdeviceapis to units, it compiles well, but the app crashes at start without any calls (e.g. device.vibrate() ).

Then, I tried to "extract" from lazdeviceapis what seem to be "useful", and I can make an unit that can compile well (without LCLBase requirement). The app start and works ok, but when I call something (e.g. device.vibrate(250) ) the app crashes.

I know there is a part in ".java" needed, I tried to do something, but unsuccessfully (I think).

Any help?

Thank you,
Kjow
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130806/be85e309/attachment.html>

Reply by email

Felipe Monteiro de Carvalho
to Kjow
Kjow wrote
I would use android sensors (vibration, accelerometer, etc) without LCLBase, is it possible?.

No. But you can just copy the code from the android implementation of lazdeviceapis to your project and adapt it.

Felipe Monteiro de Carvalho

Reply by email

Kjow
to Felipe Monteiro de Carvalho

2013/8/6 Felipe Monteiro de Carvalho

Show quoted text 8 lines
On Tue, Aug 6, 2013 at 12:38 PM, Kjow wrote: > I would use android sensors (vibration, accelerometer, etc) without LCLBase, > is it possible?. No. But you can just copy the code from the android implementation of lazdeviceapis to your project and adapt it.

Hi Felipe,

can you help me to make it working? I made this unit (in attachment) that compiles and works until I call something (e.g. device.vibrate(100) ).

In MyProjectActivity.java I added, after "onCreate":

public native int LCLOnSensorChanged(int ASensorKind, double[] AValues);

and then almost all "SensorEventListener overrides"

@Override public void onSensorChanged(SensorEvent event)

...
...
...
  // for LazDeviceAPIs
  public String lcldestination;
  public int lclkind;

I can't find/understand where are used LCLOnSensorChanged, lcldestination, etc in andriodlcl demo.

Of course, in AndroidManifest.xml I have:

<uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.SEND_SMS" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

I'm hoping my explanation is clear enough.

Thank you,
Kjow
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130806/6c0daf4e/attachment.html> -------------- next part --------------
A non-text attachment was scrubbed...
Name: sensorapi.zip
Type: application/zip
Size: 2669 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130806/6c0daf4e/attachment.zip>

Reply by email