bitQuit_Android/app/src/main/java/com/tonydicola/bletest/app/MainActivity.java
@Override
    protected void onStop() {
        super.onStop();

        // Save state of bitQuit -- saved in sharedPreferences
        SharedPreferences data = getSharedPreferences("bitQuit_state", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = data.edit();
        editor.putInt("Count", numCigs);
        editor.apply();
        editor.putInt("thisMonth", thisMonth);
        editor.apply();

        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        Action viewAction = Action.newAction(
                Action.TYPE_VIEW, // TODO: choose an action type.
                "Main Page", // TODO: Define a title for the content shown.
                // TODO: If you have web page content that matches this app activity's content,
                // make sure this auto-generated web page URL is correct.
                // Otherwise, set the URL to null.
                Uri.parse("http://host/path"),
                // TODO: Make sure this auto-generated app deep link URI is correct.
                Uri.parse("android-app://com.tonydicola.bletest.app/http/host/path")
        );
        AppIndex.AppIndexApi.end(client, viewAction);
        if (gatt != null) {
            // For better reliability be careful to disconnect and close the connection.
            gatt.disconnect();
            gatt.close();
            gatt = null;
            tx = null;
            rx = null;
        }
        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        client.disconnect();
    }
// OnStop, called right before the activity loses foreground focus.  Close the BTLE connection.
OnStop, called right before the activity loses foreground focus.  Close the BTLE connection.
OnStop called right before the activity loses foreground focus . Close the BTLE connection .
@Override
    protected void onStop() {
        super.onStop();
        SharedPreferences data = getSharedPreferences("bitQuit_state", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = data.edit();
        editor.putInt("Count", numCigs);
        editor.apply();
        editor.putInt("thisMonth", thisMonth);
        editor.apply();
        Action viewAction = Action.newAction(
                Action.TYPE_VIEW, 
                "Main Page", 
                Uri.parse("http://host/path"),
                Uri.parse("android-app://com.tonydicola.bletest.app/http/host/path")
        );
        AppIndex.AppIndexApi.end(client, viewAction);
        if (gatt != null) {
            gatt.disconnect();
            gatt.close();
            gatt = null;
            tx = null;
            rx = null;
        }
        client.disconnect();
    }
@ Override protected void onStop ( ) { super . onStop ( ) ; SharedPreferences data = getSharedPreferences ( "bitQuit_state" , Context . MODE_PRIVATE ) ; SharedPreferences . Editor editor = data . edit ( ) ; editor . putInt ( "Count" , numCigs ) ; editor . apply ( ) ; editor . putInt ( "thisMonth" , thisMonth ) ; editor . apply ( ) ; Action viewAction = Action . newAction ( Action . TYPE_VIEW , "Main Page" , Uri . parse ( "http://host/path" ) , Uri . parse ( "android-app://com.tonydicola.bletest.app/http/host/path" ) ) ; AppIndex . AppIndexApi . end ( client , viewAction ) ; if ( gatt != null ) { gatt . disconnect ( ) ; gatt . close ( ) ; gatt = null ; tx = null ; rx = null ; } client . disconnect ( ) ; }
OnStop, called right before the activity loses foreground focus.
OnStop called right before the activity loses foreground focus .
// Save state of bitQuit -- saved in sharedPreferences // ATTENTION: This was auto-generated to implement the App Indexing API. // See https://g.co/AppIndexing/AndroidStudio for more information. // TODO: choose an action type. // TODO: Define a title for the content shown. // TODO: If you have web page content that matches this app activity's content, // make sure this auto-generated web page URL is correct. // Otherwise, set the URL to null. // TODO: Make sure this auto-generated app deep link URI is correct. // For better reliability be careful to disconnect and close the connection. // ATTENTION: This was auto-generated to implement the App Indexing API. // See https://g.co/AppIndexing/AndroidStudio for more information.