File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed
firebase-sessions/test-app/src/main
kotlin/com/google/firebase/testing/sessions Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ class FirstFragment : Fragment() {
7171 }
7272 }
7373 binding.createTrace.setOnClickListener {
74- viewLifecycleOwner. lifecycleScope.launch(Dispatchers .IO ) {
74+ lifecycleScope.launch(Dispatchers .IO ) {
7575 val performanceTrace = performance.newTrace(" test_trace" )
7676 performanceTrace.start()
7777 delay(1000 )
Original file line number Diff line number Diff line change @@ -22,10 +22,13 @@ import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
2222import android.os.Build
2323import android.os.Bundle
2424import android.widget.Button
25+ import androidx.lifecycle.lifecycleScope
26+ import com.google.firebase.perf.FirebasePerformance
27+ import kotlinx.coroutines.delay
28+ import kotlinx.coroutines.launch
2529
2630/* * Second activity from the MainActivity that runs on a different process. */
2731class SecondActivity : BaseActivity () {
28-
2932 override fun onCreate (savedInstanceState : Bundle ? ) {
3033 super .onCreate(savedInstanceState)
3134 setContentView(R .layout.activity_second)
@@ -38,6 +41,15 @@ class SecondActivity : BaseActivity() {
3841 findViewById<Button >(R .id.second_crash_button).setOnClickListener {
3942 throw IllegalStateException (" SecondActivity has crashed" )
4043 }
44+ findViewById<Button >(R .id.second_create_trace).setOnClickListener {
45+ lifecycleScope.launch {
46+ val performanceTrace = FirebasePerformance .getInstance().newTrace(" test_trace" )
47+ performanceTrace.start()
48+ delay(1000 )
49+ performanceTrace.stop()
50+ }
51+
52+ }
4153 findViewById<Button >(R .id.kill_background_processes).setOnClickListener {
4254 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .M ) {
4355 getSystemService(ActivityManager ::class .java)
Original file line number Diff line number Diff line change 3838 app : layout_constraintTop_toBottomOf =" @id/prev_activity_button"
3939 app : layout_constraintLeft_toLeftOf =" parent" />
4040
41+ <Button
42+ android : id =" @+id/second_create_trace"
43+ android : layout_width =" wrap_content"
44+ android : layout_height =" wrap_content"
45+ android : text =" @string/create_trace"
46+ app : layout_constraintTop_toBottomOf =" @id/second_crash_button"
47+ app : layout_constraintLeft_toLeftOf =" parent" />
48+
4149 <Button
4250 android : id =" @+id/kill_background_processes"
4351 android : layout_width =" wrap_content"
You can’t perform that action at this time.
0 commit comments