- Two of the most useful shortcuts utilize the Fn (function) keys. It is therefore recommended that you enable the "Use all F1, F2, etc. keys as standard function keys" option [System Preferences > Keyboard].
- Be sure to enable the Mac OS X 10.5+ keymap in Android Studio [Preferences > Keymap].
- A fairly complete shortcut list can be found here.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
_____ _____ _ | |
| __ \ / ____| | | | |
| | | | ___| | _ __ _ _ _ __ | |_ ___ _ __ | |
| | | |/ _ \ | | '__| | | | '_ \| __/ _ \| '__| | |
| |__| | __/ |____| | | |_| | |_) | || (_) | | | |
|_____/ \___|\_____|_| \__, | .__/ \__\___/|_| | |
__/ | | | |
|___/|_| | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Component | Action | |
---|---|---|
UI Controllers (Activity and Fragment) | Only UI related logic | |
ViewModel | Container for data required by UI | |
Repository | Single source of truth for data | |
Room | Local Database | |
Retrofit | Web Service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<TextView | |
android:id="@+id/text_user" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
tools:drawableLeft="@tools:sample/avatars" | |
tools:text="@tools:sample/full_names"/> | |
It would look much nicer if we could show the real item used in our RecyclerView, and even more so if that item uses sample texts tools:text=”@tools:sample/lorem” and tools:text=”@tools:sample/lorem/random” for TextViews inside | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You can overwrite the ${USER} variable in the template file with the | |
#set( $VARIABLE = "value") | |
function. Go to Settings -> File and Code Templates -> Includes -> File Header prepend the #set() function call, for example: | |
#set( $USER = "Your name" ) | |
/** | |
* Created by ${USER} on ${DATE}. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
READ: | |
FileInputStream in = openFileInput("filename.txt"); | |
InputStreamReader inputStreamReader = new InputStreamReader(in); | |
BufferedReader bufferedReader = new BufferedReader(inputStreamReader); | |
StringBuilder sb = new StringBuilder(); | |
String line; | |
while ((line = bufferedReader.readLine()) != null) { | |
sb.append(line); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In Android, if we want to pass the objects to activities then there is a need to implement the Serializable or Parcelable interface. | |
Serializable and Parcelable are two interfaces: | |
* Serializable is a standard java interface that implemented by “java.io.Serializable” | |
* Parcelable is an Android-specific interface that implemented by “android.os.Parcelable” | |
Serializable interface is easy to implement by overriding the methods but it is a slow process | |
and it creates a lot of temporary objects and causes quite a bit of garbage collection. | |
Parcelable interface takes more time to implement in comparison to Serializable because of the code size. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ANR (A pplication N ot R esponding )is due to handling long running task in Main Thread(UI thread).If the main thread is stopped for more than 5 sec you get ANR. | |
Crash are due to exception and error like Nullpoint,classNotfound, typecast ,parse error etc. ANR also causes crash of application. | |
ANR and Crash Examples: | |
ANR: | |
// this will produce an ANR on your app | |
int i = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit() writes the data synchronously (blocking the thread its called from). It then informs you about the success of the operation. | |
apply() schedules the data to be written asynchronously. It does not inform you about the success of the operation. | |
If you save with apply() and immediately read via any getX-method, the new value will be returned! | |
If you called apply() at some point and it's still executing, any calls to commit() will block until all apply-calls and its own commit are finished. | |
commit() writes its data to persistent storage immediately, whereas apply() will handle it in the background. |
NewerOlder