<div dir="ltr">I am pleased to announce I have released an RTL2832U driver for android for the benefit of all of the developers working on SDR.<div><br></div><div>The app could be found here</div><div><br></div><div><a href="https://play.google.com/store/apps/details?id=marto.rtl_tcp_andro">https://play.google.com/store/apps/details?id=marto.rtl_tcp_andro</a></div>
<div style><br></div><div style>And the sources are released under GPL2+ here</div><div style><br></div><div style><a href="https://github.com/martinmarinov/rtl_tcp_andro-">https://github.com/martinmarinov/rtl_tcp_andro-</a><br>
</div><div style><br></div><div style>So how do you use it in case you want to develop your own Android application that uses rtl_tcp_andro?</div><div style><br></div><div style>It's quite simple, you need to add just one line of code to your existing Android app (assuming the user has the driver installed).</div>
<div style><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div style><i>startActivityForResult(new Intent(Intent.ACTION_VIEW).setData(Uri.parse("iqsrc://-a 127.0.0.1 -p 123", START_REQ_CODE);</i></div>
</blockquote><div style><br></div><div style>Where START_REQ_CODE is a random number you assign. This will start rtl_tcp_andro on the localhost at port 123. As you see the thing after iqsrc:// is just the command line arguments you pass to a regular rtl_tcp.</div>
<div style><br></div><div style>If you want to be more fancy and do error capture, you should override this method in your Android activity and perform error detection as so:</div><div style><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<div style><div style><i>@Override</i></div></div><div style><div style><i><span class="" style="white-space:pre">      </span>protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {</i></div>
</div><div style><div style><i><br></i></div></div><div style><div style><i><span class="" style="white-space:pre">         </span>runOnUiThread(new Runnable() {</i></div></div><div style><div style><i><br></i></div></div><div style>
<div style><i><span class="" style="white-space:pre">                     </span>@Override</i></div></div><div style><div style><i><span class="" style="white-space:pre">                    </span>public void run() {</i></div></div><div style><div style><i><span class="" style="white-space:pre">                          </span>if (requestCode == START_REQ_CODE) {</i></div>
</div><div style><div style><i><span class="" style="white-space:pre">                                        </span>if (resultCode == RESULT_OK) { // rtl_tcp_andro has been started successfully!}</i></div></div><div style><div style><i><span class="" style="white-space:pre">                                      </span>else {</i></div>
</div><div style><div style><i><br></i></div></div><div style><div style><i><span class="" style="white-space:pre">                                         </span>try {</i></div></div><div style><div style><i><span class="" style="white-space:pre">                                                        </span>switch (data.getIntExtra("marto.rtl_tcp_andro.RtlTcpExceptionId", -1)) {</i></div>
</div><div style><div style><i><span class="" style="white-space:pre">                                                        </span>case 0:</i></div></div><div style><div style><i><span class="" style="white-space:pre">                                                              </span>// exception - permission denied</i></div>
</div><div style><div style><i><span class="" style="white-space:pre">                                                                </span>break;</i></div></div><div style><div style><i><span class="" style="white-space:pre">                                                       </span>case 1:</i></div></div><div style><div style>
<i><span class="" style="white-space:pre">                                                              </span>// exception - root required</i></div></div><div style><div style><i><span class="" style="white-space:pre">                                                         </span>break;</i></div></div><div style><div style>
<i><span class="" style="white-space:pre">                                                      </span>case 2:</i></div></div><div style><div style><i><span class="" style="white-space:pre">                                                              </span>// exception - no devices found</i></div></div><div style><div style>
<i><span class="" style="white-space:pre">                                                              </span>break;</i></div></div><div style><div style><i><span class="" style="white-space:pre">                                                       </span>case 4:</i></div></div><div style><div style><i><span class="" style="white-space:pre">                                                              </span>// exception - the user needs to reconnect the device</i></div>
</div><div style><div style><i><span class="" style="white-space:pre">                                                                </span>break;</i></div></div><div style><div style><i><span class="" style="white-space:pre">                                                       </span>default:</i></div></div><div style><div style>
<i><span class="" style="white-space:pre">                                                              </span>// unknown exception</i></div></div><div style><div style><i><span class="" style="white-space:pre">                                                         </span>break;</i></div></div><div style><div style><i><span class="" style="white-space:pre">                                                       </span>}</i></div>
</div><div style><div style><i><span class="" style="white-space:pre">                                                </span>} catch (Exception e) {}</i></div></div><div style><div style><i><span class="" style="white-space:pre">                                     </span>}</i></div></div><div style>
<div style><i><span class="" style="white-space:pre">                             </span>}</i></div></div><div style><div style><i><span class="" style="white-space:pre">                    </span>}</i></div></div><div style><div style><i><span class="" style="white-space:pre">            </span>});</i></div>
</div><div style><div style><i><span class="" style="white-space:pre">        </span>}</i></div></div></blockquote><div style><br></div><div style>It is that simple! rtl_tcp_andro will take care of showing different dialogs to the user for device selection. It will also take care of non-rooted devices by communicating with rtl_tcp_androi and sending the appropriate file descriptors, etc. You don't need to worry about all of the magic that is happening in the background - you only need to monitor the result of your intent request.</div>
<div style><br></div><div style>If you get <i>RESULT_OK</i> then you are ready to go. Now what remains is to implement your own TCP client that connects to the appropriate host/port number and communicates using the <i>rtl_tcp</i> protocol. Make sure you send the additional "exit" command that rtl_tcp_andro has in order not to leave zombie services behind.</div>
<div style><br></div><div style>That's all if you have any questions, feel free to contact me! Sorry for the bad state of the source code of rtl_tcp_andro, I will add comments as time passes by.</div><div style><br></div>
<div style>Hope to see great new projects on the Android platform :)</div><div style><br></div><div style>Thanks,</div><div style>Martin</div></div>