Jump to content

Chester Wilson

Members
  • Content Count

    27
  • Joined

  • Last visited

Community Reputation

5 Neutral

Technical Information

  • Delphi-Version
    Delphi 10.2 Tokyo

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Chester Wilson

    android camera problem

    Found! On the Kastri page, you have to click on "Code" before you can Download. (Beats me, but it rhymes.) NOW I can start to get some understanding.
  2. Chester Wilson

    android camera problem

    Dear Everyone, More from the struggling department! Click on that Camera | Android Developers reference and you get taken to a deprecated page. I have looked at the Java Camera2 page - which is fine if you want to write in Java! Not so helpful if you can't get the Delphi basics sorted out (but yes, it would be very helpful after that.) I have tried to get the files from Github. It does not give me an option to download. I can look at each of the files in turn, select all the text, copy then paste into notepad then save with the correct filename. Messy - but there must be a better way (which I have not found yet). Any ideas please? In Androidapi.JNI.Hardware Delphi pseudo-interfaces are created, with what should ideally be class methods, but for syntactic reasons they are just methods. Unfortunately when you type something to reference one of these methods it will not let you. (If you write one yourself, does the UUID have to match something deep in the bowels of Java, or can you just generate your own UUID?) For example, trying to get the number of cameras available to decide which to open: i := JCameraClass.getNumberOfCameras; - can't find any getNumberOfCameras function. In fact, typing JCameraClass. gives none of the "Class" functions which should be available. What syntax should be used to get this to work please?
  3. Chester Wilson

    android camera problem

    All I want to do is take a bloody piccie! Here is the next episode - trying to use the definitions in Androidapi.JNI.Hardware. It crashed most effectively with non-explanatory error messages in both 10.3 and 10.4. It needs 2 buttons (ButtonPiccie and ButtonExit) and an Image. (Not sure if this is easier than trying to send the files, or more of a nuisance - please tell me!) unit TryCamera3MainUnit; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Memo.Types, FMX.Objects, FMX.StdCtrls, FMX.Controls.Presentation, FMX.ScrollBox, System.Permissions, FMX.Memo, Androidapi.JNI.JavaTypes, Androidapi.JNIBridge, Androidapi.JNI.Hardware, Androidapi.Helpers; type TForm1 = class(TForm) ButtonPiccie: TButton; Memo1: TMemo; ButtonExit: TButton; procedure FormCreate(Sender: TObject); procedure FormActivate(Sender: TObject); procedure ButtonPiccieClick(Sender: TObject); procedure RequestPermissionsResultProc( const aPermissions : System.TArray<string>; const aGrantResults : System.TArray<tPermissionStatus>); procedure ButtonExitClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; aPermissions : System.TArray<string>; aGrantResults : System.TArray<tPermissionStatus>; implementation {$R *.fmx} procedure TForm1.FormCreate(Sender: TObject); begin Memo1.Lines.Clear; end; procedure TForm1.FormActivate(Sender: TObject); begin aPermissions := ['android.permission.CAMERA']; PermissionsService.RequestPermissions( aPermissions, RequestPermissionsResultProc); end; procedure TForm1.ButtonExitClick(Sender: TObject); begin Application.Terminate; end; procedure tForm1.ButtonPiccieClick(Sender : tObject); var Cam : JCamera; h, w : integer; begin Cam := TJCamera.Create; //Crashes here Memo1.Lines.Add(JstringToString(Cam.toString)); Application.ProcessMessages; Cam.startPreview; //Originally crashed here h := Cam.getParameters.getPictureSize.height; w := Cam.getParameters.getPictureSize.width; Memo1.Lines.Clear; Memo1.Lines.Add('Height: ' + inttostr(h)); Memo1.Lines.Add('Width: ' + inttostr(w)); end; procedure tForm1.RequestPermissionsResultProc( const aPermissions : System.TArray<string>; const aGrantResults : System.TArray<tPermissionStatus>); var s : string; begin s := 'Unknown'; case aGrantResults[0] of tPermissionStatus.Granted: s := 'Granted'; tPermissionStatus.Denied: s := 'Denied'; tPermissionStatus.PermanentlyDenied: s := 'Permanently Denied'; end; Memo1.Lines.Add(aPermissions[0]); Memo1.Lines.Add(s); end; end.
  4. Chester Wilson

    android camera problem

    Thanks for your warnings, emaiilx45! No, I am not going to take my phone back to a7 - and nor would the other users of the programme. It is interesting that Dave Nottage, to whom I sent the latest version of the programme, had no trouble running it under 10.3.3. I tried it with 10.3.3 on m computer and still got the same error message. My android seems to be 25.2.5. Could that be a problem? Otherwise my option seems to be getting / writing a java wrapper for camera2 - which looks pretty daunting!
  5. Chester Wilson

    android camera problem

    Thanks for your response, emailx45! I was trying to simplify it down to a minimalist programme to hone in on where the error may be coming from. I do not need to send any rationale to the user. The system box requesting permission is quite, quite enough! The RequestPermissions is sending me the correct information - ie that the programme has been granted CAMERA permission, and it works without any problems. The problem is in the next bit, where I try to access the camera. The error message comes after either the TakePhoto() or the TakePhotoFromCameraAction1.Execute Dave Nottage suggested that I had to get camera permissions first. I have done that successfully (well, the RequestPermissions returned .Granted, so I assume that means all is well), but the same error message persists, and I would love to be able to get rid of it. My apologies if my pascal reads like programming by a Fortran programmer! As I have nobody else for 1000km whom I know of to interact Delphi programming with, I am stuck with my background.
  6. Chester Wilson

    android camera problem

    Well, fellas, thanks for your ideas. I can request required permissions now, and get some of them! (Why it won't give me WAKE_LOCK I know not. Reasonable not to give me ELEPHANT though!) The location one still comes up with the annoyance of "only while active". I am not sure that the argument about a tracking predator is good enough to bugger it up for everyone, especially as a tracking predator would have to get hold of the victim's phone and set it all up. However, it really buggers up my job of tracking small furry mammals in the middle of Australia! I could not find anything explanatory in the suggested reading on certificates, how to use them, where to get them, and what they may be capable of doing for this problem. Unfortunately, I have had no luck with the camera stuff. I have taken your ideas, and other ideas from the net, and put together two means of accessing the camera. Neither of them works, and they still prang with the extremely unhelpful message of : "java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.XmlResourceParser android content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager,java.lang.String)' on a null object reference." The sample files are attached in a single .zip. I would greatly appreciate any ideas, as the various delphi help facilities and the net have been no help at all! Permissions.zip
  7. Chester Wilson

    android camera problem

    Sorry, EmailX45! I will accept the "hug" at the bottom of your email as a friendly "man hug" and call you by your preferred name! The problem is that the later versions of android will only allow you in the "Settings" for a programme to have location as either deniet or "Only while app is in use"! It seems to be part of their idea that some permissions are regarded as "dangerous", and therefore are limited in their availability. Unfortunately I need to be able to continue tracking (small furry animals in remote areas of Australia) without interruption - and I cannot find out how to get android to cooperate!!!! i go to another app briefly, and the GPS gets turned off my tracking programme! This is a real problem, and I would like to get a useful answer to it. Any idea whom I should ask?
  8. Chester Wilson

    android camera problem

    Have you any idea how to get location permission not only for when the programme is the primary one on the screen, but always? In earlier androids I could continue tracking, go off an do something else briefly, then return to the tracking programme. In recent androids this turns off the location to the tracking programme, really messing up the data collection! (Why they think location is a dangerous privilege I do not know. The only time I can see it being dangerous is if I am going somewhere where my wife does not want me to go, and she finds out about it!)
  9. Chester Wilson

    android camera problem

    Thanks, hug! I will tackle it over the next few days. Even if the permissions for a programme have been set in "Settings" on an android device, and set up in the programme (project/options etc), is it still necessary to go through all the code for the permissions in the programme as well? Or is that so that the user can get an error message telling him which permissions have not been set?
  10. Chester Wilson

    android camera problem

    I am having great difficulty getting a firemonkey programme to take piccies on an android device. This is the simplest programme I have managed to put together for this. It keeps blowing up no matter what I try! (I have put 3 full days work into it, with no success, and now seek help!) I am using Delphi in Embarcadero® RAD Studio 10.4 Version 27.0.37889.9797 (it will be a month before I can get home to download Sydney). The phone I am working on is a Huawei P20 Pro with android 10 (can I have android 7 back please?????) I got Marco's GitHub main form for a camera, and got the same error from it. I wondered if it were a Delphi bug, and sent it off to Quality.Embarcadero. Dave Nottage kindly replied, telling me to set the permissions. However, if the permissions are not set, the error message is different, and setting the permissions did not help. I sent back that Dave's considered response did not help any, but have heard nothing since. It is necessary to run it once, then go and set up the android settings permissions since android have become cripplingly paranoid from V10. The error message is: Project TryCamera1.spk raised exception class EJNIException with message 'java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData (android.content.pm.PackageManager, java.lang.String)' on a null object reference'. The crash comes on ExecuteTarget in FMX.MediaLibrary.Action where it is called with FCameraService.TakePhoto TryCamera1.dpr TryCamera1.dproj TryCamera1.dproj.local TryCamera1.identcache TryCamera1.res TryCameraMainUnit.fmx TryCameraMainUnit.pas TryCameraMainUnit1.fmx TryCameraMainUnit1.pas
  11. Chester Wilson

    Present status of Indy

    Thanks, Remy. Tim Frost has kindly found Indy Help under Delphi/Help/Third Party Help. I had finally found a 2012 PDF Delphi in Depth, but the new one on the system is very nice - many thanks, Tim!
  12. Chester Wilson

    GDB server problems in 10.4

    Love your bug! The problem fixed itself after a couple of days, and has not recurred.
  13. Chester Wilson

    Present status of Indy

    Does anyone know the current status of Indy? It is installed on 10.4 with no help files. Pulling (quite a large collection!) of supposed Indy Help files from the net gives .htm files which tell you nothing about the component you are after help on and/or say they have been redirected to a non-extant site; or .chm files which microsoft thinks are variant htm files and deals with inappropriately and unhelpfully. The Indy components can be put in a programme, but to use values (eg tIdPOP3.Authorise = adAuth (I can't remember the name the .pdf file eventually gave me) only fails to be able to define the value! It must be hidden somewhere in another Indy file.
  14. Chester Wilson

    DeleteFile Compilation Message

    May I ask yet another really dumb question please? What has Posix got to do with Delphi? Or is it to do with running Firemonkey on Android-trying-to-be-a-Posix-flavour? Or did it come from Kylix?
  15. Just updated a Huawei P20 phone to Android 10, and am finding the things that it has now broken! This code worked fine in android 9. Using Delphi 10.4. FileData=tfile.ReadAllLines('/storage/emulated/0/Documents/Pete/PeteADefaults.cfg') now prangs with Cannot open file "/storage/emulated/0/Documents/Pete/PeteADefaults.cfg" Permission denied. Anyone got any bright ideas? I tracked it through with F7 to FileOpen in System.IOUtils, FileHandle := __open(M.AsAnsi(filename, CP_UTF8).ToPointer, (Mode and 3), FileAccessRights) which returns -1. (Can't read files or directories either - probably the same problem)
×