How to disable Auto Save in Android Studio - android-studio

Is there way to disable auto save in Android Studio?
I have already unchecked "Save files automatically if application is idle for n sec"
under Setting->General.
Anything else to be done?

Disable Autosave
File > Settings > Appearance & Behavior > System Settings > Autosave > then uncheck both Save files if the IDE is idle for |15| seconds and Save files when switching to a different application > Apply
After doing the above, you may like to do enable the following 2 options too-
Mark Changed But Unsaved File
File > Settings > Editor > General > Editor Tabs > then check Mark modified (*) > Apply
Save One File with Ctrl+S
File > Settings > Keymap > search with save document > right click Save Document > Add Keyboard Shortcut > press Ctrl+S> OK > Remove > Apply

In android Studio 2.1.1, 2016
File -> Settings -> Appearance and Behavior -> System Settings
And see synchronization paragraph and uncheck autosave and/or 'use safe write'

If you go to Settings, and type Save in the search you will find under the IDE Settings an area called "General". From there you can find a number of options to control saving. It sometimes does not work and saving will continue anyway. Unfortunately there is no universal "turn-off" switch. AS is a hand holding IDE, you just have to get use to it.
Settings section you are seeking looks like this:

For Android Studio v3.3
Open Settings (Ctrl+Alt+S or File->Settings)
On the top left corner of the settings menu, search for "save" in the search bar field
Click on System Settings and all the sub-settings related to save will be highlighted
Uncheck Save files automatically if application is idle for * sec
Click on apply and close the settings menu.
It is highly recommended to follow this method
Mark Changed But Unsaved File which will help you distinguish between your unsaved and saved files.

Related

How to restore XML code style settings in Android Studio

File > Settings. After I change rules to languages (spaces, wrappings, imports, etc.) and restart Android Studio, they apply again. But if I change XML settings, they will be lost after restart. So every time after restart of AS I have to change these settings again. How can I make AS to save and restore XML settings?
In order to save XML settings do following.
Open Settings: Ctrl+Alt+S.
Find XML in Editor > Code Styles > XML, Android tab.
Select two checkboxes. Select scheme and press Copy to Project....
Now you can redefine a Project scheme. Also check two checkboxes. Now your scheme becomes Project with your settings, and after restart you will have this new scheme.

How to return item to context menu in Android Studio

In my Android Studio, when I have a cursor on the regular exprssion and if I click Alt + Enter I see a context menu like this
There was an item Check Regexp or something like this but I click accidentaly Disable... and it disappeared. Tell me please where can I find it in android studio to make it return back.
Those menu items are called Intention Actions.
To configure intention settings using the Settings/Preferences dialog
Open the Settings / Preferences Dialog by pressing Ctrl+Alt+S or by choosing File | Settings for Windows and Linux or IntelliJ IDEA | Preferences for macOS, and click Intentions under Editor.
In the Intentions page, clear the checkboxes of the intention actions or action c1ategories that you do not currently need.
Selecting or clearing a category affects all intention actions in this category.
Apply changes and close the dialog.
Check for details here

How do I open two or more projects at the same time in Android Studio?

In Android Studio, I want to open another project, so I click File -> Open, but the original project has been closed.
What should I do to open the two projects at the same time?
To open multiple projects simultaneously in Android Studio,
go to Settings > Appearance & Behavior > System Settings,
in the Project Opening section,
choose Open project in new window.
Umh,I have solved my question.
First,I try to click the File->Find Action and search 'open new project'.Then I find a result and enter the settings window:Project opening.(So sad I have no reputation to post a picture)
Select the first check box.

XML attributes order in Android Studio

I'm facing problem with keeping proper order of XML attributes in Android Studio. As you can see below, the style attribute is between layout_* attributes, but I want it to be ordered by name (like in Eclipse). I'm using standard Intellij code formatter and the Android Studio gives users ability to set your own rules regarding XML ordering. The settings are located in Code Style -> XML -> Arrangement, but it seems not to work or I'm using it wrong. Any ideas how to order XML attributes by name using default code formatter?
<TestView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
style="#style/BackgroundLight"
android:layout_height="wrap_content">
</TestView>
Finally got it.
Choose File > Settings > Code Style > XML > Set from > Predefined Style > Android
Set File > Settings > Editor > Formatting > Show "Reformat Code" dialog
Run formatting on a XML file (CTRL+ALT+L by default)
You will see a popup window, set the Rearrange entries flag
Disable Reformat Code dialog in the settings
This way every XML file formatting will set the attributes in a proper order.
Edit:
Starting with Android Studio 0.2.6 release the XML Android style formatting is set by default, but you still have to set the Rearrange Entries flag manually.
http://tools.android.com/recent/androidstudio026released
Automatically apply the Android XML code style if a code style hasn't
already been customized. This will make it possible to automatically
order XML attributes (check the "Rearrange Entries" checkbox in the
"Code > Reformat Code..." dialog.)
UPDATE: the method I described below is an official way to fix this known issue, see: https://developer.android.com/studio/releases
After updating to the newest Android Studio v3.4.2 I found that it doesn't format XML code properly anymore. For instance, attributes ordering didn't work in layouts. It did indentation and namespaces ordering only.
I don't know the reason why it was broken after an update but was lucky to fix this:
Go to Settings (CMD + , ) on Mac.
Type format in Search box and click on Editor -> XML setting.
Click on the Android tab and make the same settings here as it's on a picture:
Settings on a picture quite normal, but of course you can tune this tab setting up to you.
Go to the Arrangement tab and you will see something like this:
The reason why attributes are not getting sorted - sorting rules are empty.
To fix this:
Choose Scheme and play with Default IDE and Project options. Switching between them may help.
Or choose Scheme which suites your needs and then click on Set from... blue text in right upper corner -> Predefined Style -> Android. You will see restored rules in the window:
I also chose Force rearrange - Always
To save result – click Apply.
Also you can click on a gear icon near Scheme and copy settings or even restore defaults.
P.S. To me standard rules are comfortable, but it can be customized further. Here is an article which may help doing this: https://medium.com/#VeraKern/formatting-xml-layout-files-for-android-47aec62722fc
Go to your layout XML
Try Ctrl + alt + shift + L then find checkbox label is Rearrange code and checked its.
To delete empty lines between them:
Preferences > Code Style > XML > Other > Keep blank lines: 0
And then just reformat your XML files.
There is a plugin for IntelliJ which might do what you're after...
http://plugins.jetbrains.com/plugin/?idea&pluginId=6546
File > Settings > Editor > XML > Arrangement Select Scheme and choose Default

Android studio - wrap in container

Is there an equivalent feature in Android studio like Eclipse for "wrap in container"?
On the widget press alt+enter and choose what you want!
For Mac ... same as above but use option+Enter.
UPDATE(2021): Currently, Android studio support wrap in content and you can follow this answer: https://stackoverflow.com/a/59217255/1105277
Original Answer(2016):
You can use soft wrap, first solution is right click on the left of line where show line numbers and check Use Soft Wraps.
Another way is set it from:
File > Settings > Editor > General > Use soft wraps in editor
Also You can set Right margin for your editor from :
File > Settings > Editor > Code Style > Right margin (columns)

Resources