16-05-2024, Saat: 18:44
(09-05-2024, Saat: 10:31)mrmarman Adlı Kullanıcıdan Alıntı: Embarcadero örneklerinde buna ilişkin örnek var, baktınız mı? Oradan başlayıp takıldığınız yerde yardımcı oluruz
Merhabalar hocam, sorunu çözdüm.
unit Unit1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, System.Messaging, FMX.Platform,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, Androidapi.JNI.GraphicsContentViewText,
FMX.Controls.Presentation, FMX.StdCtrls, FMX.Layouts, FMX.WebBrowser, FMX.Objects, FMX.ScrollBox, FMX.Memo,
FMX.Memo.Types;
type
TForm1 = class(TForm)
ToolBar1: TToolBar;
Layout1: TLayout;
Memo1: TMemo;
Label1: TLabel;
Image1: TImage;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
function HandleAppEvent(AAppEvent: TApplicationEvent; AContext: TObject): Boolean;
procedure HandleActivityMessage(const Sender: TObject; const M: TMessage);
function HandleIntentAction(const Data: JIntent): Boolean;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
uses FMX.Platform.Android, Androidapi.JNI.JavaTypes, Androidapi.JNI.Net, Androidapi.JNI.Os, Androidapi.Helpers,
Androidapi.JNIBridge, FMX.Surfaces, FMX.Helpers.Android;
procedure TForm1.FormCreate(Sender: TObject);
var
AppEventService: IFMXApplicationEventService;
begin
if TPlatformServices.Current.SupportsPlatformService(IFMXApplicationEventService, AppEventService) then
AppEventService.SetApplicationEventHandler(HandleAppEvent);
MainActivity.registerIntentAction(TJIntent.JavaClass.ACTION_VIEW); //text/pas
MainActivity.registerIntentAction(TJIntent.JavaClass.ACTION_SEND); //IMAGE
TMessageManager.DefaultManager.SubscribeToMessage(TMessageReceivedNotification, HandleActivityMessage);
end;
procedure TForm1.HandleActivityMessage(const Sender: TObject; const M: TMessage);
begin
if M is TMessageReceivedNotification then
HandleIntentAction(TMessageReceivedNotification(M).Value);
end;
function TForm1.HandleAppEvent(AAppEvent: TApplicationEvent; AContext: TObject): Boolean;
var
StartupIntent: JIntent;
begin
Result := False;
if AAppEvent = TApplicationEvent.BecameActive then
begin
StartupIntent := MainActivity.getIntent;
if StartupIntent <> nil then
HandleIntentAction(StartupIntent);
end;
end;
procedure URI2Bitmap(const AURI:Jnet_Uri; const ABitmap:TBitmap);
var
bitmap:JBitmap;
surface: TBitmapSurface;
begin
bitmap:= TJBitmapFactory.JavaClass.decodeStream(
TAndroidHelper.Context.getContentResolver.openInputStream(AURI));
surface :=TBitmapSurface.Create;
JBitmapToSurface(bitmap, surface);
TThread.Queue(nil, procedure begin ABitmap.Assign(surface); end);
end;
function TForm1.HandleIntentAction(const Data: JIntent): Boolean;
var
Extras: JBundle;
Parcelable:Jparcelable;
bitmap: JBitmap;
// surface: TBitmapSurface;
begin
Result := False;
if Data <> nil then
begin
Memo1.ClearContent;
Memo1.Lines.Add('Handle Intent Action: Data');
Memo1.Lines.Add('Type :'+JstringToString(Data.getType));
Memo1.Lines.Add('Action: '+JStringtoString(Data.getAction));
Extras := Data.getExtras;
if Extras <> nil then
begin
Memo1.Lines.Add('');
Memo1.Text := JStringToString(Extras.getString(TJIntent.JavaClass.EXTRA_TEXT));
end;
Parcelable :=Data.getParcelableExtra(TJIntent.JavaClass.EXTRA_STREAM);
if Parcelable<>nil then
begin
Memo1.Lines.Add('Got Parcelable...');
Memo1.Lines.Add(JUriToStr(TJnet_Uri.Wrap((Parcelable as ILocalObject).GetObjectID)));
Uri2Bitmap(TJnet_Uri.Wrap((Parcelable as ILocalObject).GetObjectID), Image1.Bitmap);
end;
Invalidate;
end;
end;
end.
Seçtiğim tek bir dosyayı programa gönderebiliyorum.
Peki birden fazla dosyayı seçip paylaş dediğimde program kaç tane dosya geldiğini nasıl anlıyacak?


