Skip to content

Commit

Permalink
Merge branch 'anr-detection-example-app' into android-anr-detection
Browse files Browse the repository at this point in the history
  • Loading branch information
fractalwrench committed Mar 13, 2019
2 parents 202ed85 + 36b9bc5 commit 78e1ee2
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

Expand Down Expand Up @@ -54,6 +55,17 @@ public void onClick(View view) {
doCrash();
}
});

findViewById(R.id.btn_anr).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
Thread.sleep(10000);
} catch (InterruptedException ignored) {
Log.d("Bugsnag", "Interrupted");
}
}
});
}

private void performAdditionalBugsnagSetup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class ExampleActivity : AppCompatActivity() {

val nativeBtn: View = findViewById(R.id.btn_native_crash)
nativeBtn.setOnClickListener { doCrash() }

findViewById<View>(R.id.btn_anr).setOnClickListener { Thread.sleep(10000) }
}

private fun performAdditionalBugsnagSetup() {
Expand Down
7 changes: 7 additions & 0 deletions examples/sdk-app-example/src/main/res/layout/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@
android:layout_height="wrap_content"
android:text="@string/trigger_native_crash" />

<Button
android:id="@+id/btn_anr"
style="@style/ButtonTheme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/trigger_anr" />

<View style="@style/separator" />

<!-- Trigger handled exceptions -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<string name="trigger_fatal_crash">FR</string>
<string name="trigger_native_crash">FR</string>
<string name="trigger_native_notify">FR</string>
<string name="trigger_anr">FR</string>

<string name="handled_exceptions">FR</string>
<string name="trigger_nonfatal_crash">FR</string>
Expand Down
1 change: 1 addition & 0 deletions examples/sdk-app-example/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<string name="unhandled_exceptions">Unhandled Exceptions</string>
<string name="trigger_fatal_crash">Trigger a fatal crash</string>
<string name="trigger_native_crash">Trigger a native crash</string>
<string name="trigger_anr">Trigger an ANR</string>

<string name="handled_exceptions">Handled Exceptions</string>
<string name="trigger_nonfatal_crash">Trigger a non-fatal crash</string>
Expand Down

0 comments on commit 78e1ee2

Please sign in to comment.