Tuesday, 6 May 2014

Delphi XE6 App tethering and barcodes


Fun with Delphi XE6 App tethering and barcodes


One of the new key features in XE6 is what Embarcadero has chosen to call App Tethering components - the only problem I initially had with the name was that it implied that mobile had to be involved in some way - which is not the case. You can make a windows service that is a "receiver" from a desktop application running on the same sub-net.

An example could be POS systems, running on various devices talking to the same receiver - without bothering about implementing multiple communications protocols - these components all wraps this up nicely.

I wanted to give these new component a try, by making a very simple barcode scanner using my phone as the barcode scanner and then have the receiver send the barcode to whatever application was active.

A word of warning: this is a prof of concept - not ready for production or deployment - you need to do some work yourself to make it fit your needs. I have tried to use as little code as possible - leaving out all exception handling :-).


Part 1 - The "receiver" desktop app.


Start with a new Desktop application either VCL or FireMonkey will do, add a TTetheringManager, a TTetheringAppProfile, a TLabel and a TCheckBox - which all should end up looking a bit like this:


Change the (Manager)Text property on the TTetheringManager to 'BarcodeReceiverManager', on the TTetheringAppProfile change the (Profile)Text property to 'BarcodeReceiver' and set the Manager property to point to the TTetheringManager.

Since we want to send the received barcode to the active application, we just use a send key function - in this case I have just used the WinAPI keybd_event() method - it would be more correct to use SendInput() - but the barcodes consists of non-unicode characters. For the letters we also need to send along the shift key.

  procedure SendKeys(const S: String);
  var
    I: Integer;
  begin
    for I := 1 to Length(S) do
    begin
      if CharInSet(S[I], ['A'..'Z']) then
        keybd_event(VK_SHIFT, 0, 0, 0);
      keybd_event(Ord(S[I]), MapVirtualKey(Ord(S[I]), 0),0, 0);
      keybd_event(Ord(S[I]), MapVirtualKey(Ord(S[I]), 0), KEYEVENTF_KEYUP, 0);
      if CharInSet(S[I], ['A'..'Z']) then
        keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
    end;
  end;

On the TTetheringAppProfile.OnResourceReceived event add the following code to send the string received from the mobile app - and maybe a carriage return - if our TCheckBox is checked.

 SendKeys(AResource.Value.AsString);
 if cbAddReturn.IsChecked then
   SendKeys(char(13));


Part 2 - The "sender" mobile app.

Create a new FireMonkey Mobile Application, add a TTetheringManager, a TTetheringAppProfile, a TEdit, a TLabel and two TSpeedButtons - which all should end up looking a bit like this:

This design will never get accepted on any App Store :-D

On the TTetheringAppProfile set the Manager property to point to the TTetheringManager.

Now on the FormShow event we want to unpair any Managers already paired with this TTetheringManager, and after that trigger the Discover event.

 for I := TetheringManager1.PairedManagers.Count - 1 downto 0 do
   TetheringManager1.UnPairManager(TetheringManager1.PairedManagers[I]);
 TetheringManager1.DiscoverManagers;

At the end of the discovery, the TTetheringManager.OnEndManagersDiscovery event is called:

 for I := 0 to RemoteManagers.Count-1 do
   if (RemoteManagers[I].ManagerText = 'BarcodeReceiverManager')  then
   begin
     TetheringManager1.PairManager(RemoteManagers[I]);
     Break; // Break since we only want the first...
   end;

 followed by the TTetheringManager.OnEndProfilesDiscovery event:

 Label1.Text := 'No receiver found';
 for i := 0 to TetheringManager1.RemoteProfiles.Count-1 do
   if (TetheringManager1.RemoteProfiles[i].ProfileText = 'BarcodeReceiver') then
   begin
     if TetheringAppProfile1.Connect(TetheringManager1.RemoteProfiles[i]) then
       Label1.Text := 'Receiver ready.'
   end;

