Why are all actions / classes displayed in the application list during installation?

I am relatively new to Java (well, maybe new, it was about 10 years old) and Android programming. I created an application with a main action and two "auxiliary" actions, which are activated using two buttons in the main activity window.

Everything is working fine. However, when I install the application on my phone, there are icons for the main activity / class and each of the two “auxiliary” actions / classes in the list of applications on the phone.

This, I believe, is a flaw in my knowledge of Java, but I hide the actions that are invoked through the user interface, and they are only under the main icon of the application, so is this the only entry point to the application?

All classes are designated as:

public class extends Activity {

Is there a "private class extends Activity" or something like this that allows you to use the main action but not show it to application users?

+3
source share
1 answer

This is actually an android thing that I consider. Check your AndroidManifest and see how you are if you include an additional intent filter section for each action. There should be only one. The other two actions are not intended to run, so they should not have this section.

<activity android:name=".MainActivity" android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
</activity>
<!-- these don't have intent-filter children because they aren't meant to be launched -->
<activity android:name=".SubActivity1" android:label="@string/app_name"/>
<activity android:name=".SubActivity2" android:label="@string/app_name"/>
+16
source

Source: https://habr.com/ru/post/1775997/


All Articles