My app has this main activity:
<activity
android:name=".main.MainActivity"
...
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
and it launches with no problem from the home launcher. However, when I try to launch it from Google's Gesture Search, I get a Gesture error message saying that the app does not have .MainActivity
.
https://play.google.com/store/apps/details?id=com.google.android.apps.gesturesearch
Do Android apps required to have the main activity called .MainActivity
? If not, is it a soft recommendation or a convention or just a bad assumption on Gesture's part?
Yes, you can change the name of MainActivity by, opening the directory of the java file in android studio, right-click on it and find refactor, then rename, put in the name you like then click on refactor. Save this answer.
Typically, one activity in an app is specified as the main activity, which is the first screen to appear when the user launches the app. Each activity can then start another activity in order to perform different actions.
The activity is a Java class, and the layout is an XML file, so the names we've given here will create a Java class file called MainActivity. java and an XML file called activity_main. xml. When you click on the Finish button, Android Studio will build your app.
Navigate to app>java>your app's package name>Right click on it>New>Empty activity and name it as MainActivity2. Navigate to app>res>layout>activity_main2. xml and add the below code to it. Comments are added in the code to get to know in detail.
Android apps do not require any activity called .MainActivity. Furthermore, I'm not aware of any conventions like this. It sounds like you may be unknowingly telling Gesture that you want something called .MainActivity.
Perhaps it is because you put a package name before the actual name of the class. Try putting the fully qualified class name instead. Also try renaming the Activity, and see if you get any different results.
Android apps do not require an activity named MainActivity
and you should not assume (and should certainly not rely) on any application implementing one.
Furthermore, I have never heard of any convention that recommends doing so. Most developers will name each activity to suit its behavior and/or purpose in the application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With