Can I use Zebble for only UI and use Xamarin for everything else - xamarin-zebble

I would like to use Zebble only for producing UI and all other things I would like to use Xamarin apis/custom http apis/local db or whatever it may be. Basically a UI project with zebble and other things will be in PCLs.
Will it be compatible? Could you please advice?

Yes you can. There is nothing in Zebble that prevents you from using the native APIs directly.
For custom http calls, I recommend using the HttpClient class which is by default available in all 3 platforms of a newly created Zebble project.
For Device APIs, you can of course use the standard API classes of each platform, but to save time and achieve 100% code reuse I strongly recommend using the http://zebble.net/docs/device-api. For example if you want o use the lamp (aka flash, led or torch) you can very easily implement that on all platforms with very little code code:
// Determines if a lamp feature is available on the device.
if (await Device.Torch.IsAvailable()) { ... }
// This will switch the lamp on.
await Device.Torch.TurnOn();
// This will switch the lamp off.
await Device.Torch.TurnOff();

Related

Is it possible and advisable to use Antora's UI customization to generate a Google Sheets-like help widget?

I would like to use Antora to create a Google Sheet-like widget on a web app written in React. I wanted to see if the recommended approach is to write this in React or to utilize Antora's UI customization capabilities.
I have not tried to prototype either of these approaches yet.
Antora is a static site generator (SSG), so that's overkill for your use case and would add unnecessary complexity.
Antora documentation is authored in Asciidoc. Instead of using Antora, you can use asciidoctor to transform Asciidoc->HTML. There is asciidoctor.js, which is transpiled from the asciidoctor Ruby source, and that would be a good fit for a React app.

How to force flutter to use wifi rather than 4G?

My app makes local network calls. Is there a way, with flutter/dart, to force http.get() over WiFi (even if internet is not available) rather than 3G/4G?
Core Flutter framework has not that feature yet(and won't have at least for a long time imo).
When it comes hardware related things, you can almost say that native code is only way to go. Good thing is there many official & third party packages that already done the job for you.
For example this package is popular one for connection related features: https://pub.dev/packages/connectivity
This is the example code you need:
import 'package:connectivity/connectivity.dart';
var connectivityResult = await (Connectivity().checkConnectivity());
if (connectivityResult == ConnectivityResult.mobile) {
// I am connected to a mobile network.
} else if (connectivityResult == ConnectivityResult.wifi) {
// I am connected to a wifi network.
}
There is a plugin that helps you to solve the problem.
You need to add this https://github.com/alternadom/WiFiFlutter plugin to your project like so:
wifi_iot:
git: https://github.com/alternadom/WiFiFlutter.git
and then to force wifi usage you call
WiFiForIoTPlugin.forceWifiUsage(true);
I made it safe and added a platform check
import 'dart:io' show Platform;
if(Platform.isAndroid) {
WiFiForIoTPlugin.forceWifiUsage(true);
}
The downside is, that at the first time you do this in your app, the user will be redirected to allow the app to change system settings (and from there the "back" navigation button doesn't work at the moment).
This is not currently possible with flutter. The only way is to use platform native code via paltform-channels.
https://flutter.dev/docs/development/platform-integration/platform-channels

Visual Studio Mac Streaming BasicHttpBinding not working

I have a cross platform app that runs on Windows and Mac. It is using WCF on .NET 4.5.2. In the BasicHttpBinding configuration in the settings file I am setting the transferMode="Streaming". We are downloading large files using this service.
On Windows everything works fine. The WCF method call returns right away and then when I read from the Stream member of the MessageContract object the file is streamed as excepted.
When I run the same app in Visual Studio for Mac I have 2 problems. The first problem is that the transfer mode in the binding is Buffered instead of Streamed.
I fix that by changing it in code after creating the channel. Here is the code I use to do it. Maybe this is the problem:
private IDataService CreateClient()
{
Channel = new ChannelFactory<IDataService>(BindingId);
var binding = Channel.Endpoint.Binding as BasicHttpBinding;
binding.TransferMode = TransferMode.Streamed;
Channel = new ChannelFactory<IDataService> (binding, Channel.Endpoint.Address);
var client = Channel.CreateChannel();
return client;
}
Notice how I read the binding, change the transfer mode and then create a new channel using the new binding. This seemed to be the best way to get the same settings from the settings file, but switch the transfer mode.
When the download method call is made I am able to see in the debugger where the transfer mode on the binding is Streamed, where before it was Buffered.
The problem I have at this point is that even though the transfer mode is Streamed, the download WCF method call doesn't return until the whole file is downloaded. It is acting like it is still in Buffered mode.
Any ideas how to fix this?
It looks like the streaming setting doesn't work in the Xamarin implementation of .net 4.5.2 that we are using. Not sure if it works in later versions or not.
I ended up adding a REST api just for downloading large files...

How to pass data in body of a HttpConnection in blackberry

Actually I want to pass data in body of a httpconnection.
Using apache httpclient library in blackberry, integrated jar file in my project but getting compilation error while running my project.
Kindly updated me on the same.
I have not tried using Apache HttpClient lib in a BB project before, because I did not for a moment think it would work...
In short, you need the code to be compatible with J2ME, and compilable using the RIM tool chain. And then we get into other problems....
First of, be aware that networking in BlackBerry is NOT as straightforward as one might wish.
Have a look at this video for the back ground theory: Networking Transports on the BB Platform
Ok, then for some code (I assume here you already went through the trouble of obtaining an HttpConnection):
byte [] bodyBytes = getBodyBytesFromSomewhere();
OutputStream out = httpConnection.openOutputStream();
out.write(bodyBytes);
out.flush();
out.close();//If you are done, which I'm guessing you are
The above code is of course very simplistic, and completely ignores all the many, many errors that will occur during network IO.
I would suggest you also look at this API,this forum entry,and this one. OS6.0 also introduced a new HTTP Connection API - can't find a link for that right now (sorry!)

BrowserField Blackberry

We are writing a blackberry applciation which has social media integration, we are able to invoke the browser using BrowserSession and call the facebook link with the sharer link
http://m.facebook.com/?sharer= , this works perfectly fine , however we have encountered a new method where we could embed the HTML page inside the application screen using Browserfield , unfortunately this library is available only post 5.0
I have some links which indicate that we may be able to use pre-processing directive to detect the version and build the library accordingly , to be specific
ifdef version_5.0_and_above
/* Use BrowserField */
else
/Invoke Browser/
Can someone shed some light on how this can be achieved?
Thanks for all the help in advance
This RIM doc explains how to use preprocessing.
Basically you'll have to create 2 projects with almost the same code. The difference is just in the code that implements your browser actions. For one project you assign a label (preprocessing statement) "OS_5_OR_ABOVE" and use the API 5+, the other project may be left unlabeled (since there are only 2 projects) and it should use API 4.7.0 (or the lowest API your app supports).
A sample code with preprocessing would be:
//#preprocess
package ...
import ...
public MyClass {
public MyClass() {
//#ifdef OS_5_OR_ABOVE
/* this is only called for the OS_5_OR_ABOVE project */
//#else
/* this is only called for the second project */
//#endif
}
}
Definitelly you'll need to compile each project using different JDE (for instance, JDE 5.0 and JDE 4.7.0).
Note you can also use preprocessing for conditional imports. However I'd not recommend this, since it is very easy to break the code in Eclipse on code auto-format/cleanup action.

Resources