Reputation: 75
The icon label is being overwritten by the Label specified on my Main Activity Label.
My AndroidManifest.xml has:
<manifest>
<application android:label="@string/app_name" />
</manifest>
My AssemblyInfo.cs has:
#if DEBUG
[assembly:Application(Debuggable=true, Label="@string/app_name")]
#else
[assembly:Application(Debuggable=false, Label="@string/app_name")]
#endif
My String.xml has:
<string name="app_name">MyApp</string>
My MainActivity.cs has:
[Activity (Label = "Demo App")]
When I email the apk to the phone, gmail asks me to install 'MyApp', which appears to be coming from the manifest or the Assembly. However, the icon on the App Launch screen shows 'Demo App', which is coming from the MainActivity.cs.
I want the Label from the Activity to be appearing as the title of the app(Demo App), whereas I want the App launch name to be 'MyApp'. Can I override the title somehow to get this working?
My AndroidManifest.xml has:
<manifest>
<application android:label="@string/app_name" android:icon="@drawable/AppIcon"/>
</manifest>
In String.xml has:
<string name="app_name">MyApp</string>
<string name="Home">Demo App</string>
In MainActivity.cs: Instead of this
[Activity (Label = "Demo App")]
use ActionBar
to set title,icon. Then you will get different name in app launch screen and home screen.
[Activity(MainLauncher = true, LaunchMode = Android.Content.PM.LaunchMode.SingleTop,)]
public class MainActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.main);
ActionBar.SetIcon(Resource.Drawable.Icon);
ActionBar.SetTitle(Resource.String.Home);
}
}
Upvotes: 1
Views: 2752
Reputation: 9084
I want the Label from the Activity to be appearing as the title of the app(Demo App), whereas I want the App launch name to be 'MyApp'.
Remove the Label
of the MainActivity
, set the application in the Manifest.xml
via UI or code:
<manifest ...>
<application android:label="@string/app_name" />
</manifest>
If your MainActivity
is AppCompatActivity
, you could use Toolbar
to display the Activity
label:
[Activity(MainLauncher = true, LaunchMode = Android.Content.PM.LaunchMode.SingleTop, Icon = "@drawable/icon")]
public class MainActivity : AppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.main);
var toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
if (toolbar != null)
{
SetSupportActionBar(toolbar);
SupportActionBar.Title = "Demo App";
}
}
}
Here is my toolbar.axml
:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
local:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
main.axml
:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
</RelativeLayout>
Upvotes: 1