开发者

Why Do All Activities/Classes Show Up in the Application List When I Install?

开发者 https://www.devze.com 2023-01-25 21:46 出处:网络
I am relatively new to Java (well, might as well be new, it\'s been about 10 years) and Android programming.I have built an app with a main activity and two \"sub\" activities that are activated using

I am relatively new to Java (well, might as well be new, it's been about 10 years) and Android programming. I have built an app with a main activity and two "sub" activities that are activated using two buttons on 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 "sub" activities/classes in the applications list on the phone.

This, I believe is a failing of my Java knowledge but do I hide activities that are called via the user interface and have them reside under only the main application icon so that it is the sole entry point into the app?

The classes are all designated 开发者_JS百科like:

public class extends Activity {

Is there a "private class extends Activity {" or something like it that will allow use by the main activity but not show it for app users?


This is actually an android thing I believe. Check your AndroidManifest, and see how you if you have included an extra intent-filter section on each activity. There should really only be one. Your other two activities aren't meant to be launch so they shouldn't have that 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"/>
0

精彩评论

暂无评论...
验证码 换一张
取 消