Search This Blog

13 March 2024

Flutter

Let's look at some data for Flutter usage taken from the StackOverflow yearly developer survey. We will track how much Flutter and Dart change over the years. We can see that up to 2021 Flutter is growing for a top of 13.55%. After 2021 there is a downward trend.
















https://survey.stackoverflow.co/2019

https://survey.stackoverflow.co/2020

https://survey.stackoverflow.co/2021

https://survey.stackoverflow.co/2022

https://survey.stackoverflow.co/2023/


Some other ratings. These don't rank frameworks, but knowing the connection between Flutter and Dart, we would look at Dart ratings:

https://redmonk.com/sogrady/2023/05/16/language-rankings-1-23/

Rates Dart at place 19.

https://www.tiobe.com/tiobe-index/

Rates Dart at place 32 with overall percentage of 0.50%.

It seems that Flutter is following the normal path for a cross platform framework. Initial growth, because a lot of people believe the promise of write once, run everywhere, faster, better, easier. Then cool off, because these promises are not quite correct in general.

Comparing cross platform development for mobile, I can say Flutter looks best at the moment. Seems a lot easier than for example React Native. In addition it can do web applications as well.

Apart from Cordova or any embedded browser view framework, any of the other frameworks bring a big build complexity with them - what is the build process; what framework specific libraries are you going to use; how does this new dependencies tie with your project; what if you need to have a part of the application in native, how does this tie with the framework; Unknowns, decisions, problems and dilemmas. With native you have one problem - supporting two platforms - having two developer profiles Android and iOS. With cross platform you have additional problems.

In general if web is enough, than this is your develop once, run everywhere solution - but still as with the cross platform frameworks's promises for "write once, run everywhere, faster, better, easier", this isn't quite true - supporting different browsers, browsers on different OS, different screen sizes (desktop, mobile), etc. Otherwise if you need some cross platform keep native with embedded browser view.

08 July 2022

WebRTC Android application

Small Android application for video and audio communication with WebRTC with a WebView.

The repository at Github:

 https://github.com/ektodorov/WebRtcWebView

31 July 2019

Convert video files

If you have a home video security system - DVR, NVR, it is possible that it outputs files in a dav file format. Which is quite inconvenient, although most manufacturers of such systems would supply a video player either on disk with the equipment or you would have to fish for it in their website. Oh and one big "but", but this player is for Windows only. The same goes if you look online there are one or two players only for Windows.
What else can you do.
FFmpeg ofcourse.
One simple command:

ffmpeg -y -i movie.dav movie.mp4 

will turn your dav file into mp4 file, which you can play on any player.
But what if you don't want to know what is ffmpeg, don't want to download and install it, don't want to learn how to use it ?

There is an app for it :D

Yes there are applications for Android which use ffmpeg and provide you a convenient interface for it - well some not so convenient because they would just expect you to provide them with the command you want ffmpeg to run, but others will have a GUI which will let you select your options and they will do the rest.
So in the Google Play Store search for ffmpeg and try some of the applications that will come up as a result.

Here is an application that does only that and some more because it will convert any video format to mp4 not only dav:

 


01 May 2018

Native vs Progressive Web Application (PWA)

I recently watched a video comparing Native vs Progressive Web applications. It was about how a PWA can look and behave as much as possible as a Native app. There was a part something like - look here the browser address bar isn’t even visible and look we can add a shortcut to this page on the Home screen. Great so we are deceiving the user and it is not clear he is in the browser by hiding the address bar. So we are fragmenting the places we can have bookmarks to pages in the browser and on the Home screen - yes it is convenient to have an option in the browser to be able to place a bookmark to a page on the Home screen, but it is an option and the user should make a concise decision if it is something that he uses that much that he needs it on the Home screen, not some norm for all web applications. My point is if it is no obscure that we are using a web application that is running in the browser, the next things is users searching for an update at the App Store for this application, because they have forgotten that it is a site they are visiting with the web browser. And yes a big one is - if it is a web application it is write once run everywhere. Well yes, if you have written it with support for every browser that is. Users can run any number of browsers on their devices and if it is going to be “run everywhere”, then you need to build support for all the browsers. At least if it is native application with web content
it has to support only the Native WebView components for the systems. There is nothing bad about having a web application instead of Native application, there are pros and cons, but be proud of the good things about having a web application and be proud it is running in the web browser.

