Android – why do all activities / classes appear in the application list during installation?

I have relatively new Java (well, maybe new, about 10 years old) and Android programming. I have built an application with main activities and two "child" activities, which are activated by two buttons on the main activities window

Everything is fine. However, when I install applications on my phone, there are icons for the main activities / classes and each of the two "sub" activities / classes in the application list on my phone

I believe this is a failure of my java knowledge, but do I hide the activities called through the user interface and only reside them under the main application icon so that it is the only entry point for the application?

These courses are designated as:

public class extends Activity {

Is there a "private class extension activity {" or something similar that allows the main activity to be used but not displayed to the application user?

resolvent:

This is actually an Android system I believe in. Check your Android manifest to see if you include an additional intent filter part in each activity. There should be only one. Your other two activities are not intended to start, so they should not include this part

<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"/>

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>