Ver Mensaje Individual
  #2  
Antiguo 01-10-2015
aposi aposi is offline
Miembro
 
Registrado: dic 2006
Posts: 146
Reputación: 18
aposi Va por buen camino
Hola,

descarga en el telefono el programa Barcode Scanner de zxing

en el Create del form pon este codigo:

Código Delphi [-]
procedure TForm1.FormCreate(Sender: TObject);
var
   aFMXApplicationEventService: IFMXApplicationEventService;
 begin
   FMonitorClipboard := False;
   if not TPlatformServices.Current.SupportsPlatformService(IFMXClipboardService,  IInterface(ClipService)) then
     ClipService := nil;
   if TPlatformServices.Current.SupportsPlatformService(IFMXApplicationEventService,  IInterface(aFMXApplicationEventService)) then
   begin
     aFMXApplicationEventService.SetApplicationEventHandler(HandleAppEvent);
   end
   else
   begin
     Log.d('Application Event Service is not supported.');
   end;

end;


Crea estas dos funciones:

Código Delphi [-]
unction TForm1.GetBarcodeValue: Boolean;
var
  value: String;
begin
  Result := False;
  FMonitorClipboard := False;
  if (ClipService.GetClipboard.ToString <> 'nil') then
  begin
    Edit1.Text := ClipService.GetClipboard.ToString;
    ClipService.SetClipboard(FPreservedClipboardValue);
    Result := True;
  end;
end;

function TForm1.HandleAppEvent(AAppEvent: TApplicationEvent;
  AContext: TObject): Boolean;

begin
  Result := False;
  if FMonitorClipboard and (AAppEvent = TApplicationEvent.BecameActive) then
  begin
    Result := GetBarcodeValue;
  end;

end;



Crea un boton y que ejecute este codigo:

Código Delphi [-]

procedure TForm1.SpeedButton1Click(Sender: TObject);
var
  intent: JIntent;
begin
   if Assigned(ClipService) then
  begin
    FPreservedClipboardValue := ClipService.GetClipboard;
    FMonitorClipboard := True;
    ClipService.SetClipboard('nil');
    intent := TJIntent.Create;
    intent.setAction(StringToJString('com.google.zxing.client.android.SCAN'));

    SharedActivity.startActivityForResult(intent, 0);
  end;
end;
Responder Con Cita