Java Code Examples for android.widget.Toast.cancel()

The following are Jave code examples for showing how to use cancel() of the android.widget.Toast class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: AIMSICDL   File: MainActivity.java   View Source Code Vote up 6 votes
/**
 * Exit application if Back button is pressed twice
 */
@Override
public void onBackPressed() {
    Toast onBackPressedToast = Toast
            .makeText(this, R.string.press_once_again_to_exit, Toast.LENGTH_SHORT);
    long currentTime = System.currentTimeMillis();
    if (currentTime - mLastPress > 5000) {
        onBackPressedToast.show();
        mLastPress = currentTime;
    } else {
        onBackPressedToast.cancel();
        super.onBackPressed();
        try {
            if (mAimsicdService.isSmsTracking()) {
                mAimsicdService.stopSmsTracking();
            }
        } catch (Exception ee) {
           Log.e(TAG, mTAG + "Error: Stopping SMS detection : " + ee.getMessage());
        }
        // Close database on Exit
        Log.i(TAG, mTAG + "Closing db from onBackPressed()");
        new AIMSICDDbAdapter(getApplicationContext()).close();
        finish();
    }
}