I want to access the Google map API in series 40 mobiles. I tried with using http connection but the map displayed statically. I want to load the map and moving the location in the map so that I have to use the Google map dynamically.
Please give an idea to do this.
The Google Maps API site does not contain a specific SDK for JavaME (or Series 40). The static Maps API can be used, but only for static images (no dynamic panning or zooming).
A good alternative is to use Nokia's HERE Maps. Its API is designed to work with JavaME and it offers a dynamic experience in Series 40 devices. Code Examples are also available and seem to be quite comprehensive, including panning, zoom and different map types.
PS: I'm not affiliated with Nokia in any way. I do use Here Maps on my Nokia quite frequently and I find it a good mapping solution.
EDIT: I got the Nokia HERE Maps working on a Java SDK1.1 emulator doing the following:
Download the Nokia Asha SDK 1.0. This (HUGE) download contains the most up to date libraries.
Create a new JavaME project using the Java SDK 1.1.
Sign in to HERE Maps and create an App Id and Token.
Add the following code in your MIDlet.
public class MapMIDlet extends MIDlet {
protected void startApp() throws MIDletStateChangeException {
ApplicationContext.getInstance().setAppID("API IP");
ApplicationContext.getInstance().setToken("API TOKEN");
Display display = Display.getDisplay(this);
MapCanvas mapCanvas = new MapCanvas(display){
public void onMapUpdateError(String description,
Throwable detail, boolean critical) {
// Error handling goes here.
}
public void onMapContentComplete() {
}
};
mapCanvas.getMapDisplay().setState(
new MapDisplayState(new GeoCoordinate(52.51, 13.4, 0), 10));
display.setCurrent(mapCanvas);
}
}
Reference the maps-core.jar located in "C:\Nokia\Devices\Nokia_Asha_SDK_1_0\plugins\maps api\lib".
Clean the project and run. This should display a basic pannable and zoomable map.
Related
I came back to Grails after [oh so many] years, and was happy to find the Async Controllers.
I wanted to experiment, so I have created a very simple domain class:
class ClientDevice implements AsyncEntity<ClientDevice> {
int width
int height
static constraints = {
}
}
And generated the default async controller and views.
Upon running the app using grails run-app, I've browsed to http://localhost:8080/clientDevice/index, and I'm getting HTTP Error 500.
I've looked at the logs - nothing.
The http://localhost:8080/clientDevice/create page works fine, but saving new clientDevice does not work.
I'm using the default development devDb H2 memory database.
This is happening on Grails 3.3.3 with Java 1.8_161
Any tips? I was really looking forward to trying the async stuff.
In my point of view it is a little confusing how to resolve dependecies in XLabs.
According to the sample project here is how I register the dependencies (simplified):
1) Platform dependent in MainActivity.cs:
private void SetIoc()
{
var resolverContainer = new SimpleContainer();
resolverContainer.Register<IMediaPicker, MediaPicker>();
Resolver.SetResolver(resolverContainer.GetResolver());
}
2) Platform independent in App.cs:
public App ()
{
DependencyService.Register<ISettings, Settings>();
DependencyService.Register<FooViewModel>();
}
Now, it is rather difficult to resolve the dependencies. The expected way would be resolving by constructor injection, which ends in exceptions:
public FooViewModel(IMediaPicker picker) {} // Exception
public FooViewModel(ISettings settings) {} // Exception
Another, but not optimum way is to resolve by DependencyService / Resover. But here I need to know which I have to use:
public FooViewModel()
{
_picker = Resolver.Resolve<IMediaPicker>();
_settings = DependencyService.Get<ISettings>();
}
This all seems not optimal for me (e.g. for unit testing). Is there a way to unify the whole resolving process, in the best case via constructor?
Theres not reason not to place your implementations in your constructors and pass them down the stack. Define your Interface in your PCL implement it in your Android or IOS specific projects and pass it into the PCL on you APP constructor. It will work fine.
The problem arises though when you start to have more then about 3 interfaces you want to be platform specific. When the constructor of your App starts to get longer then the constructor of your MainPage you might start looking for other options.
DependencyService is a simple low ball container that Xamarin Forms offers you. You can use it for platform specific or within the PCL. It takes simple forms. You register your interface and the implementation you want to use for it and then you can retrieve a new instance of the implementation anywhere in your PCL or platform specific code. It's simple to use.
Register with
DependencyService.Register<IMyInterface,MyClass> ();
Get an instance of MyClass just call
IMyInterface me = DependencyService.Get<IMyInterface> ();
and me will be a brand new baby MyClass.
You could also call it in your Platform specific code.
DependencyService.Register<IMyInterface,MyAndroidVersion> ();
and then in your PCL
IMyInterface me = DependencyService.Get<IMyInterface> ();
would give you MyAndroid version.
XLabs Container works the same way just gives you more options. You don't have to use both in fact I'd recommend against it. Pick one of the three options and use it. If you start with the first two you could eventually outgrow them so XLabs might be the best choice.
Personally I use the SimpleIOC container from MVVMLight. But they are all basically the same thing just with a few different bells and whistles.
Autofac 3.0 will have a MultitenantIntegration support and its preview release is out now. To try it out, I created an ASP.NET Web API application with the following configuration:
public class Global : System.Web.HttpApplication {
protected void Application_Start(object sender, EventArgs e) {
var config = GlobalConfiguration.Configuration;
config.Routes.MapHttpRoute("Default", "api/{controller}");
RegisterDependencies(config);
}
public void RegisterDependencies(HttpConfiguration config) {
var builder = new ContainerBuilder();
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
// creates a logger instance per tenant
builder.RegisterType<LoggerService>().As<ILoggerService>().InstancePerTenant();
var mtc = new MultitenantContainer(
new RequestParameterTenantIdentificationStrategy("tenant"),
builder.Build());
config.DependencyResolver = new AutofacWebApiDependencyResolver(mtc);
}
}
It gets the job done and creates a LoggerService instance as ILoggerService per tenant. I have two problems at this stage which I wasn't able to solve:
I used out of the box provided RequestParameterTenantIdentificationStrategy here as the TenantIdentificationStrategy just for this demo application. I am able to create my custom TenantIdentificationStrategy by implementing ITenantIdentificationStrategy interface. However, TryIdentifyTenant method of the ITenantIdentificationStrategy makes you rely on a static instance such as HttpContext.Current which is something that I don't want in an ASP.NET Web API environment as I want my API to be hosting agnostic (I know that I can delegate this work to the hosting layer but I would rather not to). Is there another way to achieve this in a way that I won't rely on a static instance?
I also have a chance to register tenant specific instance as below:
mtc.ConfigureTenant("tenant1", cb => cb.RegisterType<Foo>()
.As<IFoo>().InstancePerApiRequest());
However, one of my situations requires me to pass the tenant name through the constructor parameter and I would love to have something like below:
mtc.ConfigureTenant((cb, tenantName) => cb.RegisterType<Foo>()
.As<IFoo>()
.WithParameter("tenantName", tenantName)
.InstancePerApiRequest());
Currently there is no such an API. Is there another way to achieve this or this kind of requirement doesn't make any sense?
Multitenant support has been available for a long time, it's just that 3.0 is the first time we've had a NuGet package for it. :)
The RequestParameterTenantIdentificationStrategy is, as documented, just a very simple example showing one possible (and not recommended) way to identify tenant. You will have to choose for yourself how to identify your tenant based on the operating context. It could be from a web.config value, an environment variable, or some other thing in the current environment. If you don't want to use HttpContext.Current, don't. It's up to you to pick where you get that info from.
(A note on the RPTIStrategy - the part that isn't recommended is using a querystring or request parameter as the tenant ID mechanism. I use HttpContext in my production apps and it works fine. There's only so much you can abstract out before you have to actually touch the bare metal.)
There is no way out of the box to provide the lambda registration syntax you're asking for, primarily because tenant is not passed through the resolution process. The resolution process is:
Identify the tenant with the strategy.
Find the tenant's configured lifetime scope.
Use standard Autofac Resolve style syntax.
It's intentionally simple and analogous to the existing operations. At the time of resolve, the sub-lifetime-scope belonging to the tenant is tagged with the tenant ID but the resolution operation doesn't know about the tenant ID... so the lambda wouldn't work (and probably won't anytime soon because it'd change the fundamental internals of the way Autofac works if it did).
To accomplish what you're looking for, you can use a combination of the InstancePerTenant extension when registering...
var builder = new ContainerBuilder();
builder.RegisterType<Foo>().As<IFoo>().InstancePerTenant();
...and registering the ITenantIdentificationStrategy as a dependency in your container.
builder.Register(myIdStrategy).As<ITenantIdentificationStrategy>();
Then make your class take an ITenantIdentificationStrategy rather than the tenant ID directly. Use the strategy to get the tenant ID instead.
If you REALLY want to get fancy, you could register a keyed lambda that resolves the ID strategy, then gets the tenant ID. Then you could add a parameter registration to the object like you did but using a keyed service. (I'm going to go by memory now, so you'll have to double-check my syntax here, but it'll be something like this...)
builder.Register(c =>
{ var s = c.Resolve<ITenantIdentificationStrategy>();
object id;
s.TryIdentifyTenant(out id);
return id;
}).Keyed<object>("tenantId");
builder.RegisterType<Foo>()
.As<IFoo>()
.WithParameter(
(pi, c) => pi.Name == "tenantId",
(pi, c) => c.ResolveKeyed<object>("tenantId"))
.InstancePerApiRequest();
Again, you'll want to double-check me on that, but I'm pretty sure that (or a minor variation) should work to get you what you want.
I'm in the middle of switching from Flex Builder 3 to Flash Builder 4, and one of the problems I have run into is that support for web services in 4 is substantially different. In both IDE's I am able to import a WSDL for my web service and it will generate the appropriate client classes for communicating with the service. The generated code in each is different.
In my Flex3 code I was able to access the endpointURI property of the mx.rpc.soap.AbstractWebService, but in the Flex4 code that is generated, the new class extends com.adobe.fiber.services.wrapper.WebServiceWrapper which does not have the endpointURI property.
My project has mulitple game servers and the player picks which server they want to play on. In the past if the player wanted server 1, I would set the endpoint URI to http://game1.server.com/service.asmx, and like wise if they wanted server 2 I would set the endpoint to http://game2.server.com/service.asmx.
What am I looking for to accomplish this in Flash Builder 4?
Short Answer:
var s:ClassThatExtendsWebServiceWrapper = new ClassThatExtendsWebServiceWrapper;
s.serviceControl.endpointURI = 'http://service.com/service.asmx';
Long Answer:
Well I finally found a solution. Adobe seems to have made this much harder than it should have been.
Web Service classes that are generated by Flash Builder 4 extend the com.adobe.fiber.services.wrapper.WebServiceWrapper. WebServiceWrapper has a property called serviceControl that can be used to control the service. The problem is that not all the members of serviceControl are accessible at the application code level. Lets assume that I have a web service called GameService. When I use the data tool to connect to the web service by providing a WSDL, Flash Builder will create two classes for me automcatically.
internal class _Super_GameService extends
com.adobe.fiber.services.wrapper.WebServiceWrapper
{ ... }
public class GameService extends _Super_GameService
{}
_Super_GameService contains all the automatically generated code to make calls to the web service. GameService contains no code itself, but unlike _Super_GameService, it is public. The idea here is that any enhancements that we need to make can be made to GameService, then later on if we need to update, _Super_GameService can be regenerated, but out changes to GameService will not be overwritten by the code generation tool.
Now this leads us to usage of these generated classes. Typically all I should have to do is create an instance of GameService and call a method on it. In this example DoSomethingAwesome is a method available on the web service.
var gs:GameService = new GameService();
var token:AsyncToken = gs.DoSomethingAwesome();
Now this will call the service using the URI of the service specified in the WSDL file. In my situation I wanted GameService to connect to a different URI. This should have been simple, but things fell apart.
My first problem was that viewing the documentation on WebServiceWrapper (http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/com/adobe/fiber/services/wrapper/WebServiceWrapper.html) did not render properly in Firefox. So when I was reading the documentation I wasn't getting the full picture. This really needs to be fixed by Adobe.
Viewing the documentation in another browser helped me find out about the serviceControl property of WebServiceWrapper. serviceControl is declared as a mx.rpc.soap.AbstractWebService. AbstractWebService does have an endpointURI property which makes the following code valid.
var gs:GameService = new GameService();
gs.serviceControl.endpointURI = 'http://game1.service.com/GameService.asmx';
The other problem I had is that for some reason the endpointURI property of serviceControl does not appear in the Intellisense context menu. So since I didn't see serviceControl in the online documentation at first, and I didn't see endpointURI in intellisense, I didn't realize the property was there to be set.
If you look at the source for AbstractWebserivce, (http://opensource.adobe.com/svn/opensource/flex/sdk/trunk/frameworks/projects/rpc/src/mx/rpc/soap/AbstractWebService.as) there doesn't seem to be an Exclude tag to explain why endpointURI does not appear in the Intellisense context menu. So I don't know what is going on there.
You should be able to override the endpointURI on the WebService. But I'm not sure where to do that with the generated code since I use <s:WebService/>.
This is the only way I could get it to work, in the generated stub for your service:
import com.adobe.fiber.core.model_internal;
Also:
/**
* Override super.init() to provide any initialization customization if needed.
*/
protected override function preInitializeService():void
{
_needWSDLLoad = false; // to prevent loading the default WSDL
super.preInitializeService();
// Initialization customization goes here
wsdl = "http://localhost/yourservice?wsdl";
_needWSDLLoad = true;
model_internal::loadWSDLIfNecessary();
I am working on flex dasboards and charting stuff. Till now I have build them for static data only now I want to upgrade them to work for real time data where new data is continuosly sent to client (swf file) from server and it updates the same.
I am using Jruby with RoR.
Please share the links for any similar implementation in RoR-Flex architecture. Or if you have some suggestions to share I will really appreciate.
Thanks friends.
Try this :
http://flexonrails.net/?p=105
You need a server push architecture which can support live data streaming.
Just create a private variable with getters and setters that you continually update. This variable will be the dataProvider for your charts.
[Bindable]
_dataProvider:ArrayCollection = new ArrayCollection();
public function get dataProvider() : ArrayCollection {
return _dataProvider;
}
public function set dataProvider (value:ArrayCollection) : void {
_dataProvider = value;
_dataProvider.refresh();
}
Then set your chart to use _dataProvider as its dataProvider.
look into livecycle data services...or even maybe blazeDS,
here's a pretty good sample app from the adobe website that has data being pushed real time.
http://examples.adobe.com/flex3/devnet/networkmonitor/main.html
Check out the Real-Time Dashboard sample in Tour de Flex.
I've used WebORB for a project involving Twitter and Flash, and it works great. It allows the persistence of primitive types (dictionaries/hashes/objects, arrays, etc) across the wire. Check out the overview here:
http://www.themidnightcoders.com/products/weborb-for-rails/overview.html
Or take a peek at the quick start guide here:
http://www.themidnightcoders.com/products/weborb-for-rails/quick-start-guide.html