Recent

Author Topic: Android LAMW Share File  (Read 1441 times)

Odanka

  • New member
  • *
  • Posts: 24
Android LAMW Share File
« on: December 19, 2018, 05:00:06 am »
LAMW share file by jShareFile or jIntentManger, everything is fine and work properly in android < 5.0  (lolypop) but problem occur on android > 7 (nougat).
Anyone Please..
Thank you.

jmpessoa

  • Hero Member
  • *****
  • Posts: 1346
Re: Android LAMW Share File
« Reply #1 on: December 19, 2018, 06:48:28 am »
Hi Odanka!

The "AppCameraDemo" show how to handle "run time  permission"  [read/write and others] ...

PS. Please,  write in "Android"  forum entry...
« Last Edit: December 19, 2018, 06:52:14 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Odanka

  • New member
  • *
  • Posts: 24
Re: Android LAMW Share File
« Reply #2 on: December 19, 2018, 07:20:43 am »
JNI prompt taken from CameraDemo (Runtime Permission)
Code: Pascal  [Select]
  1. // Permission
  2.   if IsRuntimePermissionNeed() then   // that is, target API >= 23
  3.   begin
  4.  
  5.     ShowMessage('warning: Requesting Runtime Permission.... please, wait..');
  6.  
  7.     SetLength(manifestPermissions, 2);
  8.  
  9.     manifestPermissions[0] := 'android.permission.CAMERA';  //from AndroodManifest.xml
  10.     manifestPermissions[1] := 'android.permission.WRITE_EXTERNAL_STORAGE';
  11.     //from AndroodManifest.xml
  12.  
  13.     RequestRuntimePermission(manifestPermissions, 1001);
  14.  
  15.     SetLength(manifestPermissions, 0);
  16.  
  17.   end;  
  18.  
OnPermissionResult:
Code: Pascal  [Select]
  1.   case requestCode of
  2.     1001:
  3.     begin
  4.       if grantResult = PERMISSION_GRANTED then
  5.         ShowMessage('Success! [' + manifestPermission + '] Permission grant!!! ')
  6.       else  //PERMISSION_DENIED
  7.         ShowMessage('Sorry... [' + manifestPermission +
  8.           '] Permission not grant... ');
  9.     end;
  10.   end;
  11.  
Sharing Action :
Code: Pascal  [Select]
  1.       jIntentManagers.SetAction('android.intent.action.SEND');
  2.       jIntentManagers.SetMimeType('image/png');
  3.       jIntentManagers.PutExtraFile(GetEnvironmentDirectoryPath(
  4.         dirDownloads), 'estimasi.png');
  5.       if jIntentManagers.IsCallable(jIntentManagers.GetIntent()) then
  6.         jIntentManagers.StartActivity()
  7.       else
  8.         ShowMessage('No Activity found to handle Intent');
  9.  
Please help me, do not work on android 7+ (nougat).

Odanka

  • New member
  • *
  • Posts: 24
Re: Android LAMW Share File
« Reply #3 on: December 19, 2018, 07:24:53 am »
Once Again, I'm sorry for miss place.

jmpessoa

  • Hero Member
  • *****
  • Posts: 1346
Re: Android LAMW Share File
« Reply #4 on: December 19, 2018, 07:33:52 am »

Yes, but you need to adapt the example code.....
[you dont need camera permission!  Only read/write]
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Odanka

  • New member
  • *
  • Posts: 24
Re: Android LAMW Share File
« Reply #5 on: December 19, 2018, 07:50:50 am »
I'm still learning. Did you mean code to adapt as bellow?
Code: Pascal  [Select]
  1. procedure TAndroidModule1.AndroidModule1ActivityResult(Sender: TObject;
  2.   requestCode: integer; resultCode: TAndroidResult; intentData: jObject);
  3. begin
  4.   if resultCode = RESULT_CANCELED then
  5.   begin
  6.     ShowMessage('Photo Canceled!')
  7.   end
  8.   else if resultCode = RESULT_OK then //ok...
  9.   begin
  10.     if requestCode = jCamera1.RequestCode then
  11.     begin
  12.       jBitmap1.LoadFromFile(jCamera1.FullPathToBitmapFile);
  13.       jImageView1.SetImageBitmap(jBitmap1.GetImage, jImageView1.Width, jImageView1.Height);
  14.  
  15.       FPhotoExist:= True;
  16.       jView1.Refresh;   //dispatch   OnDraw!
  17.     end;
  18.   end
  19.   else
  20.     ShowMessage('Photo Fail!');
  21.  
  22. end;
  23.  

jmpessoa

  • Hero Member
  • *****
  • Posts: 1346
Re: Android LAMW Share File
« Reply #6 on: December 19, 2018, 08:18:49 am »

Wait.  I'll update the demo "AppShareFileDemo1" today....
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Odanka

  • New member
  • *
  • Posts: 24
Re: Android LAMW Share File
« Reply #7 on: December 19, 2018, 08:22:24 am »
I'm waiting, and Thank you very-very much.

jmpessoa

  • Hero Member
  • *****
  • Posts: 1346
Re: Android LAMW Share File
« Reply #8 on: December 20, 2018, 05:50:58 am »
Done !!!

Added "run time permission" to "AppShareFileDemo1"
need by Android 6.0+ [target Api 23+]

Thank you!
« Last Edit: December 20, 2018, 05:55:09 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Odanka

  • New member
  • *
  • Posts: 24
Re: Android LAMW Share File
« Reply #9 on: December 20, 2018, 08:22:50 am »
Done!!! and work properly.
Very-very Thank you JMPESSOA.
« Last Edit: December 20, 2018, 08:30:49 am by Odanka »

Odanka

  • New member
  • *
  • Posts: 24
Re: Android LAMW Share File
« Reply #10 on: December 20, 2018, 08:26:04 am »
And I'm finding the answers my self of why 5001 in RequestRunTimePermission.  :)