Turns out it was a stupid ommission. If you are having this problem, don't forget to add this to your AndroidManifest:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INTERNET"/>
C:\work> mvn archetype:generate -DarchetypeCatalog=http://kallisti.eoti.org:8081/content/repositories/snapshots/archetype-catalog.xml2: http://kallisti.eoti.org:8081/content/repositories/snapshots/archetype-catalog.xml -> galatea-archetype (null)
C:\work> cd ErrorTest
C:\work\ErrorTest> mvn clean install
try{
throw new IOException("This is an error");
} catch (IOException e) {
Log.e(TAG, "Standard Error Logging", e);
// Derived from http://thinkandroid.wordpress.com/2010/01/25/debugging-applications-by-emailing-error-reports/
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"malachid@gmail.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "[" + getClass().getSimpleName() + "] ERROR REPORT");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, sw.toString());
startActivity(Intent.createChooser(emailIntent, "Send error report..."));
}
F:\work> mvn archetype:generate -DarchetypeCatalog=http://kallisti.eoti.org:8081/content/repositories/snapshots/archetype-catalog.xml2: http://kallisti.eoti.org:8081/content/repositories/snapshots/archetype-catalog.xml -> galatea-archetype (null)
F:\work> cd PhoneIDTest
F:\work\PhoneIDTest> mvn clean install
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
private void showMessage(String msg)
{
Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
}
TelephonyManager mgr = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);Redeploy (mvn clean install) and run the app.
switch(mgr.getPhoneType())
{
case TelephonyManager.PHONE_TYPE_CDMA:
showMessage("CDMA");
break;
case TelephonyManager.PHONE_TYPE_GSM:
showMessage("GSM");
break;
case TelephonyManager.PHONE_TYPE_NONE:
showMessage("NONE");
break;
default:
showMessage("Unknown phone type");
}
showMessage("Device ID: " + mgr.getDeviceId());
showMessage("Version: " + mgr.getDeviceSoftwareVersion());
showMessage("Number: " + mgr.getLine1Number());
showMessage("Country: " + mgr.getNetworkOperatorName());
showMessage("Sim Serial#: " + mgr.getSimSerialNumber());
showMessage("Subscriber ID: " + mgr.getSubscriberId());
showMessage("Operator: " + mgr.getSimOperatorName());
F:\work> mvn archetype:generate -DarchetypeCatalog=http://kallisti.eoti.org:8081/content/repositories/snapshots/archetype-catalog.xml
F:\work> cd URLTest
F:\work\URLTest> mvn clean install
<uses-permission android:name="android.permission.INTERNET" />
public class URLTestActivity extends Activity {
private Handler handler;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
handler = new Handler(){
@Override
public void handleMessage(Message msg) {
Toast.makeText(URLTestActivity.this, "Time: " + msg.obj, Toast.LENGTH_SHORT).show();
}
};
Thread t = new Thread(){
@Override
public void run() {
try {
URL url = new URL("http://tycho.usno.navy.mil/cgi-bin/timer.pl");
URLConnection connection = url.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line = "";
String s = "";
while( (line = in.readLine()) != null )
{
int idx = line.indexOf("Pacific Time");
if( idx != -1)
{
s = line.substring(4, idx-1).trim(); // strip off "<BR>" and "Pacific Time"
}
}
Message msg = new Message();
msg.obj = s;
handler.sendMessage(msg);
} catch (Exception e) {
Toast.makeText(URLTestActivity.this, "ERROR: " + e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
};
t.start();
}
}