Example usage for java.lang Thread setDefaultUncaughtExceptionHandler

List of usage examples for java.lang Thread setDefaultUncaughtExceptionHandler

Introduction

In this page you can find the example usage for java.lang Thread setDefaultUncaughtExceptionHandler.

Prototype

public static void setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler eh) 

Source Link

Document

Set the default handler invoked when a thread abruptly terminates due to an uncaught exception, and no other handler has been defined for that thread.

Usage

From source file:com.illusionaryone.GameWispAPI.java

private GameWispAPI() {
    Thread.setDefaultUncaughtExceptionHandler(com.gmt2001.UncaughtExceptionHandler.instance());
}

From source file:com.gloriouseggroll.DonationHandlerAPI.java

private DonationHandlerAPI() {
    Thread.setDefaultUncaughtExceptionHandler(com.gmt2001.UncaughtExceptionHandler.instance());
}

From source file:com.scaniatv.ChallongeAPI.java

/**
 * @function ChallongAPI/*ww w .j  ava 2 s  . c o m*/
 *
 * @param {string} oauth
 * @param {string} tournamentId
 */
private ChallongeAPI(String oAuth) {
    Thread.setDefaultUncaughtExceptionHandler(com.gmt2001.UncaughtExceptionHandler.instance());

    this.oAuth = oAuth;
}

From source file:org.apache.giraph.graph.GraphMapper.java

@Override
public void setup(Context context) throws IOException, InterruptedException {
    // Execute all Giraph-related role(s) assigned to this compute node.
    // Roles can include "master," "worker," "zookeeper," or . . . ?
    graphTaskManager = new GraphTaskManager<I, V, E>(context);
    graphTaskManager.setup(DistributedCache.getLocalCacheArchives(context.getConfiguration()));

    // Setting the default handler for uncaught exceptions.
    Thread.setDefaultUncaughtExceptionHandler(graphTaskManager.createUncaughtExceptionHandler());
}

From source file:com.simadanesh.isatis.LoginActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState); //To change body of generated methods, choose Tools | Templates.
    try {/*from   ww w .ja  va2s.c om*/
        CommonPlace.loginActivity = this;
        Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
            @Override
            public void uncaughtException(Thread paramThread, Throwable paramThrowable) {
                Log.e("Alert", "Lets See if it Works !!!" + paramThrowable.toString());
            }
        });

        setContentView(R.layout.activity_login);
        Utility.InitializeDefatultSettings(this);

        edUserName = (EditText) findViewById(R.id.edUserName);
        edPassword = (EditText) findViewById(R.id.edPassword);
        btnLogin = (Button) findViewById(R.id.btnLogin);
        btnCancel = (Button) findViewById(R.id.btnCancel);

        btnLogin.setOnClickListener(this);
        btnCancel.setOnClickListener(this);

        edUserName.setTypeface(Utility.getDefaultFont());
        edPassword.setTypeface(Utility.getDefaultFont());
        btnLogin.setTypeface(Utility.getDefaultFont());
        btnCancel.setTypeface(Utility.getDefaultFont());
        edPassword.setImeActionLabel("Login", KeyEvent.KEYCODE_ENTER);
        // edPassword.setImeActionLabel("Login", KeyEvent.IME_ACTION_DONE);
        edPassword.setOnEditorActionListener(new TextView.OnEditorActionListener() {

            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == KeyEvent.KEYCODE_ENTER) {
                    Login();
                }
                return true;
            }
        });

    } catch (Exception ex) {
        Toast.makeText(this, ex.toString(), Toast.LENGTH_LONG).show();
    }

}

From source file:com.moto.miletus.application.tabs.CommandsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_commands);

    if (!(Thread.getDefaultUncaughtExceptionHandler() instanceof CustomExceptionHandler)) {
        Thread.setDefaultUncaughtExceptionHandler(new CustomExceptionHandler(this));
    }/*from   ww  w  .jav  a2s  .  co  m*/

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);

    final Bundle state = savedInstanceState != null ? savedInstanceState : getIntent().getExtras();
    mComponent = state.getParcelable(Strings.EXTRA_KEY_DEVICE_COMPONENT);
    mDevice = state.getParcelable(Strings.EXTRA_KEY_DEVICE);
    if (mDevice == null || mComponent == null) {
        throw new IllegalArgumentException("Error in intent extra");
    }

    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowHomeEnabled(true);
        actionBar.setTitle(StringUtils.capitalize(
                mDevice.getDevice().getName().replace(com.moto.miletus.utils.Strings.mSearchName, "")));
        actionBar.setSubtitle(StringUtils.capitalize(getComponent().getTraitName().replace("_", "")));
    }
}

From source file:com.illusionaryone.GameWispAPIv1.java

private GameWispAPIv1() {
    Thread.setDefaultUncaughtExceptionHandler(com.gmt2001.UncaughtExceptionHandler.instance());
}

From source file:me.mast3rplan.phantombot.cache.ChannelHostCache.java

