Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>public class ForceCloseExceptionHandalingActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); setContentView(MyLayout()); Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread paramThread, Throwable paramThrowable) { myHandaling(paramThread, paramThrowable); } }); } private ViewGroup MyLayout(){ LinearLayout mainLayout = new LinearLayout(this); mainLayout.setOrientation(LinearLayout.VERTICAL); Button btnHello =new Button(this); btnHello.setText("Show all button"); btnHello.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setContentView(MyLayout2()); } }); mainLayout.addView(btnHello); return mainLayout; } private ViewGroup MyLayout2(){ LinearLayout mainLayout = new LinearLayout(this); mainLayout.setOrientation(LinearLayout.VERTICAL); Button btnHello =new Button(this); btnHello.setText("I am a EEROR uncaughtException"); btnHello.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Log.e("Alert","btn uncaughtException::"); Toast.makeText(ForceCloseExceptionHandalingActivity.this, "Alert uncaughtException222",Toast.LENGTH_LONG).show(); View buttone = null; setContentView(buttone); } }); Button btnHello2 =new Button(this); btnHello2.setText("I am a EEROR Try n catch"); btnHello2.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { try{ View buttone = null; setContentView(buttone); } catch (Exception e) { Log.e("Alert","Try n catch:::"); Toast.makeText(ForceCloseExceptionHandalingActivity.this, "Alert Try n catch",Toast.LENGTH_LONG).show(); setContentView(MyLayout()); } } }); mainLayout.addView(btnHello); mainLayout.addView(btnHello2); return mainLayout; } public void myHandaling(Thread paramThread, Throwable paramThrowable){ Log.e("Alert","Lets See if it Works !!!" +"paramThread:::" +paramThread +"paramThrowable:::" +paramThrowable); Toast.makeText(ForceCloseExceptionHandalingActivity.this, "Alert uncaughtException111",Toast.LENGTH_LONG).show(); Intent in =new Intent(ForceCloseExceptionHandalingActivity.this,com.satya.ForceCloseExceptionHandaling.ForceCloseExceptionHandalingActivity.class); startActivity(in); finish(); android.os.Process.killProcess(android.os.Process.myPid()); } @Override protected void onDestroy() { Log.e("Alert","onDestroy:::"); Toast.makeText(ForceCloseExceptionHandalingActivity.this, "Alert onDestroy",Toast.LENGTH_LONG).show(); super.onDestroy(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload