Android启动活动标题显示在最近打开的应用程序中,而不是App名称

时间:2014-04-01 16:43:32

标签: android android-layout android-manifest

我的Android应用程序在“Android应用程序名称”中有不同的名称,并在Android清单中启动“活动标题”。它在主屏幕上显示正常,但当我双击主页按钮调用最近打开的应用程序列表时,它显示启动“活动标题”而不是应用程序名称。这是我的清单的样子。任何人都可以建议如何修复此问题并在最近打开的应用程序中显示应用名称?

- AndroidManifest.xml

<application
    android:allowBackup="false"
    android:allowClearUserData="false"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" ===> "My App"
    android:theme="@style/AppTheme" >

<activity
        android:name=".MainActivity"
        android:label="@string/title_activity_main" ===> "Welcome to My App"
        android:screenOrientation="portrait"
        android:launchMode="singleTop"
        android:logo="@drawable/ic_header">

         <intent-filter android:label="@string/app_name" > ===> "My App"
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
        </intent-filter>
    </activity>

- Java代码

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Inflate our UI from its XML layout description.
    setContentView(R.layout.activity_main);
}

 @Override
 protected void onStart() {
     super.onStart();
}

 @Override
 protected void onResume() {
     super.onResume();
}

 @Override
 protected void onStop() {
     super.onStop();
}
}

2 个答案:

答案 0 :(得分:0)

我认为为什么会发生这种情况非常清楚。始终使用隐式意图调用主要活动。这意味着您的组件(活动)将作为服务进行调用。

这是隐含意图的工作方式

1活动A创建一个带有动作描述的Intent并将其传递给startActivity()。 2 Android系统会在所有应用中搜索与意图匹配的意图过滤器。当找到匹配时,[3]系统通过调用其onCreate()方法并将其传递给Intent来启动匹配活动(活动B)。

enter image description here

。有关隐式意图的更多信息,请阅读this

此过程针对您的活动完成,因为它有一个单独的名称,因此最近的应用显示其android:label="@string/title_activity_main"

<强>解决方案

我认为除了android:label="@string/app_name"

之外别无他法

答案 1 :(得分:-1)

你可以在这里输入任何你想要的东西

android:label =&#34;我的BadAss游戏!&#34;