Creating animator file in Android Studio blocks app - android

I'm working on Android apps in Android Studio and need to add an animation to the project using an xml file.So I created a res/animator directory and I put in it a file called pulsation.xml,which do nothing, here the code:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"android:ordering="together">
</set>
Inside an Activity, the app access to some value stored in a SharedPreferences object.When running the apps without the pulsation.xml file in the res/animator directory the program retrieves the values needed without problems, when putting a .xml file inside res/animator the programs can't retrieve anything.I can't understand where this weird behavior come from. Here the piece of code where the app retrieve the data from the SharedPreferences object:
SharedPreferences pref = getSharedPreferences("ballan.emmanuele.hellpuzzle.PUNTEGGI",MODE_PRIVATE);
SharedPreferences.Editor editor = pref.edit();
do
{
next = pref.getInt(R.id.liv1+"next",R.id.liv2);
TextView punt = (TextView) findViewById(pref.getInt(next+"punt",R.id.punt1));
punt.setText(pref.getInt(next+"punteggio",0)+"");
TextView num = (TextView) findViewById(pref.getInt(next+"num",R.id.num1));
num.setText(pref.getInt(next+"numero_sequenza",0)+"");
LinearLayout lay =(LinearLayout)findViewById(pref.getInt(next+"riga",R.id.riga1));
lay.setVisibility(View.VISIBLE);
}while (next != ultimo);
I set the minimum SDK version to 11.Thanks for helping.

I discovered the problem consists with Nexus S Api 23. Using this emulator the program still don't work, changing emulator or using my Samsung or other Nexus emulators phone the app doesn't bother.

Related

NLog with Xamarin cross-plattform application doesn't log anything

I set up NLog like this in the Android part of my Xamarin-project.
My NLog.config looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="true"
throwConfigExceptions="true"
internalLogLevel ="Trace"
internalLogFile ="C:\Users\MyUser\intLogFile.txt"
internalLogToConsole="true"
internalLogIncludeTimestamp ="true">
<targets>
<target name="file" xsi:type="File"
layout="${longdate} ${logger} ${message}${exception:format=ToString}"
fileName="/storage/emulated/0/Download/${shortdate}.log" />
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="file" />
</rules>
</nlog>
I put the NLog.config in the assets-folder in my android-project.
I added this NuGet to my android-project.
I changed the build action to embedded resource.
I made sure to have writing permissions on the external storage of the device.
I am loading the NLog configuration programmatically like this and nlogConfigFile != null is true so I assume the NLog.config is found.
As you can see I enabled throwing exceptions from NLog but there are no exceptions thrown...
...But the internal logging is not working aswell
I followed every step of the troubleshooting by NLog
Has somebody an idea why NLog is still not logging anything?
--------------------- UPDATE ----------------------------
NLog is now logging with basic setup of a LogService-class:
public void Initialize(Assembly assembly, string assemblyName)
{
var location = $"{assemblyName}.NLog.config";
var stream = assembly.GetManifestResourceStream(location);
NLog.LogManager.Configuration = new XmlLoggingConfiguration(XmlReader.Create(stream), null);
NLog.Common.InternalLogger.LogFile = "C:\\Users\\MyUser\\Documents\\internalLog.log";
NLog.Common.InternalLogger.LogWriter = new StringWriter();
NLog.Common.InternalLogger.LogLevel = LogLevel.Debug;
}
But the internal log is still not showing up. As you can see I tried configuring the InternalLogger in code and also in the NLog.config. I tried putting the NLog.config in the assets-folder and in the main android-project and I set build action to respectively embedded ressource or android asset.
--------------------- 2nd UPDATE --------------------------
The InternalLogger is now working on my Android-device.
In this tutorial the internal file is logged to c://temp/... which I assume is a path on Windows. But I am still not able to achieve this during debugging. Is this even possible?
Following some additional troubleshooting tips that helped me solving my issue:
If you are using a real Andriod-device and not an emulator unplug the
debugging connection and reconnect it. The Windows-File-Explorer
sometimes is not updating the files in the folders of the device if
it is not reconnected.
Basic initializing in the code should be enough:
public void Initialize(Assembly assembly, string assemblyName)
{
var location = $"{assemblyName}.NLog.config";
var stream = assembly.GetManifestResourceStream(location);
NLog.LogManager.Configuration = new XmlLoggingConfiguration(XmlReader.Create(stream), null);
}
You should be fine by putting NLog.config as an embedded resource in the main folder of the android project. If not put it as an android asset in the assets-folder.
If it is still not logging try to set the configuration up programmatically
Also make sure your minlevel in the .config is lower than the loglevel you are using.

JavaFxPorts TextField Issue - Android Keyboard wont function

