So, the crash is caused when trying to set the status of the app in the Action Bar. For some reason, the code (from BluetoothChat.java)<br><span class=""><br></span><div><i><span class="">final</span> ActionBar actionBar = getActionBar();</i><div>
<br></div><div>in both setStatus functions gets a value of null from getActionBar(). (I don't know how that function is supposed to work, but one would assume it would work on a 4.2 device)</div><div><br></div><div>Then the following line:</div>
<div><br></div><div><i>actionBar.setSubtitle(resId);</i><br></div><div><br></div><div>throws your null pointer exception, because the actionBar variable is null.</div><div><br></div><div>You could throw an if() in there and make sure the value isn't null, but I imagine there's a bigger issue. You can also just comment out those lines temporarily (that is, comment out both instances of  actionBar.setSubtitle ) to move past the issue for now.</div>
<div><br></div><div><br></div><div>The bigger question is: what phones do you want to support? The methods causing the crash have to do with the Action Bar, which is only present in android 4.0+ (or maybe that was 3.0+) devices. If you want to ensure compatibility with more phones, supporting android 2.2+ is recommended. In that case, you can probably just use the old bluetooth chat example from 2.2 and it should work fine. The new one may have some nicer features though (it kind of looks like it does), so alternatively you can comment out the offending lines and then put some conditional code around anything that requires a newer version of android (not sure why Google didn't do that...).<br>
</div><div><div><br></div><div>Anyway, to reiterate, you can get the example to run by commenting out the contents of the methods below. Eventually you'll want to figure out why it's crashing. And side note: I also had to set the minimum API level in the manifest to 11 to get it to stop complaining at me for having those ActionBar methods in the first place.</div>
<div><br></div><div>







<p class=""> <span class="">private</span> <span class="">final</span> <span class="">void</span> setStatus(<span class="">int</span> resId) {</p>
<p class="">        <span class="">final</span> ActionBar <span class="">actionBar</span> = getActionBar();</p>
<p class=""><span class="">       </span> actionBar.setSubtitle(resId);</p>
<p class="">    }</p>
<p class=""><br></p>
<p class="">    <span class="">private</span> <span class="">final</span> <span class="">void</span> setStatus(CharSequence subTitle) {</p>
<p class="">        <span class="">final</span> ActionBar <span class="">actionBar</span> = getActionBar();</p>
<p class=""><span class="">     </span>   actionBar.setSubtitle(subTitle);</p>
<p class="">    }</p></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Dec 19, 2012 at 8:10 PM, Taylor Alexander <span dir="ltr"><<a href="mailto:tlalexander@gmail.com" target="_blank">tlalexander@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">:)<div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Dec 19, 2012 at 8:07 PM, Anders Nelson <span dir="ltr"><<a href="mailto:anders.k.nelson@gmail.com" target="_blank">anders.k.nelson@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I want you to know that I <i>actually </i>jumped upward and did a little dance.</div><div class="gmail_extra">

<div><br clear="all"><div>--<br>Anders Nelson<br><br><a href="tel:%2B1%20%28517%29%20775-6129" value="+15177756129" target="_blank">+1 (517) 775-6129</a><br><br><a href="http://www.erogear.com" target="_blank">www.erogear.com</a></div>


<br>
<br><br></div><div><div><div class="gmail_quote">On Wed, Dec 19, 2012 at 8:05 PM, Taylor Alexander <span dir="ltr"><<a href="mailto:tlalexander@gmail.com" target="_blank">tlalexander@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
It crashes on my unit too. Debugging now.<div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Dec 19, 2012 at 7:56 PM, Anders Nelson <span dir="ltr"><<a href="mailto:anders.k.nelson@gmail.com" target="_blank">anders.k.nelson@gmail.com</a>></span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Attached is a screenshot of the system specs. Thanks sooo much for your help!<div><br></div><div>=]</div>



</div><div class="gmail_extra"><div><br clear="all"><div>--<br>Anders Nelson<br><br><a href="tel:%2B1%20%28517%29%20775-6129" value="+15177756129" target="_blank">+1 (517) 775-6129</a><br><br>
<a href="http://www.erogear.com" target="_blank">www.erogear.com</a></div><br>
<br><br></div><div><div><div class="gmail_quote">On Wed, Dec 19, 2012 at 7:53 PM, Taylor Alexander <span dir="ltr"><<a href="mailto:tlalexander@gmail.com" target="_blank">tlalexander@gmail.com</a>></span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Let me download the latest example code and try running it. I'm working from a copy of the bluetoothchat program from android 2.2 or so. They may have changed it recently and broken something.<div><br></div><div>Which, by the way, you might want to try - go grab an older version and try running it. I think that's easy enough to do. I forget off the top of my head. I'll report back in a few.</div>




<div><div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Dec 19, 2012 at 7:49 PM, Anders Nelson <span dir="ltr"><<a href="mailto:anders.k.nelson@gmail.com" target="_blank">anders.k.nelson@gmail.com</a>></span> wrote:<br>





<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hey Taylor,<div><br></div><div>Thanks for the response! There may be something awkward with the fact that my GNex is the international GSM version and it's not based on the yakju system image. I'm not sure what it is but the phone has not been particularly stable at times.</div>






<div><br></div><div>My symptoms are that the app seems to crash immediately upon creation of a thread (if I'm reading the debug messages correctly) and cites a null reference exception or something. I don't even get to the part where the program conects to another device, nor even draws the UI.</div>






<div><br></div><div>Am I doing something stupid?</div></div><div class="gmail_extra"><div><br clear="all"><div>--<br>Anders Nelson<br><br><a href="tel:%2B1%20%28517%29%20775-6129" value="+15177756129" target="_blank">+1 (517) 775-6129</a><br>





<br><a href="http://www.erogear.com" target="_blank">www.erogear.com</a></div>
<br>
<br><br></div><div><div><div class="gmail_quote">On Wed, Dec 19, 2012 at 7:45 PM, Taylor Alexander <span dir="ltr"><<a href="mailto:tlalexander@gmail.com" target="_blank">tlalexander@gmail.com</a>></span> wrote:<br>





<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Here is the fix for the RN-42:<div><br></div><div><div style="overflow:hidden;width:739px;color:rgb(119,119,110);font-family:Arial,'MS Sans Serif',Geneva,sans-serif;font-size:13px"><div><img src="https://dlnmh9ip6v2uc.cloudfront.net/images/framework/anon.png" style="border:none;float:left;margin-right:6px"><a href="http://www.sparkfun.com/users/65" style="text-decoration:initial;color:rgb(240,53,40)" target="_blank">Jonathon Cox</a> <span style="padding:0px 5px">|</span> <span title="Saturday, 20-Aug-11 12:19:40 MDT"><a href="https://www.sparkfun.com/products/10253#comment-4eaad857757b7fd35100af3e" style="text-decoration:initial;color:rgb(119,119,110)" target="_blank">about a year ago</a></span> <span><span title="Please login to up-vote comments" style="background-image:url(https://dlnmh9ip6v2uc.cloudfront.net/images/framework/comments.png);display:inline-block;min-height:20px;vertical-align:bottom;width:20px;background-repeat:no-repeat no-repeat"></span> </span><span><a data="http://fancybox" href="http://www.sparkfun.com/static/comment_help" style="text-decoration:initial;color:rgb(119,119,110)!important" target="_blank">1</a></span></div>







<div style="font-size:11px"></div></div><div style="padding-top:5px"><p style="color:rgb(119,119,110);font-family:Arial,'MS Sans Serif',Geneva,sans-serif;font-size:13px;padding-bottom:5px;margin:0px;clear:left;word-wrap:break-word">







You can also use the BluetoothChat example in the Android SDK to connect to the module. Just change the UUID like this:<br>private static final UUID MY_UUID = UUID.fromString(“00001101-0000-1000-8000-00805F9B34FB”);</p><br>







via <a href="https://www.sparkfun.com/products/10253" target="_blank">https://www.sparkfun.com/products/10253</a></div></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Dec 19, 2012 at 7:41 PM, Taylor Alexander <span dir="ltr"><<a href="mailto:tlalexander@gmail.com" target="_blank">tlalexander@gmail.com</a>></span> wrote:<br>







<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>It works on my galaxy nexus. (4.2, was 4.1 and 4.0, all worked)</div><div><br></div>I do know that this won't work with the popular RN-42 (and 41) bluetooth to serial modules unless you change one line of code. Are you using one of those? I can look up what the change is if need be. I also posted it on stackoverflow at one point.<div class="gmail_extra">








<br><br><div class="gmail_quote"><div><div>On Wed, Dec 19, 2012 at 7:38 PM, Anders Nelson <span dir="ltr"><<a href="mailto:anders.k.nelson@gmail.com" target="_blank">anders.k.nelson@gmail.com</a>></span> wrote:<br>







</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>
<div dir="ltr">Helloooooooo you wonderful people!<div><br></div><div>Does someone on this list have experience with getting the BluetoothChat Android SDK sample working? Can you help me get it to *not* crash upon launch?<br>









<div><br></div><div>I'm building a Bluetooth-based program on the Android platform and I've managed to give myself a bald spot trying to figure out why a certain Android SDK sample is immediately crashing when I open it on my Galaxy Nexus phone. It's really important that I get this to simply run, the rest I can do myself!</div>









<div><br></div><div>Here's why it's important - as some of you may know, I've spent the last year and six weeks completely redesigning my wearable LED display platform, and the beta articles are working beautifully as I feed them with video from my PC over Bluetooth. Buuuuut my main selling point is for mobile apps to feed these displays.</div>









<div><br></div><div>Android ships their SDK with a great sample program containing a class that does the Bluetooth state/connection management for you on multiple threads for snappiness (and happiness). It's called "BluetoothChat". The problem I'm having is that it hasn't the facility to use Bluetooth in the emulator, and it also crashes upon launch when I debug using my Galaxy Nexus running ICS 4.1.1. I've Googled my tail off and went through many a tutorial already.</div>









<div><br></div><div>Anyway, I live in SF but will travel. I will also pay/barter for your time.</div><div><br></div><div>Cool?</div><div><br></div><div><img src="cid:ii_13bb661e1c3a35d2" alt="Inline image 1"><br>
</div><div><br clear="all"><div>--<br>Anders Nelson<br><br><a href="tel:%2B1%20%28517%29%20775-6129" value="+15177756129" target="_blank">+1 (517) 775-6129</a><br><br><a href="http://www.erogear.com" target="_blank">www.erogear.com</a></div>








<br>
</div></div></div>
<br></div></div>_______________________________________________<br>
Noisebridge-discuss mailing list<br>
<a href="mailto:Noisebridge-discuss@lists.noisebridge.net" target="_blank">Noisebridge-discuss@lists.noisebridge.net</a><br>
<a href="https://www.noisebridge.net/mailman/listinfo/noisebridge-discuss" target="_blank">https://www.noisebridge.net/mailman/listinfo/noisebridge-discuss</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>