I am going through this tutorial and I am a bit confused of about this part
Inside the Resources/Values/ folder, open Strings.xml. This is where you should save all default text strings for your user interface. The default template for this file starts with two strings, hello and app_name. Revise hello to something else. Perhaps "Hello, Android! I am a string resource!" The entire file should now look like this:
view plainprint?
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="Hello">Hello, Android! I am a string resource!</string>
<string name="ApplicationName">Hello, Android</string>
</resources>
I would have thought it would show up as in the application menu(where you go to select the application you want)
However that does not seem to be the case. I am not sure if the code label is overriding it or what
[Activity(Label = "Test Test", MainLauncher = true, Icon = "#drawable/icon")]
public class Activity1 : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
}
}
As I see "Test Test"
Gets shown by the Package Installer when the user is Installing your app.
label is the one that you in manage apps or in the app cabinet. the application name is optional.
"An optional name of a class implementing the overall android.app.Application for this package"
is what Eclipse says.
Related
Here is the code in my app:
namespace JTest.Droid
{
[Activity(Label = "Test+", Theme = "#style/MainTheme")]
public class MainActivity : FormsAppCompatActivity
{
Does anyone know what the purpose of the Label = "Test+", is and why the developer might have included this?
Lable attribute is Activity Title Bar.
By default, Android gives your application a title bar when it is run. The value used for this is /manifest/application/activity/#android:label.
In most cases, this value will differ from your class name. To specify your app's label on the title bar, use the Label property. For example:
[Activity (Label="Awesome Demo App")]
public class MyActivity : Activity
{
}
This example produces the following xml fragment:
<activity android:label="Awesome Demo App"
android:name="md5a7a3c803e481ad8926683588c7e9031b.MainActivity" />
Label determine the activity title as shown in the Android launcher.
I am trying to implement an splash screen for the Android part of my UNO solution. I can get the splash screen to appear, wait a few seconds but upon navigation to the main page I get the following exception in the app.cs
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
{
// this.DebugSettings.EnableFrameRateCounter = true;
}
#endif
Frame rootFrame = Windows.UI.Xaml.Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame(); <<<<< exception
Unhandled Exception:
Java.Lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference occurred
The stack trace is as simple as :
0x25 in Uno1.App.OnLaunched at C:\Users\pjsta\Documents\Visual Studio 2017\Projects\Uno1\Uno1\Uno1.Shared\App.xaml.cs:55,17 C#
The relevant part of the solution are
1. my new SplashActivity in the Android project
[Activity(Label = "SplashScreen", MainLauncher = true, Theme = "#style/Theme.SplashActivity")]
public class SplashActivity : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
System.Threading.Thread.Sleep(1000);
StartActivity(typeof(MainActivity));
}
}
Modification to MainActivity to not be the MainLauncher
[Activity(
MainLauncher = false,
ConfigurationChanges = ConfigChanges.Orientation |
ConfigChanges.ScreenSize,
WindowSoftInputMode = SoftInput.AdjustPan | SoftInput.StateHidden )]
public class MainActivity : Windows.UI.Xaml.ApplicationActivity
{
}
The relevant style loads fo the splash screen OK. Switching the MainActivity back to MainLauncher=true works , albeit without a splash screen.
I am a newbie to Xamarin and Android development, but competent in UWP. Anyone out there got any ideas?
From the exception, it sounds like when new Frame() is called, the base native constructor is called with a null Context. This is probably because Uno expects ApplicationActivity to be run as MainLauncher=true. It's possible that inheriting your SplashActivity class from Uno.UI.BaseActivity could resolve the error.
A better way to show a splash screen on Android is to modify the theme rather than create a separate activity. I'll use the Uno Gallery app as an example.
Create a file in the Resources/drawable folder of your Android head called, eg, splash.xml. Define your splash screen visual appearance here.
Open the Resources/values/Styles.xml file. Inside the 'AppTheme' style add the following line:
<item name="android:windowBackground">#drawable/splash</item>
Hope that helps. Also, please tag questions about the Uno Platform as 'uno-platform' (the 'uno' tag refers to the OpenOffice component model).
I've create a short test Application with the following pre conditions:
My Smartphone run on 7.0 (and up). I've setup multiple languages in my settings English (United States) & Deutsch (Deutschland).
This is my App setup:
compile-, target-, min-SdkVersion 24
String-Resources:
The content from strings.xml ("default") is:
<resources>
<string name="app_name">Test</string>
<string name="test">default</string>
</resources>
And the content from string.xml (values-en-rGB) is:
<resources>
<string name="test">GB Fallback!</string>
</resources>
The MainActivity have only a onCreate() with the following code:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final String string = getString(R.string.test);
Log.d("TestString", string);
final LocaleList locaList = LocaleList.getDefault();
for (int i = 0; i < locaList.size(); i++) {
Log.d("AvailableLocale", locaList.get(i).toLanguageTag());
}
}
When I run my App I expect the output from "TestString" is GB Fallback!. Why? Because Android 7.0 support multilingual. * (See update)
Instead of GB Fallback! I get always the default output. That means default.
The output from AvailableLocale is always up to date with the setup from my phone settings.
So. Why I got default from getString(R.string.test). Do I miss understand something with the multilingual stuff from the Android docs?
* Update
Why I claim I got GB Fallback!. The reason is the multilingual feature. The documentation shows a nice table:
I will try it to map it to my situation:
(Sorry, my Image is wrong. I don't mean de-GB. It's en-GB of course)
So, what is wrong here?
This help is for a simple Air on Android app done using flash CC.
I am using a XML to store some settings data.
The first launch of the app will show a tutorial, once the user selects "Ok got it" Button, the data in the XML should be changed to false so that when it is launched again the tutorial wont play.
This is the XML
<?xml version="1.0" encoding="utf-8"?>
<SETTINGS>
<SET intro="true"></SET>
</SETTINGS>
This is the AS3 to get data from the XML
var settingsXML: XML;
var settingsXMLLoader: URLLoader = new URLLoader();
settingsXMLLoader.load(new URLRequest("settings.xml"));
settingsXMLLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e: Event): void {
settingsXML = new XML(e.target.data);
if (settingsXML.SET[0].#intro == true) {
gotoAndStop("tutorial");
} else {
gotoAndStop("homepage");
}
}
Now in another frame i need to change the xml "intro" to "false" and save it at the same location. Please help. how to do it?
And How to make
settingsXMLLoader.load(new URLRequest("settings.xml"));
load xml from documentsDirectory, i mean this path
File.documentsDirectory.resolvePath('App Name/data/settings.xml');
am working in a multi language Alarm android application with :
1 xml file [alarm_settings.xml]
2 string.xml files [English & arabic]
The problem is that the localization is not working in the right way, below you can find 4 images 2 for my application and 2 for the device's Settings
When you look at these 4 images you can find that in my application the localization works only for the text not for the alignment of views , but you can find in the device's settings that the localization works for both of them - text , views - .
So is it a special case for the device's settings views or i can make my views to be localized like the Device's settings ?!
.java File :
public class MainActivity extends PreferenceActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.alarm_settings);
}
}
thanks
Just found the Solution of the problem at Android Developers Blog
in my case it it was to add
android:supportsRtl="true"
to the element
application
in
manifest file.