23 April 2018

Android Socket connections

Here we have an Android application that can act as a socket client, server or both for Peer-to-Peer connectivity. It is a kind of continuation to a previous blog post: https://techzealous.blogspot.bg/2018/04/peer-to-peer-connection-with-java-p2p_18.html
It can provide you with a convenient way to test connectivity between peers in a network without the need to create your own project if you only need a quick working example.
At the bottom part of the application we get a message log of what the application is doing or any exceptions that we get if the desired address and port combination is not available for use (it is already in use. After we close an address it is not made available by the OS for some time, so this has to be kept in mind as well).

GitHub repository of the application:
https://github.com/ektodorov/P2P_Sockets_Android

  (P2P Sockets Android application)

18 April 2018

Peer-to-Peer connection with Java (p2p)

Let us start with a bit of information on sockets.
In the case that we want to use the same port to connect and to accept incoming connections, we have to first start connecting to the remote host and then to start accepting incoming connections, because we can't bind to a Socket if it is already listening for connections, which is the case when we start accepting, and after that we won't be able to bind to the same port when we try to connect. Although on some systems it would be possible, it all depends on the sockets implementation in the OS.
As we can read in the Socket man page - http://www.skrenta.com/rt/man/socket.4.html :
"
SO_REUSEADDR
              Indicates   that   the  rules  used  in  validating
              addresses supplied in a bind(2) call  should  allow
              reuse  of local addresses. For PF_INET sockets this
              means that a socket may bind, except when there  is
              an  active  listening  socket bound to the address.
              When the listening socket is  bound  to  INADDR_ANY
              with  a  specific  port  then it is not possible to
              bind to this port for any local address.
"
More on this topic:

https://stackoverflow.com/questions/14388706/socket-options-so-
reuseaddr-and-so-reuseport-how-do-they-differ-do-they-mean-t/14388707#14388707

Now for the connections.

Connect:
We need to bind only using a port. When connecting the local address is usually "address any", that is why we only supply a port number. We are connecting to the public IP of the other machine (IP that is visible from the Internet) and we supply the IP address and the port number.

Socket socket = new Socket();
socket.setReuseAddress(true);
InetSocketAddress inetSocketAddress = new InetSocketAddress(44445);
socket.bind(inetSocketAddress);
InetSocketAddress socketAddress = new InetSocketAddress("11.222.333.555", 44446);
socket.connect(socketAddress, 30000);

Accept:
When accepting a connection we need to bind to the local IP address. If for some reason we don't get the actual local IP addres from getLocalHost (the OS may not allow us to have access to it and instead we either get the "address any" 0.0.0.0 or the loopback 127.0.0.1) we have to supply it ourselves:
InetAddress localAddress = InetAddress.getByName("192.168.100.10");

ServerSocket serverSocket = new ServerSocket();
serverSocket.setReuseAddress(true);
InetAddress localAddress = InetAddress.getLocalHost();
InetSocketAddress socketAddress = new InetSocketAddress(localAddress, 44446);
serverSocket.bind(socketAddress);
Socket socket = serverSocket.accept();

If the clients are in the same LAN network or neither of them are behind a Firewall or a NAT, we can have one of them only accept incoming connection and the other one only connect and they will establish a connection. But if one or both of them are behind a Firewall / NAT we would have both of them connect and accept so that they punch holes in their Firewall / NAT so that the incoming connection can go through.
We have to remember that Peer-to-Peer connection is not guaranteed to succeed, because the hole punching may not be possible depending on the network setup that our hosts are in, either by accident or the network may have been setup by intention to prevent such connections on purpose. In that case we can have a relayed Peer-to-Peer communication between the two hosts - both connect to a server on the Internet and it relays the data between them. More on Peer-to-Peer communications over the Internet - http://www.brynosaurus.com/pub/net/p2pnat/

Connect and Accept part as Java methods and how to call them:

accepting("111.222.333.444", 44446);
connecting(44445, "111.222.333.555", 44446);
Of course each of these methods has to be called on a separate thread.