@SuppressWarnings("CallToThreadStartDuringObjectConstruction")
private ChannelHostCache(String channel) {
    if (channel.startsWith("#")) {
        channel = channel.substring(1);//from   w w w .j  av a 2 s.c  o  m
    }

    this.channel = channel;
    this.updateThread = new Thread(this);

    Thread.setDefaultUncaughtExceptionHandler(com.gmt2001.UncaughtExceptionHandler.instance());
    this.updateThread.setUncaughtExceptionHandler(com.gmt2001.UncaughtExceptionHandler.instance());

    updateThread.start();
}

From source file:com.nkahoang.screenstandby.AutoSettingWizard.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_auto_setting_wizard);

    Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this));
    final TextView txtTitle = ((TextView) this.findViewById(R.id.txtTitle));
    txtTitle.setTypeface(typefaceLight);

    mButtonNext = (Button) this.findViewById(R.id.btnNext);
    mButtonBack = (Button) this.findViewById(R.id.btnBack);

    mPager = (ViewPager) findViewById(R.id.mainpager);
    mPagerAdapter = new SettingsPagerAdapter(this.getSupportFragmentManager());
    mPager.setOnPageChangeListener(new OnPageChangeListener() {
        @Override//from ww w. ja va 2s.co m
        public void onPageScrollStateChanged(int arg0) {
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
        }

        @Override
        public void onPageSelected(int arg0) {
            checkPage(arg0);
        }
    });
    mPager.setAdapter(mPagerAdapter);

    mButtonBack.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            if (mPager.getCurrentItem() == 0) {
                finishWizard();
            } else
                mPager.setCurrentItem(mPager.getCurrentItem() - 1, true);
            checkPage(mPager.getCurrentItem());
        }
    });

    mButtonNext.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            if (mPager.getCurrentItem() == (NUM_PAGES - 1)) {
                SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(AutoSettingWizard.this);
                prefs.edit().putBoolean("usemetro", mPagerAdapter.step3.chkBox.isChecked()).commit();

                ConfEntry dev = DeviceSettings.GetDevicesList()
                        .get(mPagerAdapter.step1.spDevices.getSelectedItemPosition());
                ConfEntry uc = DeviceSettings.GetUsecaseList()
                        .get(mPagerAdapter.step1.spUsecases.getSelectedItemPosition());
                DeviceSettings.ApplySettings(AutoSettingWizard.this, new ConfEntry[] { dev, uc },
                        mPagerAdapter.step1.resetDefault);
                finishWizard();
            } else
                mPager.setCurrentItem(mPager.getCurrentItem() + 1, true);
            checkPage(mPager.getCurrentItem());
        }
    });
}

From source file:com.hybris.mobile.logging.ExceptionHandler.java

public static boolean register(Context context) {
    LoggingUtils.i(LOG_TAG, "Registering default exceptions handler");
    // Get information about the Package
    PackageManager pm = context.getPackageManager();
    try {/*from w ww  .  jav  a  2s . c om*/
        PackageInfo pi;
        // Version
        pi = pm.getPackageInfo(context.getPackageName(), 0);
        RA.APP_VERSION = pi.versionName;
        // Package name
        RA.APP_PACKAGE = pi.packageName;
        // Files dir for storing the stack traces
        RA.FILES_PATH = context.getFilesDir().getAbsolutePath();
        // Device model
        RA.PHONE_MODEL = android.os.Build.MODEL;
        // Android version
        RA.ANDROID_VERSION = android.os.Build.VERSION.RELEASE;
    } catch (NameNotFoundException e) {
        LoggingUtils.e(LOG_TAG,
                "No package found for \"" + context.getPackageName() + "\"" + e.getLocalizedMessage(), context);
    }

    LoggingUtils.i(LOG_TAG, "TRACE_VERSION: " + RA.TraceVersion);
    LoggingUtils.d(LOG_TAG, "APP_VERSION: " + RA.APP_VERSION);
    LoggingUtils.d(LOG_TAG, "APP_PACKAGE: " + RA.APP_PACKAGE);
    LoggingUtils.d(LOG_TAG, "FILES_PATH: " + RA.FILES_PATH);
    LoggingUtils.d(LOG_TAG, "URL: " + RA.URL);

    boolean stackTracesFound = false;
    // We'll return true if any stack traces were found
    if (searchForStackTraces().length > 0) {
        stackTracesFound = true;
    }

    new Thread() {
        @Override
        public void run() {
            // First of all transmit any stack traces that may be lying around
            submitStackTraces();
            UncaughtExceptionHandler currentHandler = Thread.getDefaultUncaughtExceptionHandler();
            if (currentHandler != null) {
                LoggingUtils.d(LOG_TAG, "current handler class=" + currentHandler.getClass().getName());
            }
            // don't register again if already registered
            if (!(currentHandler instanceof DefaultExceptionHandler)) {
                // Register default exceptions handler
                Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler(currentHandler));
            }
        }
    }.start();

    return stackTracesFound;
}