We all know how easily and safely to create a new Activity
. Now I want to know how to remove an Activity
from my project safely.
I've created some activity in my project and feel that they are now needless and I want to delete them. But if I delete manually these files:
The activity's XML file in the /layout
folder
The activity's Java file in the /src
folder
The <activity></activity>
portion from the manifest file
Then,
I found my answer. To remove an activity, let the name of the activity is activity
:
activity.java
file from src
folder (java/your.package.name
folder for AndroidStudio)activity.xml
file from layouts
folder (layout
folder for AndroidStudio)activity.xml
file from res/menu
folder (this is an optional folder)<activity></activity>
block of the activity from the manifest
file<activity>
block in the manifest
file has a reference (usually in android:label
tag) remove the referenced value (usually from values/strings.xml
).According to answers from @ojonugwa ochalifu and @Md Tarik Mahmud you should also right click on app folder then Refractor -> Remove Unused Resources