<p dir="ltr">Legend! Top man :)</p>
<p dir="ltr">Mike<br>
M0MIK<br>
</p>
<div class="gmail_quote">On 30 Jan 2013 12:50, "Мартин Маринов" <<a href="mailto:martintzvetomirov@gmail.com">martintzvetomirov@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<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" target="_blank">https://play.google.com/store/apps/details?id=marto.rtl_tcp_andro</a></div>

<div><br></div><div>And the sources are released under GPL2+ here</div><div><br></div><div><a href="https://github.com/martinmarinov/rtl_tcp_andro-" target="_blank">https://github.com/martinmarinov/rtl_tcp_andro-</a><br>

</div><div><br></div><div>So how do you use it in case you want to develop your own Android application that uses rtl_tcp_andro?</div><div><br></div><div>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><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><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><br></div><div>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><br></div><div>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><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">

<div><div><i>@Override</i></div></div><div><div><i><span style="white-space:pre-wrap">    </span>protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {</i></div>
</div><div><div><i><br></i></div></div><div><div><i><span style="white-space:pre-wrap">               </span>runOnUiThread(new Runnable() {</i></div></div><div><div><i><br></i></div></div><div>
<div><i><span style="white-space:pre-wrap">                 </span>@Override</i></div></div><div><div><i><span style="white-space:pre-wrap">                      </span>public void run() {</i></div></div><div><div><i><span style="white-space:pre-wrap">                            </span>if (requestCode == START_REQ_CODE) {</i></div>

</div><div><div><i><span style="white-space:pre-wrap">                                  </span>if (resultCode == RESULT_OK) { // rtl_tcp_andro has been started successfully!}</i></div></div><div><div><i><span style="white-space:pre-wrap">                                        </span>else {</i></div>

</div><div><div><i><br></i></div></div><div><div><i><span style="white-space:pre-wrap">                                               </span>try {</i></div></div><div><div><i><span style="white-space:pre-wrap">                                                  </span>switch (data.getIntExtra("marto.rtl_tcp_andro.RtlTcpExceptionId", -1)) {</i></div>

</div><div><div><i><span style="white-space:pre-wrap">                                                  </span>case 0:</i></div></div><div><div><i><span style="white-space:pre-wrap">                                                                </span>// exception - permission denied</i></div>
</div><div><div><i><span style="white-space:pre-wrap">                                                          </span>break;</i></div></div><div><div><i><span style="white-space:pre-wrap">                                                 </span>case 1:</i></div></div><div><div>
<i><span style="white-space:pre-wrap">                                                            </span>// exception - root required</i></div></div><div><div><i><span style="white-space:pre-wrap">                                                           </span>break;</i></div></div><div><div>
<i><span style="white-space:pre-wrap">                                                    </span>case 2:</i></div></div><div><div><i><span style="white-space:pre-wrap">                                                                </span>// exception - no devices found</i></div></div><div><div>
<i><span style="white-space:pre-wrap">                                                            </span>break;</i></div></div><div><div><i><span style="white-space:pre-wrap">                                                 </span>case 4:</i></div></div><div><div><i><span style="white-space:pre-wrap">                                                                </span>// exception - the user needs to reconnect the device</i></div>

</div><div><div><i><span style="white-space:pre-wrap">                                                          </span>break;</i></div></div><div><div><i><span style="white-space:pre-wrap">                                                 </span>default:</i></div></div><div><div>
<i><span style="white-space:pre-wrap">                                                            </span>// unknown exception</i></div></div><div><div><i><span style="white-space:pre-wrap">                                                           </span>break;</i></div></div><div><div><i><span style="white-space:pre-wrap">                                                 </span>}</i></div>

</div><div><div><i><span style="white-space:pre-wrap">                                          </span>} catch (Exception e) {}</i></div></div><div><div><i><span style="white-space:pre-wrap">                                       </span>}</i></div></div><div>
<div><i><span style="white-space:pre-wrap">                         </span>}</i></div></div><div><div><i><span style="white-space:pre-wrap">                      </span>}</i></div></div><div><div><i><span style="white-space:pre-wrap">              </span>});</i></div>
</div><div><div><i><span style="white-space:pre-wrap">  </span>}</i></div></div></blockquote><div><br></div><div>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><br></div><div>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><br></div><div>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><br></div>
<div>Hope to see great new projects on the Android platform :)</div><div><br></div><div>Thanks,</div><div>Martin</div></div>
</blockquote></div>