I developed a simple javafx application to be ported in Android Environment, however I cant type any characters in the TextField. I guess its a bug, how to fix this one?
Th problem on galaxy S5 android 5.0.1 is not present but on galaxy tab 4 android 5.0.2 it doesn't work i type but none is displyed.
Tried with normal textfield. And the problem persist also I have added the properties .
Another strange rhig is that the space where recognizer. And the del button . The text not
THe code by example is very easy
Rectangle2D visualBounds = Screen.getPrimary().getVisualBounds();
double width = visualBounds.getWidth();
double height = visualBounds.getHeight();
TextField tt= new TextField();
tt.setTranslateY(-150);
StackPane stackPane = new StackPane();
stackPane.getChildren().addAll(tt);
borderpane.setCenter(stackPane);
Scene scene = new Scene(borderpane, width, height);
stage.setScene(scene);
Assuming that CustomTextField is just a custom TextField, this is a known issue, not related to the CustomTextField itself, given that it works in other device.
If you debug it:
./adb logcat -v threadtime
you surely find an exception that explains the issue: a StackOverFlow exception.
On older devices it can be solved adding this: create a java.custom.properties file, and include in it this property:
monocle.stackSize=128000
You may also include this one:
monocle.platform=Android
(it will be soon included by default in the next version)
Put the file at the root of your classpath, e.g. in the folder src/android/resources of your project.
Build and deploy the project on your mobile and check again.

My Android App hangs on SharedPreferences, but only in Android 5

An odd one here. I've built an app in Android Studio which is working perfectly in Android 4 (4.4.2), but it just stopping on Android 5.0.2. It's not throwing up any errors, just stopping.
Going line by line, it seems to be focussed on the SharedPreferences file, which it's not loading.
protected void onCreate(Bundle savedInstanceState) {
try {
super.onCreate(savedInstanceState);
final SharedPreferences sharedPreferences = this.getSharedPreferences("appname", MODE_PRIVATE );
currentlyTracking = sharedPreferences.getBoolean("currentlyTracking", false);
So, on Android 4, going line by line, when I get to the currentlytracking line, I can view the contents of the SharedPreferences file in the Variables window, and the app works. On Android 5, when I get to the currentlytracking line, none of the variables show up, and it just says 'Collecting data'. The app then stops if I try to continue on.
Interestingly, if I change the name of the Sharedpreferences file, it will create a new file but then fail to save to it.
This is only happening on Android 5, any thoughts would be appreciated.
Cheers

Google Tag Manager Not Showing Values

I just started working on Google Tag Manager. I got it worked. But I faced one issue. That is, each time I edit or add some new macros, I need to create new version and publish it. Unless I am not downloading the new version and saving inside assets/tagmanager and also unless I refer with the new version name of the downloaded file, I am not able to see my updates.
Is it so? If so, I didn't understand why this is useful. Is anything done by me went wrong?
I got it worked.The issue was when we keep the json or binary inside assets folder, then on openContainer() call, Google Tag Manager will check for the saved file first. Then only it will goto the network and search. This caused issue to me. So I removed the file kept inside assets/tagmanager folder.
Also I called container.refresh() before we set value inside the singleton class.
Sample code:
ContainerOpener.openContainer(tagManager, CONTAINER_ID, OpenType.PREFER_NON_DEFAULT,
TIMEOUT_FOR_CONTAINER_OPEN_MILLISECONDS, new ContainerOpener.Notifier() {
#Override
public void containerAvailable(Container container) {
container.refresh();
// Save container for use by any other activities in the app.
WPContainerHolder.setContainer(container);
//perform your other functionalities
}
});

getting Eclipse to see recently added Drawables (png artwork)

I'm having trouble getting Eclipse to see that I've just put a new image into my project when referencing that image using R.drawable.this_text
So I drag my png into myProject/res/drawable-hdpi in Eclipse's Project Explorer. The name of the image is this_text and it's a png!
So I go into my application and I want to put this on the screen; So here's the code for that...
private void setTitle()
{
ImageView title = new ImageView(this); //this extends activity
title.setBackgroundResource(R.drawable.this_text);
...
}
This I have done before and each time I do it I experience the same thing:
if i just dragged my this_text.png into the Project Explorer in eclipse, the word "this_text" will be underlined in red, and not allow me to compile or proceed. I try to F5 (refresh) the project. I try refreshing the image foldr, the src, the actual java...etc! I try closing and opening eclipse but nothing really works. So I quit for afew minutes and work elsewhere in my application, and eventually this error goes away!
Well I'm impatient today-- And I'd rather know how to solve this incase I need to do any quick programming! So does anyone know what to do?
I'm using eclipse Version: Indigo Service Release 1.
Thanks- Ethan
R files for android are generated. Rather than refreshing you should be able to CLEAN the project which should fix your issue. You could even just delete the error from the problems list which would allow for compilation to start and for the generated R file to be created. Or you could make a change to an xml which would also allow for the file to be regened. As always make sure you are up to date on your tool chain.

Categories

Resources