Notice the only two references to the "Text" properties we set in our "receiver" applications Manager and Profile components - the rest is done by magic (or a lot of Indy code I didn't need to write :-D)

And the last thing we need to add is on the OnClick event of the "Send barcode" button:

 TetheringAppProfile1.SendString(TetheringManager1.RemoteProfiles[0], 
                                 'Barcode from mobile', Edit1.Text);

Now we can start our "receiver" application, and run our "sender" mobile app on iOS or Android, and in theory it should work.

I did put the tethering example to a minimum, for a more correct examples see the samples include with XE6 - it seems that there is a lot of extra stuff hidden in these 2 components - maybe for another post.

Part 3 - Barcode scanning.

There are some examples out there for doing this both on Android and iOS - I guess you could also invest in some commercial components like those from TMS or WinSoft.

I previously been using the ZBar library on iOS/ObjectiveC and xzing library Android/Java - because ZBar wasn't that good on Android years back.

For this example I am only going to do Android using xzing as what is called an intent. I guess that using intents on Android is best practice, but I guess most Delphi developers are not that keen on being depending on any framework or other thing we do not control - like Windows :-D

When doing Android Apps in Java, I did not always follow the intent way, but included the xzing core.jar file - that would also be possible in Delphi - but getting the classes wrapped into Delphi interfaces would take some work, or someone should sponsor me by buying either WinSoft JavaImportor CHUA Chee Wee's Android2DelphiImport - even better if Embarcadero bundles one of them in XE6 update 1 :-)

Update: Software Union also provides Java2Pas which might do the trick.

I did have a peek at the code from Thomas K's TKRBarcodeScanner component (beware terrible link :-) ) which for iOS is depending on the TMS component.

Since we are going to use the clipboard to get the barcode from the xzing intent, and still behave as good citizens preserving what is already there - we declare some variables:

 FPreservedClipboardValue: TValue;
 FMonitorClipboard: Boolean;
 ClipService: IFMXClipboardService;

Notice the TValue from the System.Rtti unit - it is kind of a Variant and then not.
On the FormCreate event we start testing if the platform supports what we think of as a clipboard, and we also wants it to support application events - so that we can check when the intent is done and our app becomes active again.

 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;

Now we want to call the xzing intent to scan a barcode, put the result on the clipboard and return when done. So on the OnClick event of the "Scan barcode" we put the following code:

 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'));
 //    intent.putExtras(TJIntent.JavaClass.EXTRA_TEXT, StringToJString('"SCAN_MODE", "CODE_39"'));
   SharedActivity.startActivityForResult(intent, 0);
 end;

We create an instance of TJIntent, set its action to the zxing barcode scanner intent, which you might need to install on your mobile before running this app, if you do not already have the intent via some other app. You need to convert the name of the intent to a Java string. You can among other things also specify which barcode types that can be read - doing that increases the speed and precision of the scanning - so if you know you only need Code 39 or EAN13 you should specify that.

When the application event fires, we check if it was because our app became active and we were monitoring the clipboard.

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

The GetBarcodeValue function gets the barcode from the clipboard, and restores the old value from before we initiated the scan:

 Result := False;
 FMonitorClipboard := False;
 if (ClipService.GetClipboard.ToString <> 'nil') then
 begin
   Edit1.Text := ClipService.GetClipboard.ToString;
   ClipService.SetClipboard(FPreservedClipboardValue);
   Result := True;
 end;

Done - you should now have a working app - which could need a lot of extra error checking and care. But like baking your own bread I hope this has been fun. I have added some extra links below to people or code that might also be helpful - including the full code for download. If you just have interest in the barcode part there are better examples in the links below - also be aware that in XE6 the StringToJString has move to the Androidapi.Helpers unit.

Links:

The source code: Receiver application and Scanner app.
Jim McKeeth is always helpfull: http://delphi.org/2014/02/scanning-barcodes-with-rad-studio-xe5/
FMX Express is very active collecting relevnat stuff: http://www.fmxexpress.com/qr-code-scanner-source-code-for-delphi-xe5-firemonkey-on-android-and-ios/ - there is also a better link to Thomas K. code there.
John Whitham should also be mentioned: http://john.whitham.me.uk/xe5/

Monday, 5 May 2014

Jual 81 Sourcecode Skripsi

Didevelop dengan delphi


No Judul



1 Sistem Pengolahan Data Perusahaan Untuk Setiap Kabupaten Pada Departemen Tenaga Kerja dan Transmigrasi Provinsi xxx

2 Perangkat Lunak Aplikasi Dokter Praktek Pada Apotik xxx Farma xxxxi

3 Aplikasi Data Penjualan Spare Part Pada PT. Astra International Tbk Honda xxx

4 Sistem Pengolahan Data Pegawai Pada Kantor Badan Kepegawaian Daerah (BKD) Kabupaten Buton Utara

5 Sistem Pengolahan Data Inventaris Barang Pada STIE Dharma Bharata Grup xxx

6 Sistem Pengolahan Data Keuangan Pengurusan Paspor Pada Kantor Imigrasi xxx

7 Sistem Pengolahan Data Penjualan Barang Furniture Pada Toko Antiek Interior xxx

8 Sistem Pengolahan Data Bimbingan Klien Anak Pada Kantor Balai Pemasyarakatan (BAPAS)Klas IIA xxx

9 Komputerisasi Data Madrasah Pada Departemen Agama Kota xxx

10 Sistem Pengolahan Data Kriminal Pada Polres Kota xxx

11 Perancangan Sistem Informasi Pembuatan Kartu AK1 (Kartu Pencari Kerja) Pada Dinas Sosial, Tenaga Kerja dan Transmigrasi Kabupaten Konawe Provinsi Sulawesi Tenggara

12 Aplikasi Pengolahan Data Nasabah Pada Koperasi Serba Usaha Mitra Jaya Buton Utara

13 Sistem Pengolahan Data Paspor Pada Kantor Imigrasi Kelas I xx

14 Sistem Pengolahan Data PDRB Atas Dasar Harga Berlaku Pada BPS Kota xx

15 Aplikasi Pengolahan Data Nasabah Pada Koperasi Simpan Pinjam Toro Meambo xxxxxx

16 Sistem Pengolahan Data Kasus Pembebasan Bersyarat Pada Bimbingan Klien Dewasa (BKD) Pada BAPAS KDI

17 Sistem Pengolahan Data Pendistribusian Majalah, Tabloid dan Koran Pada PT. Ade Sula Sultra Persada Unit Ade Agency xxxxxx

18 Sistem Pengolahan Data Laporan Retribusi Penerimaan Anggaran Pendapatan Daerah Pada Dispenda Sultra

19 Sistem Pengolahan Data Pendistribusian Bahan Bangunan Pada PT. Ade Sultra Persada Unit Ade Sula Graha

20 Komputerisasi Data Jamaah Haji Pada Kantor Departemen Agama Kota xxxxxx

21 Perangkat Lunak Sistem Produksi Pada Melia Loundry dan Drycleaning Kota xxxxxx

22 Sistem Pengolahan Data Pembayaran Lost Pada PD. Pasar Kota xxxxxx(Mall Mandonga xxxxxx)

23 Aplikasi Peserta Keluarga Berencana (KB) Pada Puskesmas Kemaraya Dengan Menggunakan Bahasa Pemrograman Delphi 7.0

24 Sistem Pengolahan Data Peserta Bimbingan Belajar Pada JILC xxxxxx

25 Sistem Informasi Pengolahan Data Taksi Pada PT. Ade Sultra Persada xxxxxxMenggunakan Delphi 6.0

26 Sistem Pengolahan Data Monitoring Pencacah Lapangan (PCL) Sensus Penduduk Pada BPS Prov. Sultra

27 Sistem Pengolahan Data Arus Kas Pada Toko FinaEka Seluler xxxxxx

28 Komputerisasi Data Pengiriman Barang Pada PT. Yapindo Transportama (PCP) Cabang xxxxxx

29 Sistem Pengolahan Data Siswa Pelatihan Pada UPTD Balai Latihan Kerja UKM xxxxxx

30 Sistem Pengolahan Data Akademik Pada Akademi Farmasi Bina Husada xxxxxx

31 Komputerisasi Data Pengguna Narkoba Pada Badan Narkotika Nasional Provinsi Sulawesi Tenggara

32 Komputerisasi Pengolahan Data Keuangan MAN I xxxxxx

33 Sistem Pengolahan Data Keuangan Pada Hotel Kubra xxxxxx

34 Sistem Pengolahan Data Penggajian Guru dan Staf Pada Sekolah Dasar Negeri Wawobende

35 Sistem Informasi Produksi dan Pemasaran Pada Percetakan Sultra

36 Sistem Pengolahan Data Sertifikasi Guru Pada Dinas Pendidikan Nasional Kota xxxxxx

37 Sistem Pengolahan Data Penjualan Pada UD. Samudera Anugrah xxxxxx

38 Komputerisasi Kepemilikan Taksi Pada PT. Ade Sultra Persada xxxxxx

39 Sistem Pengolahan Data Jasa Angkutan Kontainer Pada PT. Samudera Raya Indo Lines (SRIL) xxxxxx

40 Sistem Pengolahan Data Peserta KB Pada Puskesmas xxxxxx

41 Sistem Pengolahan Data Karyawan Pada CV. KingMart Mall Mandonga xxxxxx

42 Sistem Pengolahan Data Keuangan Pemasukan dan Pengeluaran Kas Pada Ziola Selular xxxxxx

43 Sistem Pengolahan Laporan Penjualan Kosmetik Pada Toko Indriani xxxxxxxxxxxx

44 Sistem Pengolahan Data Pembayaran Kredit Lost Pada Pasar Sentral Kota xxxxxx

45 Sistem Pengolahan Data Akta Pada Kantor Badan Keluarga Sejahtera Kependudukan dan Catatan Sipil Kota xxxxxx

46 Sistem Pengolahan Data Penjualan Meubel Pada Usaha Dagang Meubel Selutibar Jaya xxxxxx

47 Sistem Pengolahan Data Persediaan Barang Dagangan Pada PT. Fajar Lestari Abadi xxxxxx

48 Sistem Pengolahan Data Penjualan Handphone Pada Semesta Sellular xxxxxx

49 Sistem Pengolahan Data Mahasiswa Pada Akademi Keperawatan Pemerintah Daerah Konawe

50 Sistem Pengolahan Data Santri Pada Pondok Pesantren Ummussabri xxxxxx

51 Sistem Pengolahan Data Industri Besar Sedang Kota xxxxxxPada Kantor BPS Kota xxxxxx

52 Perangkat Lunak Sistem Administrasi Keuangan Berbasis Jaringan Pada PT. Daka Lintas Samudra xxxxxx

53 Sistem Pakar Diagnosa Hama dan Penyakit Pada Tanaman Kakao

54 Perangkat Lunak Sistem Informasi Pendidikan dan Pelatihan Pada LEPPINA xxxxxx

55 Sistem Pengolahan Data Penerimaan dan Pengeluaran Kas Pada Frid Ultra xxxxxx

56 Sistem Informasi Pengolahan Data Pasien Pada Rumah Sakit Umum Provinsi Sulawesi Tenggara

57 Aplikasi Pemesanan Tiket Pada PT. PELNI xxxxxx

58 Sistem Pengolahan Data Pemasaran Aspal Pada PT. Sarana Karya (Persero) Kabupaten Buton

59 Aplikasi Data Harian Seksi Pemasaran dan Informasi Pada PPS Kenxxxxxxdari

60 Sistem Pengolahan Data Pemakaian Bahan dan Alat-Alat Laboratorium Pada UPTD Balai Litbang Industri xxxxxx

61 Sistem Pengolahan Data Siswa Pelatihan Pada Balai Latihan Kerja UKM xxxxxx

62 Komputerisasi Data Pengiriman Barang Pada PT. Citra Van Titipan Kilat (TIKI) Cabang

63 Sistem Pengolahan Data Pajak Kendaraan Bermotor Pada UPTD Samsat Provinsi Sulawesi Tenggara

64 Sistem Pengolahan Data Perpustakaan Pada Akademi Komputer Global xxxxxx

65 Sistem Pengolahan Data Bengkel Pemeliharaan Pada PT. Sinar Galesong Pratama xxxxxx

66 Sistem Pengolahan Data Penerimaan dan Pengeluaran Kas Pada CV. Tepung Emas Utama (T.E.U) xxxxxx

67 Sistem Pengolahan Data Pemasaran Rumah Pada Perum Perumnas Cabang Sultra

68 Pengolahan Data Tenaga Kerja Pada Kantor Dinas Tenaga Kerja dan Transmigrasi Provinsi Sulawesi Tenggara

69 //

70 Sistem Komputerisasi Akuntansi Terhadap Laporan Keuangan Pada SMP Frater xxxxxx

71 Sistem Pengolahan Data Perkara Pada Pengadilan Negeri xxxxxx

72 Sistem Pengolahan Data Pasien Rawat Inap Pada Rumah Sakit Bhayangkara xxxxxx

73 Sistem Pengolahan Data Pendapatan dan Pengeluaran Driver Taxi Pada PT. Ade Sultra Persada

74 Sistem Komputerisasi Laporan Keuangan Pada Akademi Manajemen Informatika dan Komputer Global xxxxxx

75 Sistem Pengolahan Data Peserta Ujian SD-SMA Pada Kantor Dinas Pendidikan Kota xxxxxx

76 Sistem Pengolahan Data Peminjaman Buku Pada Perpustakaan Fakultas Teknik Universitas Haluoleo xxxxxx

77 Sistem Perangkat Lunak Surat Izin Usaha Perdagangan Pada Disperindagkop xxxxxx

78 Sistem Aplikasi Pembayaran Iuran Osis Pada SMP Negeri 4 xxxxxxDengan Menggunakan Bahasa pemograman Borland Delphi 7.0

79 Sistem Pengolahan Data Karyawan Pada PT. Triple Eight Energy

80 Pengolahan Data Remisi Nara Pidana Pada Pemasyarakatan Kanwil Departemen Hukum dan Ham Sultra

81 Sistem Komputerisasi Pendaftaran Mahasiswa Baru Pada Stie Dharma Barata Grup xxxxxx

Saya jual sebesar 1.5 juta
hanya sourcecode ....
minat sms aja langsung 

Fajar Priyadi >> 081290906693

BCA - 8600191200 - Fajar Priyadi

Install Fortesreport community Delphi 7 dan RX Berlin

Download  Pertama2 kita harus punya file installernya terlebih dahulu, download  https://github.com/fortesinformatica/fortesrepo...