Permalink
Browse files

example

  • Loading branch information...
1 parent 74cf78e commit c6be975384571d6a14f890ac91aa3d23da7b1999 Jon Vlachoyiannis committed Mar 17, 2011
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.nullwire.trace.example"
+ package="com.sfalma.trace.example"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name"
@@ -16,4 +16,4 @@
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk android:minSdkVersion="3" />
-</manifest>
+</manifest>
View
@@ -0,0 +1,17 @@
+# This file is used to override default values used by the Ant build system.
+#
+# This file must be checked in Version Control Systems, as it is
+# integral to the build system of your project.
+
+# This file is only used by the Ant script.
+
+# You can use this to override default values such as
+# 'source.dir' for the location of your java source folder and
+# 'out.dir' for the location of your output folder.
+
+# You can also use it define how the release builds are signed by declaring
+# the following properties:
+# 'key.store' for the location of your keystore and
+# 'key.alias' for the name of the key to use.
+# The password will be asked during the build when you use the 'release' target.
+
View
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="SfalmaExample" default="help">
+
+<!-- The local.properties file is created and updated by the 'android'
+ tool.
+ It contains the path to the SDK. It should *NOT* be checked into
+ Version Control Systems. -->
+ <property file="local.properties" />
+
+ <!-- The build.properties file can be created by you and is never touched
+ by the 'android' tool. This is the place to change some of the
+ default property values used by the Ant rules.
+ Here are some properties you may want to change/update:
+
+ source.dir
+ The name of the source directory. Default is 'src'.
+ out.dir
+ The name of the output directory. Default is 'bin'.
+
+ Properties related to the SDK location or the project target should
+ be updated using the 'android' tool with the 'update' action.
+
+ This file is an integral part of the build system for your
+ application and should be checked into Version Control Systems.
+
+ -->
+ <property file="build.properties" />
+
+ <!-- The default.properties file is created and updated by the 'android'
+ tool, as well as ADT.
+ This file is an integral part of the build system for your
+ application and should be checked into Version Control Systems. -->
+ <property file="default.properties" />
+
+ <!-- Custom Android task to deal with the project target, and import the
+ proper rules.
+ This requires ant 1.6.0 or above. -->
+ <path id="android.antlibs">
+ <pathelement path="${sdk.dir}/tools/lib/anttasks.jar" />
+ <pathelement path="${sdk.dir}/tools/lib/sdklib.jar" />
+ <pathelement path="${sdk.dir}/tools/lib/androidprefs.jar" />
+ </path>
+
+ <taskdef name="setup"
+ classname="com.android.ant.SetupTask"
+ classpathref="android.antlibs" />
+
+<!-- extension targets. Uncomment the ones where you want to do custom work
+ in between standard targets -->
+<!--
+ <target name="-pre-build">
+ </target>
+ <target name="-pre-compile">
+ </target>
+
+ [This is typically used for code obfuscation.
+ Compiled code location: ${out.classes.absolute.dir}
+ If this is not done in place, override ${out.dex.input.absolute.dir}]
+ <target name="-post-compile">
+ </target>
+-->
+
+
+ <!-- Execute the Android Setup task that will setup some properties
+ specific to the target, and import the build rules files.
+
+ The rules file is imported from
+ <SDK>/platforms/<target_platform>/ant/ant_rules_r#.xml
+
+ To customize existing targets, there are two options:
+ - Customize only one target:
+ - copy/paste the target into this file, *before* the
+ <setup> task.
+ - customize it to your needs.
+ - Customize the whole script.
+ - copy/paste the content of the rules files (minus the top node)
+ into this file, *after* the <setup> task
+ - disable the import of the rules by changing the setup task
+ below to <setup import="false" />.
+ - customize to your needs.
+ -->
+ <setup />
+
+</project>
@@ -10,4 +10,4 @@
# Indicates whether an apk should be generated for each density.
split.density=false
# Project target.
-target=android-3
+target=Google Inc.:Google APIs:8
View
@@ -0,0 +1 @@
+../../android-sdk/tools/adb install -r bin/SfalmaExample-debug.apk
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -1,4 +1,4 @@
-package com.nullwire.trace.example;
+package com.sfalma.trace.example;
import android.app.Activity;
import android.app.AlertDialog;
@@ -7,11 +7,12 @@
import android.view.View;
import android.view.View.OnClickListener;
-import com.nullwire.trace.ExceptionHandler;
+import com.sfalma.trace.SfalmaHandler;
public class MainActivity extends Activity {
private static final int DIALOG_SUBMITTING_EXCEPTIONS = 1;
+ private static final String SFALMA_KEY = "e402bf37b34ec5d42c955f1e85004d12";
private Dialog mExceptionSubmitDialog;
@@ -20,6 +21,8 @@ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
+ SfalmaHandler.setup(this, SFALMA_KEY);
+ /*
ExceptionHandler.setMinDelay(4000);
ExceptionHandler.setHttpTimeout(10000);
ExceptionHandler.setup(this, new ExceptionHandler.Processor() {
@@ -37,7 +40,7 @@ public void submitDone() {
@Override
public void handlerInstalled() {}
});
-
+ */
findViewById(R.id.crash_button).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
@@ -48,7 +51,7 @@ public void onClick(View v) {
@Override
protected void onDestroy() {
- ExceptionHandler.notifyContextGone();
+ //ExceptionHandler.notifyContextGone();
super.onDestroy();
}
@@ -39,6 +39,7 @@
import java.io.Writer;
import java.lang.Thread.UncaughtExceptionHandler;
import java.util.Random;
+import java.util.Date;
import android.util.Log;
@@ -67,6 +68,9 @@ public void uncaughtException(Thread t, Throwable e) {
Log.d(G.TAG, "Writing unhandled exception to: " + G.FILES_PATH+"/"+filename+".stacktrace");
// Write the stacktrace to disk
BufferedWriter bos = new BufferedWriter(new FileWriter(G.FILES_PATH+"/"+filename+".stacktrace"));
+
+ Date now = new Date();
+ bos.write(now + "\n");
bos.write(G.ANDROID_VERSION + "\n");
bos.write(G.PHONE_MODEL + "\n");
bos.write(result.toString());
@@ -38,8 +38,8 @@
public static String FILES_PATH = null;
public static String APP_VERSION = "unknown";
public static String APP_PACKAGE = "unknown";
- //public static String URL = "http://10.39.255.101:8080/api/send";
- public static String URL = "http://192.168.0.55:8080/api/errors";
+ public static String URL = "http://10.39.255.101:8080/test/android";
+ //public static String URL = "http://192.168.0.55:8080/api/errors";
public static String TAG = "SfalmaHandler";
public static String ANDROID_VERSION = null;
public static String PHONE_MODEL = null;
@@ -38,8 +38,8 @@ public class G {
public static String FILES_PATH = null;
public static String APP_VERSION = "unknown";
public static String APP_PACKAGE = "unknown";
- //public static String URL = "http://10.39.255.101:8080/api/send";
- public static String URL = "http://192.168.0.55:8080/api/errors";
+ public static String URL = "http://10.39.255.101:8080/test/android";
+ //public static String URL = "http://192.168.0.55:8080/api/errors";
public static String TAG = "SfalmaHandler";
public static String ANDROID_VERSION = null;
public static String PHONE_MODEL = null;
@@ -31,6 +31,8 @@
import java.io.IOException;
import java.security.*;
import java.math.*;
+import java.io.BufferedReader;
+import java.io.StringReader;
import org.apache.http.NameValuePair;
@@ -43,20 +45,21 @@
public static String createJSON(String app_package, String version, String phoneModel, String android_version, String stackTrace, boolean wifi_status, boolean mob_net_status, boolean gps_status) throws Exception {
JSONObject json = new JSONObject();
- JSONObject request_json = new JSONObject();
JSONObject exception_json = new JSONObject();
JSONObject application_json = new JSONObject();
JSONObject client_json = new JSONObject();
- request_json.put("remote_ip", "192.168.0.1");
- json.put("request", request_json);
+ // stackTrace contains many info we need to extract
+ BufferedReader reader = new BufferedReader(new StringReader(stackTrace));
- exception_json.put("occured_at", "today");
- exception_json.put("message", "java.lang.NullPointerException");
- exception_json.put("exception_class", "java.lang.NullPointerException");
+ exception_json.put("occured_at", reader.readLine()); // get date
+ exception_json.put("message", "java.lang.NullPointerException"); //get message
+ exception_json.put("exception_class", "java.lang.NullPointerException"); // get exception class
exception_json.put("backtrace", stackTrace);
json.put("exception", exception_json);
+ reader.close();
+
application_json.put("phone_model", phoneModel);
application_json.put("package_version", version);
application_json.put("package_name", app_package);
@@ -66,7 +69,7 @@ public static String createJSON(String app_package, String version, String phone
application_json.put("gps_on", gps_status);
json.put("application_environment", application_json);
- client_json.put("version", "sfalma-version-1");
+ client_json.put("version", "sfalma-version-0.6");
client_json.put("name", "sfalma-android");
json.put("client", client_json);
@@ -62,6 +62,7 @@
import android.location.LocationManager;
import android.location.LocationListener;
import android.location.Location;
+import android.Manifest.permission;
/**
* Usage:
@@ -517,6 +518,8 @@ private static void installHandler() {
private static boolean CheckNetworkConnection(String typeOfConnection, final Context context) {
boolean connected = false;
+ //if (android.Manifest.permission.ACCESS_NETWORK_STATE ==
+
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo[] netInfo = cm.getAllNetworkInfo();
for (NetworkInfo ni : netInfo) {

0 comments on commit c6be975

Please sign in to comment.