MapSceneConfig to modify the language does not seem to work on Android 13 - here-api

Sorry, I recently found that on Android 13, using MapSceneConfig to modify the language does not seem to work, can you please confirm?
I really need your help, Thank you!
I'm using the lite version.
I tried to change it to zh_tw to show Taiwanese streets.
MapSceneConfig mapSceneConfig = new MapSceneConfig();
mapSceneConfig.mainLanguageCode = LanguageCode.ZH_TW;
mapSceneConfig.fallbackLanguageCode = LanguageCode.ZH_TW;
mapView.getMapScene().loadScene(MapStyle.NORMAL_DAY, mapSceneConfig, new MapScene.LoadSceneCallback() {
#Override
public void onLoadScene(#Nullable MapScene.ErrorCode errorCode) {
if (errorCode == null) {
mapItemsExample = new MapItemsExample(MiniActivity.this, mapView);
mapObjectsExample = new MapObjectsExample(mapView);
mapOverlayExample = new MapOverlayExample(MiniActivity.this, mapView);
setTapGestureHandler(mapView);
if (location != null) {
moveCamera(new GeoCoordinates(location.getLatitude(), location.getLongitude()));
Log.e("location", "moveCameraonResume");
}
} else {
Log.d(TAG, "onLoadScene failed: " + errorCode.toString());
}
}
});
I found that it works normally on Android 11, but not on Android 13.

Related

Xamarin, SQLite : Don't know how to read System.Char

I use the below code to search SQLite table. It works fine with Android 9. But I receive the below error in Android 10.
Where should I check or how can I make minimal change in the code so that it will work on Android 10 also.
Edit 1:
I'm using the following versions.
Xamarin.Forms v4.5.0.495
Xamarin.Essentials v1.3.1
sqlite-net-pcl v1.7.335
Code:
public SearchPage()
{
InitializeComponent();
conn = DependencyService.Get<ISQLiteMyConnection>().GetConnection();
try
{
DisplayLines("");
}
catch (Exception ex)
{
DisplayAlert("Error", ex.Message, "Ok");
}
}
public void DisplayLines(string searchText)
{
if (String.IsNullOrWhiteSpace(searchText))
{
var details = (from x in conn.Table<QLines>() select x).ToList();
myLines.ItemsSource = details;
searchCount.Text = "";
}
else
{
var details1 = (from x in conn.Table<QLines>() where x.PartA.Contains(searchText) || x.PartB.Contains(searchText) select x).ToList();
myLines.ItemsSource = details1;
searchCount.Text = "Matches found : " + details1.Count.ToString();
}
}
private void SearchBar_TextChanged(object sender, TextChangedEventArgs e)
{
DisplayLines(e.NewTextValue);
}
Error:
Don't know how to read System.Char
I got the issue.
The nuget package SQLite.Net.Core-PCL is deprecated. This package is handling LINQ like query on SQLite db. Suggested alternative is sqlite-net-pcl. Might be, I need to revise the code.
Edit: I have updated the Xamarin Form to version 5. And revised the code ( I used query instead of LINQ)

Xamarin.Forms iOS Create animation using images

I work on Xamarin.Fomrs shared project. I want to display multiple images at same place with 100 ms interval. So that it will look like a GIF. In Android It is working. I created drawable file and in that I have put all the images with time interval. But in iOS, I am facing problem.
I found CAKeyFrameAnimation is used to implement this type of functionality. But I couldn't find how to implement it as I want.
I have implemented CAKeyFrameAnimation in ImageRenderer like this
class AnimatedImageRenderer : ImageRenderer
{
public AnimatedImageRenderer() { }
Animation objAnimation = new Animation();
protected override void OnElementChanged(ElementChangedEventArgs<Image> e)
{
base.OnElementChanged(e);
if (Control != null)
{
try
{
CAKeyFrameAnimation anim = CAKeyFrameAnimation.FromKeyPath("contents");
anim.Duration = 1;
//anim.KeyTimes = new[] {
// NSNumber.FromDouble (0), // FIRST VALUE MUST BE 0
// NSNumber.FromDouble (0.1),
// NSNumber.FromDouble(0.2),
// NSNumber.FromDouble(0.3),
// NSNumber.FromDouble(0.5),
// NSNumber.FromDouble(0.6),
// NSNumber.FromDouble(0.8),
// NSNumber.FromDouble(1.0), // LAST VALUE MUST BE 1
// };
anim.Values = new NSObject[] {
FromObject(UIImage.FromFile("bomb1.png")),
FromObject(UIImage.FromFile("bomb2.png")),
FromObject(UIImage.FromFile("bomb3.png")),
FromObject(UIImage.FromFile("bomb4.png")),
FromObject(UIImage.FromFile("bomb5.png")),
FromObject(UIImage.FromFile("bomb6.png")),
FromObject(UIImage.FromFile("bomb7.png")),
};
//anim.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.Linear);
anim.RepeatCount = 1;
anim.RemovedOnCompletion = false;
//anim.CalculationMode = CAAnimation.AnimationLinear;
//c.Init();
Control.Layer.AddAnimation(anim, "bomb");
}
catch (System.Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
// ModCommon.TraceLog("AnimatedImageRenderer tm_Tick" + ex.Message);
}
}
}
}
I don't know what extra property is missing. Please guide me.
Thank you :)
You should use CGImage instead of UIImage. Change your animation's value to:
anim.Values = new NSObject[] {
FromObject(UIImage.FromFile("bomb1.png").CGImage),
FromObject(UIImage.FromFile("bomb2.png").CGImage),
FromObject(UIImage.FromFile("bomb3.png").CGImage),
FromObject(UIImage.FromFile("bomb4.png").CGImage),
FromObject(UIImage.FromFile("bomb5.png").CGImage),
FromObject(UIImage.FromFile("bomb6.png").CGImage),
FromObject(UIImage.FromFile("bomb7.png").CGImage),
};

Toggle audio in speaker to ear-speaker and vice versa in iphone but microphone is muted

We are using third party Audio/Video SDK in our Xamarin.Forms.iOSproject. Now problem is that by default audio comes in speaker mode, instead of ear-speaker. I found below code and using that audio is toggling in ear-speaker and speaker. but when I am on speaker then microphone is muted and when I am in ear-speaker then both are working. so my question is how to enable microphone in both case?
bool blIsOnEarSpeaker=false;
public void SetAudioSettingsForIOS()
{
var session=AVFoundation.AVAudioSession.SharedInstance();
AVFoundation.AVAudioSessionCategory objCategory= AVFoundation.AVAudioSessionCategory.Playback;
Foundation.NSError error = null;
if (blIsOnEarSpeaker==false)
{
objCategory=AVFoundation.AVAudioSessionCategory.PlayAndRecord;
blIsOnEarSpeaker=true;
error = session.SetCategory(objCategory);
}
else
{
objCategory=AVFoundation.AVAudioSessionCategory.Playback;
blIsOnEarSpeaker=false;
error = session.SetCategory(
objCategory
,AVFoundation.AVAudioSessionCategoryOptions.DefaultToSpeaker
);
}
error = session.SetActive(true);
}
In the else condition:
Change
**objCategory=AVFoundation.AVAudioSessionCategory.Playback;**
to
**objCategory=AVFoundation.AVAudioSessionCategory.PlayAndRecord;**
OR better approach would be, using this line before if/else condition :
bool blIsOnEarSpeaker=false;
public void SetAudioSettingsForIOS()
{
var session=AVFoundation.AVAudioSession.SharedInstance();
AVFoundation.AVAudioSessionCategory objCategory= AVFoundation.AVAudioSessionCategory.Playback;
Foundation.NSError error = null;
objCategory=AVFoundation.AVAudioSessionCategory.PlayAndRecord;
if (blIsOnEarSpeaker==false)
{
blIsOnEarSpeaker=true;
error = session.SetCategory(objCategory);
}
else
{
blIsOnEarSpeaker=false;
error = session.SetCategory(
objCategory
,AVFoundation.AVAudioSessionCategoryOptions.DefaultToSpeaker
);
}
error = session.SetActive(true);
}

Local SQLite DB in FLex Mobile app

I'm coding an app for Android and iOS devices using Flex. I've an SQLite db already created and I want access to his data. I've seen some code looking with google but I'm not able to run nothing.
I would appreciate if you can explain me where I've to put the file.db into my project and if you share me some simple code that allow to connect to file.db and select some rows.
Sorry for my bad english and thanks in advance.
The code bellow will return an object with the data from the database.
package bd
{
public class SQLPadConnection extends SQLStatement
{
protected var _DBFilePatch:String = "DB.sqlite";
protected var _conn:SQLConnection = new SQLConnection();
public function SQLPadConnection()
{
var folder:File = File.userDirectory.resolvePath('com.app.directoryName');
if (!folder.exists) {
folder.createDirectory();
}
_conn.open(folder.resolvePath(_DBFilePatch));
this.sqlConnection = _conn;
super();
}
public function getSQLData(SQL:String = ""):Object
{
if (StringUtil.trim(SQL) != "")
{
this.begin();
this.text = SQL;
this.execute();
this.commit();
return this.getResult();
}
else
return null;
}
}
}
To use that, just do like bellow:
var res:Object = new Object();
var SQL:SQLPadConnection = new SQLPadConnection();
res = SQL.getSQLData("SELECT * FROM TABLE");
res = SQL.getSQLData("INSERT INTO/ UPDATE/ DELETE...");
Hope this help someone.
I'm going to assume you actually meant AIR, this runtime is what allows you to connect to SQLite. In which case there is gobs of information just in the reference alone...
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/data/SQLConnection.html

Adobe Flex: memory leak when pushView an popView

I am having problems of memory leaks with an app I had build in Adobe Flex, using Flex Builder. After using it for 30-40 minutes it starts to go slower and slower.
The app shows images as a catalog, but when I push and pop the views my memory rise considerably.
My thoughts are that if I set all my objects to null and dispose all the bitmapdata that I use I could free enough memory to keep using the app with no problems, but it seems like the problem is not there.
I have 3 views in my app menuView.mxml,categoriesView.mxml and productsView.mxml.
My App starts up in my pc (not in tablet) with TotalMemory: 47Mb and Private Memory : 88 MB
After pushing and poping the views for 5 times I get TotalMemory: 61Mb and Private Memory : 101 MB
Imagine if I do this several times. The app begins to go very slow in my Ipad or my Samsung Galaxy Tab.
Why is this happening? I have no idea how to solve this.
Please help! Thanks a lot!!
I put some code below.
When I am in menuView I use the following code to push the view from menuView to categoriesView
protected function button3_clickHandler(event:MouseEvent):void
{
if((FlexGlobals.topLevelApplication.getIdClienteServidorCompraActual( )!=null)&& (FlexGlobals.topLevelApplication.getIdClienteServidorCompraA ctual()>0))
{
navigator.pushView(categoriesView);
}
}
When I am in categoriesView I use the following code to push the view from categoriesView to productsView. In this view I have 3 buttons for each category.
protected function buttonC1_clickHandler(event:MouseEvent):void
{
//Categoria general con todos
var ab:ArrayCollection = getIdAmbienteServidor();
cleanMemory();
navigator.pushView(productsView, null);
}
private function cleanMemory():void
{
result.splice(0);
result = null;
System.gc();
}
When I am in productsView I use the following code to pop(I USE PUSH INSTEAD OF POP DUE TO DIFFERENT OPTIONS I HAVE) the view from productsView to categoriesView .
protected function button1_clickHandler(event:MouseEvent):void
{
cleanMemory();
navigator.pushView(menuView);
}
private function cleanMemory():void
{
if(image1 != null)
{
image1.source = "";
if(image1.bitmapData != null)
{
image1.bitmapData.dispose();
}
}
if(image2 != null)
{
image2.source = "";
if(image2.bitmapData != null)
{
image2.bitmapData.dispose();
}
}
if(result != null)
{
result.splice(0);
result = null;
}
if(result1 != null)
{
result1.splice(0);
result1 = null;
}
if(result2 != null)
{
result2.splice(0);
result2 = null;
}
dbConnection = null;
object1 = null;
object2 = null;
dataToSave = null;
cGreyImageSmallAsset = null;
cRedImageSmallAsset.bitmapData.dispose();
cRedImageSmallAsset = null;
cOrangeImageAsset.bitmapData.dispose();
cOrangeImageAsset = null;
cGreenImageAsset.bitmapData.dispose();
cGreenImageAsset = null;
cPinkImageAsset.bitmapData.dispose();
cPinkImageAsset = null;
cBlueImageAsset.bitmapData.dispose();
cBlueImageAsset = null;
cGreyImageAsset.bitmapData.dispose();
cGreyImageAsset = null;
cRedImageAsset.bitmapData.dispose();
cRedImageAsset = null;
cGreenImageSmall = null;
cOrangeImageSmall = null;
cPinkImageSmall = null;
cBlueImageSmall = null;
cGreyImageSmall = null;
cRedImageSmall= null;
cGreenImage = null;
cPinkImage = null;
cBlueImage= null;
cGreyImage = null;
cRedImage= null;
cOrangeImage= null;
System.gc();
}
I load the images with.
private function setImages():void
{
if(object1!=null)
{
panelLeft.visible = true;
buttonLeftMore.visible = true;
image1.source = "file://" + File.applicationStorageDirectory.nativePath + "/b"+object1.idArchivo+"_500.jpg";
setObject1MainTexts();
}
else
{
image1.source = "";
panelLeft.visible = false;
buttonLeftMore.visible = false;
}
if(object2!=null)
{
panelRight.visible = true;
buttonRightMore.visible = true;
image2.source = "file://" + File.applicationStorageDirectory.nativePath + "/b"+object2.idArchivo+"_500.jpg";
setObject2MainTexts();
}
else
{
image2.source = "";
panelRight.visible = false;
buttonRightMore.visible = false;
}
}
When I am in categoriesView i use the following code to pop(I USE PUSH INSTEAD OF POP DUE TO DIFFERENT OPTIONS I HAVE) the view from categoriesView to menuView.
protected function button1_clickHandler(event:MouseEvent):void
{
cleanMemory();
navigator.pushView(menuPrincipalBelda);
}
private function cleanMemory():void
{
result.splice(0);
result = null;
System.gc();
}
Thanks in advance!
I discover the problem: I was not removing the EventListener, now is working fine.
I leave you guys with some examples. If you do not remove them, then memory increases a lot! Be careful with this.
stage.addEventListener("keyUp", handleButtons, false, 1);
stage.removeEventListener("keyUp",handleButtons,false);
xeasy.addEventListener(ResultEvent.RESULT, AppWS_resultHandler);
xeasy.removeEventListener(ResultEvent.RESULT,AppWS_resultHandler, false);
Thanks to everybody!!
Remember that Flex Builder uses the Flash virtual machine and this frees the memory when considered necessary, even if you try to force him to clean the garbage collector will not do if you have free memory and does not consider it necessary.
Test the movie embedded in the images you need in the application, and not constantly loading. Since this may be letting some low-level relationship.
regards
When I worked with GC I found that it became of advantage to try several different ways! I used 3 in total over time, but just can only find one at the moment as this was the one noticeable better working in this App. so here it is and if needed I can send the other two as well must just look for them!
private var gcCount:int;
private function startGCCycle():void {
gcCount = 0;
addEventListener(Event.ENTER_FRAME, doGC);
}
private function doGC(evt:Event):void {
flash.system.System.gc();
if(++gcCount > 1) {
removeEventListener(Event.ENTER_FRAME, doGC);
setTimeout(lastGC, 40);
}
}
private function lastGC():void{
flash.system.System.gc();
}
]]>
I just was looking at something else which you should try as well it worked for me very well!
FlexGlobals.topLevelApplication.deleteReferenceOnParentDocument(this) I used these in a creationComplete in MXML where I had to open 45 Main Canvases one after another but each time with three PopUps = 180 which was easy to handle in the way I worked the GC in! regards aktell

Resources