1:  public void accepting(String aHostLocal, int aPortLocal) {  
2:          System.out.println("accepting");  
3:          ServerSocket serverSocket = null;  
4:          OutputStream outputStream = null;  
5:          BufferedReader bufferedReader = null;  
6:          try {  
7:              serverSocket = new ServerSocket();  
8:              serverSocket.setReuseAddress(true);  
9:          
10:        System.out.println("accepting, bind to=" + aHostLocal);  
11:        InetSocketAddress socketAddress = new InetSocketAddress(aHostLocal, aPortLocal);  
12:        serverSocket.bind(socketAddress);  
13:          
14:        System.out.println("accepting, accept");  
15:        Socket socket = serverSocket.accept();  
16:          
17:        bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));  
18:        int character = bufferedReader.read();  
19:        System.out.println("accepting, read character=" + character);  
20:        outputStream = socket.getOutputStream();  
21:        outputStream.write(character);  
22:        outputStream.flush();  
23:      } catch (IOException e) {  
24:        e.printStackTrace();  
25:      } finally {  
26:          if(bufferedReader != null) {  
27:              try {  
28:                      bufferedReader.close();  
29:                  } catch (IOException e) {  
30:                      e.printStackTrace();  
31:                  }  
32:          }  
33:          if(outputStream != null) {  
34:              try {  
35:                      outputStream.close();  
36:                  } catch (IOException e) {  
37:                      e.printStackTrace();  
38:                  }  
39:          }  
40:          if(serverSocket != null) {  
41:              try {  
42:                      serverSocket.close();  
43:                  } catch (IOException e) {  
44:                      e.printStackTrace();  
45:                  }  
46:          }  
47:      }  
48:          System.out.println("accepting, end");  
49:      }  
50:        
51:      public void connecting(int aPortLocal, String aHostRemote, int aPortRemote) {  
52:          System.out.println("connecting");  
53:          Socket socket = null;  
54:          OutputStream outputStream = null;  
55:          BufferedReader bufferedReader = null;  
56:          try {              
57:              socket = new Socket();  
58:              socket.setReuseAddress(true);  
59:          
60:              if(aPortLocal > 0) {  
61:                  InetSocketAddress inetSocketAddress = new InetSocketAddress(aPortLocal);  
62:                  System.out.println("connecting, bind to=" + inetSocketAddress);  
63:                  socket.bind(inetSocketAddress);  
64:              }  
65:          
66:              System.out.println("connecting, mHostRemote=" + aHostRemote);  
67:              InetSocketAddress socketAddress = new InetSocketAddress(aHostRemote, aPortRemote);   
68:        System.out.println("connecting, connect");  
69:        socket.connect(socketAddress, 30000);  
70:          
71:        System.out.println("connecting, sending 10");  
72:        outputStream = socket.getOutputStream();  
73:        outputStream.write(10);  
74:        bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));  
75:        int character = bufferedReader.read();  
76:        System.out.println("connecting received character=" + character);  
77:        outputStream.flush();  
78:      } catch (IOException e) {  
79:        e.printStackTrace();  
80:      } finally {  
81:          if(bufferedReader != null) {  
82:              try {  
83:                      bufferedReader.close();  
84:                  } catch (IOException e) {  
85:                      e.printStackTrace();  
86:                  }  
87:          }  
88:          if(outputStream != null) {  
89:              try {  
90:                      outputStream.close();  
91:                  } catch (IOException e) {  
92:                      e.printStackTrace();  
93:                  }  
94:          }  
95:          if(socket != null) {  
96:              try {  
97:                      socket.close();  
98:                  } catch (IOException e) {  
99:                      e.printStackTrace();  
100:                  }  
101:          }  
102:      }  
103:          System.out.println("connecting, end");  
104:      }  

31 March 2018

Sentinel image capture software

I have updated the Sentinel project. It now has a Desktop application as well. You can checkout the project at GitHub:


Now you can directly download an application without the need to build the project yourself. There is a Downloads directory that has an Android application and a Desktop application for Windows, Mac OS and Linux.
As you can read in the readme of the project repository, for the Eclipse project we are not using Maven, because one of the libraries has issues resolving from Maven and instead of having some of them with Maven and that one not, we decided to go for manual dependency resolution for all of them.

(Sentinel for desktop)

The images or videos will be recorded in the current working directory of the application.