A list of articles or online answers that have directly contributed to certain portions of the app.
Creating a custom Application class to run methods on app start, such as authentication file checking.
Add a bottom-only line to a TabLayout background by drawing a shape and moving all other sides of the "rectangle" out of the drawing boundaries.
Several various Screen utility functions for determining current size, orientation, etc.
Enable accessing specific fragments in a TabLayout (since they are created programmatically) in order to execute their (public) functions.
In order to use findViewById()
from inside a Fragment, a reference to a View is needed (ie. the parent View). This View reference can be found (and stored) inside the constructor, and then used like parentView.findViewById()
.
Snackbars need a view (ie. a context or anchor) to attach to, but fragments will occasionally disappear. In these cases, or other cases where the Snackbar should attach to the "app" as a whole, use a provided id
.
View snackbarRoot = getActivity().findViewById(android.R.id.content);
The Soft Keyboard can be hidden by first checking for the currently focused view and then hiding the keyboard (using the InputMethodManager
class).
Viewing the app's private files is possible through the use of the Android shell (ADB). Navigate to the project directory and run adb shell
in a terminal. Inside the shell, type run-as ca.kendallroth.mileageapp
to set the shell permission, the list the directory files (ls files/
).
Passing data to a new Activity is as simple as properly using intent.putExtras()
when creating the Intent - passing data back from the same Activity is also quite simple. Rather than call startActivity
we call startActivityForResult()
which will call the class's overriden onActivityResult()
method when the Activity returns.
- Taken from : Stack Overflow - How to pass data from 2nd activity to 1st activity when pressed back android
The AsyncTask by default (when autogenerated) returns a Boolean
; however, a more complex data structure may be required in some cases. It is possible to change the AsyncTask expected result by changing the Generic parameter in ... extends AsynTask<String, Void, [DesiredType]>
.
The App Bar should typically be overridden to provide a custom Toolbar that captures the functionality of the Activity. The following link describes Android's recommended approach: