HERE SDK for Flutter - Empty screen when resuming from background - here-api

We have new use case and problem. When the application returns from the background, there is a empty screen instead of the map.
More info:
We are using IndexedStack to show the map and other tabs
This error occurs on both android and ios
In every 'resumed' we are setting this:
#override
void didChangeAppLifecycleState(AppLifecycleState state) {
super.didChangeAppLifecycleState(state);
switch (state) {
case AppLifecycleState.resumed:
final brightness = WidgetsBinding.instance.window.platformBrightness;
final hereMapScheme = widget._mapSchemeFormatter.format(mapSchemeUiModel, brightness);
_hereMapController.mapScene.loadSceneForMapScheme(hereMapScheme, (p0) { });
break;
(...)
}
}
System info:
HERE SDK for Flutter (version: 4.12.7)
Flutter version: 3.3.4
Steps to reproduce:
Open app -> map is OK Put app into background, without it being killed by the system Resume the app after a while (~20 min) Behaviour:
I couldn't find a pattern yet as to how long the app needs to be in the background or how much load the device needs to be under (I think it is more likely to happen if the app stays in the background for a longer time). The map works in foreground and after a short background.

Related

flutter audio play delay

I am using the audioplayers package to play my mp3 audio files that are stored in firebase cloud storage. There is a significant delay for both Android and iOS and only just slightly faster in Android. I have since moved all my audio sound files to local asset.
AudioPlayer audioPlayer = AudioPlayer(mode: PlayerMode.LOW_LATENCY);
play(String url) async {
int result = await audioPlayer.play(url);
if (result == 1) {
// success
print('success');
}
}
Just a few days ago, I tested with the audio player in iOS Swift and play some audio files from firebase cloud storage but I did't encounter any significant delay due to buffering and it was a lot faster.
I need to find a way to get around this as I have many audio files and they need to be stored in the network. Anyone of you have encountered similar issues and do you have any good suggestions?
Update
Made this second PR that addresses few shortcomings of the first original PR. Both are merged into master branch of audioplayers.
My PR changes are:
playbackRate is always used in playImmediatelyAtRate instead of constant values -- initially set by the library to _defaultPlaybackRate i.e. 1.0
playImmediatelyAtRate is added to resume method as well, not just play
Original Solution
This is the final code that helped solving the audio play delay for the OP:
in play & resume method
AVPlayer *player = playerInfo[#"player"];
float playbackRate = [playerInfo[#"rate"] floatValue];
if (#available(iOS 10.0, *)) {
[player playImmediatelyAtRate:playbackRate];
} else {
[player play];
}
So calling [player playImmediatelyAtRate:playImmediatelyAtRate:playbackRate] instead of [player play]; seems to fix the issue.
So far it hasn't been merged into the pub and is still an open the first incomplete PR has been merged, second PR as well.
Original comment:
There's this open pull request that should fix delay on iOS. that hasn't reached release version. Also there's this discussion on big initial lag.

Xamarin Forms Maps Geocoder Not Working on UWP Device

My app uses Xamarin.Forms.Maps to display a map and also for geocoding. The map is displayed on a separate page when the user navigates to it from the main page. I use the geocoder to reverse geocode the current location so that I have the address. This is done from various places other than the map page.
When I run the app on a device (even in debug mode) the geocoder works right away in iOS and Android, but does not work in UWP. After I navigate to the map page and display the map, then go back to a different page to use the geocoder it starts working.
I saw a thread about the map not working with release build so I added the following code:
var laRendererAssemblies = new[] { typeof(Xamarin.Forms.Maps.UWP.MapRenderer).GetTypeInfo().Assembly };
Xamarin.Forms.Forms.Init(e, laRendererAssemblies);
//Xamarin.Forms.Forms.Init(e);
Xamarin.FormsMaps.Init("MyBingMapsKey");
This has not helped the issue with the Xamarin.Forms.Maps.Geocoder. I also tried creating an instance of Xamarin.Forms.Maps.Map in my main page, but that did not help either. Is there a way to prime the map component so that the Geocoder will work on a device? (My test device is ARM, but it happens when I run on Local
Machine (Win 10) too)
Following is a snippet of the call to the Geocoder (which works fine once the user has navigated to the Map page and back - and it works fine in iOS and Android - and as such I don't believe it is a problem with the code, but here it is):
public static async Task<Plugin.Geolocator.Abstractions.Position> Geocode(string address)
{
try
{
var loGeocoder = new Xamarin.Forms.Maps.Geocoder();
System.Diagnostics.Debug.WriteLine("Get Lat/Lon");
var lcolPositions = await loGeocoder.GetPositionsForAddressAsync(address);
if (lcolPositions != null)
After doing some research and ensuring that your geodecode class being static wouldn't mess with the async/await pattern in the UWP build. I've come across a few references to this particular problem with the built in Forms.Map geodecoder elsewhere, not just for UWP it has also been noted for android‡.
I took some time to have a look at one of our current cross-platform applications that we have in the app stores, and according to our internal documentation we switched out both the xamarin.forms map, and the geodecoder for custom ones.
The plugin that we use for our cross-platform application is the 'GelocatorPlugin' created by james montemagno, and can be found here.
It can be added to your project as a Nuget package if you prefer, and the implementation of it is very similar to the default one, so there's very little code to change. The primary benefit is that the UWP element of the geodecode plugin has been modified to take into account windows advanced tracking scenarios (details found here).
It should be a lot more stable than the one your using, once installed you simply use it like so:
Reverse Geocoding
Based on a location that is passed in, thi swill grab a list of
addresses.
UWP requires a Bing Map Key, which you can acquire by reading this
piece of documentation.
try
{
var addresses = await locator.GetAddressesForPositionAsync (position, string mapKey = null);
var address = addresses.FirstOrDefault();
if(address == null)
Console.WriteLine ("No address found for position.");
else
Console.WriteLine ("Addresss: {0} {1} {2}", address.Thoroughfare, address.Locality, address.Country);
}
catch(Exception ex)
{
Debug.WriteLine("Unable to get address: " + ex);
}
‡ Links to similar problems - Link 1, Link 2
resolved after added following lines in APP.xaml.cs (UWP project)
Xamarin.FormsMaps.Init("bingmapkey");
Windows.Services.Maps.MapService.ServiceToken = "bingmapkey";

watchOS simple wakeup

Here is some watchOS code I have working on the Similator(Watch):
.....
let interval = 60.0
NSTimer.scheduledTimerWithTimeInterval(interval,
target: self,
selector: #selector(InterfaceController.timerDidEnd(_:)),
userInfo: nil, repeats: false)
.....
func timerDidEnd(timer:NSTimer) {
print("Time is over! Please wake up!")
}
From Xcode I run the app, the first part of the code above gets executed. Then I hit Command-Shift-H and the app goes in the background.
After one minute I see in the debugging console the message: Time is over! Please wake up!
All works as I expect. My question is:
What should I write inside the function timerDidEnd(), in order to have the app wake up from the background on the simulator, rather than just printing the current message in the debugger?
There's nothing you can write inside a timer action that will bring an app to the foreground. Only the user can resume an app.
If you think about it, it would confusing and disruptive for the user if an app could programmatically bring itself to the foreground whenever it wanted.
The only way to resume an app is by the user reacting to a notification. This is similar to what happens on the phone when the user taps notification actions from the home screen.

Altbeacon library not working on Android 5.0

Yesterday I got the update for Android 5.0 on my Nexus 4, and the altbeacon library stopped detecting beacons. It appears that didEnterRegion and didRangeBeaconsInRegion are not even getting called when monitoring and ranging, respectively.
Even the Locate app from Radius Networks behaves differently now, the values from beacons, once they are detected, doesn't get updated anymore and often it appears as if the beacons went out of range.
One thing I noted differently, is that now in the logcat it appears the following line "BluetoothLeScanner﹕ could not find callback wrapper". I went ahead and looked for that class and saw that it was introduced with Android L, but I don't know if that has something to do with it.
It's important to say that before the update I had been working with both the Locate app and the Reference Application without any trouble.
I don't know if this is a generalized problem or not, but if it happened to me I'm sure it could happen to someone else, so any help it would really be appreciated.
Thanks in advance!
UPDATE:
After failing at getting the library to work I decided to try the Android L branch of the library. What I did was that I plugged in the new library into the Reference App, but didn't work as expected either.
The Monitor Activity seems to be working ok by notifying when the device has entered a new region. However, the Ranging Activity doesn't report any beacons, although didRangeBeaconsInRegion is getting called, always report zero beacons. Curiously, when the activity is paused (switching momentarily to another app) the logcat shows that now didRangeBeaconsInRegion does get called with actual beacons.
I'm kind of stuck right now because I don't know how to get any of libraries working on Android L, so again, any help would really be appreciated.
I'm using the latest Altbeacon build on 5.0+ and have no problem with it. in fact, I never used it on kitkat so i'm not really sure i can help but here is my working code which listen to iBeacons.
implement beaconConsumer:
public class MainActivity implements BeaconConsumer
init BeaconManager
beaconManager = BeaconManager.getInstanceForApplication(this);
if (beaconManager != null && !beaconManager.isBound(this)) {
beaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout("m:0-3=4c000215,i:4-19,i:20-21,i:22-23,p:24-24"));
beaconManager.bind(this);
}
onConnect and start listner
#Override
public void onBeaconServiceConnect() {
beaconManager.setRangeNotifier(new RangeNotifier() {
#Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
if (beacons.size() > 0) {
Beacon firstBeacon = beacons.iterator().next();
}
}
});
beaconManager.startRangingBeaconsInRegion(new Region("com.example.app", null, null, null));
}
this code is working on 3 devices
Nexus 4 5.0.1
Samsung Galaxy s4 - Stock 5.0.1
Samsung Galaxy s4 - CM12 5.1.1
Old question, but maybe some people will try to find answer for higher systems where you have to ask for permissions. You need to ask for Manifest.permission.ACCESS_FINE_LOCATION before scanning. At least that was the problem I met. In my opinion lib should crash such cases at least and indicate the problem

Simulator quits unexpectedly giving error, Springboard failed to launch error: -3

I am trying to make a basic Application with a background Gradient, Navigation Bar and a logo on it. When Launched in a simulator an error pops up, saying Springboard failed to launch error: -3
I am Using the Following two in code in the ViewController:-
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationItem.title = #"Menu";
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(257, 3, 320, 44)];
UIImageView *image = [[UIImageView alloc]initWithImage:[UIImage imageNamed:#"ic_home.png"]];
[image setFrame:CGRectMake(0, 0, 59, 36)];
[view addSubview:image];
[self.navigationController.navigationBar addSubview:view];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
//Add gradient background
CAGradientLayer *bgLayer = [BackgroundLayer yellowGradient];
bgLayer.frame = self.view.bounds;
[self.view.layer insertSublayer:bgLayer atIndex:0];
}
not sure if this is the most technical answer but still...
Injectios is right, it's not your code (or at least my code never causes that) it's something to do with interface builder/putting files onto the simulator (from my experience).
Simply change the device that your building for and then switch back (for example, if developing for the 3.5" iPhone screen, click the 4" simulator and run, once it builds stop it and switch back to your target device) If you are using xcode 5 the list of devices is on the same toolbar as your Run and Stop buttons or go Product -> Destination
hope it helps
How about trying to delete the app from the simulator and restarting the simulator?
In my case, none of the above answers worked. So in my desperation I finally decided to revise all warnings and resolving them. It turned out that the root of the problem was that I was sending objects of wrong type to NSNumberFormatter and other classes/objects.
So in short: revise all your warnings and resolve all of them that mention pointer conversion problems.
Try reset the simulator
simulator -> reset contents and settings
It is worked for me

Resources