CodeNameOne LocationManager w/o GPS - codenameone

on Android device there are at least two options for geolocation:
GPS Satellites
WiFi & Mobile network location
if #1is checked then LocationManager.getCurrentLocationSync gets a proper location but what if only #2 is checked? On my device I simply get LocationManager.OUT_OF_SERVICE and thats it...
If I use LocationManager.getCurrentLocation when #1==false && #2==true I get null...
How can I read devices location based on WiFi & Mobile network location if GPS is turned off? ( or we are not outdoors for example )

As discussed here (3rd paragraph): http://www.codenameone.com/blog/easy-demos-flip-more.html
You can just define the build hint: android.includeGPlayServices=true
Which will implicitly switch the location API to use the Google Play Services hybrid location. This will use the GPS when available, but also many other sensor elements to produce a more accurate and battery efficient location.

Related

Can I get low level administrative areas from Here Maps?

I am trying to get and display low level admnisitrative areas such as neighbourhoods and disctrictcs via their polygon geometry. I am new to Here Map and GIS. I need this data just for Turkey.
I have read Here documentation, however I could not find a proper solution.
Thanks,,
It's possible to do with Platform Data Extension API. You can find description, examples, and details by link https://developer.here.com/documentation/platform-data/topics/what-is.html

Beacon UUID vs BeaconLayout

I am currently interested on how Beacons are working but I have some questions about it.
For iOS, I only see source code about Beacon UUID. But for Android, I only see "beacon layouts".
Are they the same? Can they be converted from one format to another?
Let's say I have this Beacon UUID:
636f3f8f-6491-4bee-95f7-d8cc64a863b5
Is this possible to get the beacon layout? But more specifically, what's a beacon layout exactly?
Thank you!
A beacon "layout" refers to the beacon format, specifically how the different fields are encoded into bytes needed to transmit the information inside Bluetooth LE advertising packets.
Some companies like Apple maintain their beacon formats as trade secrets, so they don't allow them to be published. Open source modules like the Android Beacon Library can't include ways to decode these beacons without publishing them. So they use a layout string, which is a way for a user to quickly and easily tell the library to decode that beacon.
Here's an example for the open-source AltBeacon format, which doesn't mind folks publishing it:
m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25
This means that a bluetooth LE beacon transmission matching this layout can be encoded/decoded like this:
Uses a manufacturer advertisement packet (m) with a two byte type code of 0xbeac in byte positions 2 and 3.
Has its first identifier (ID1 equivalent to iBeacon UUID) in bytes 4-19.
Has its second identifier (ID2 equivalent to iBeacon major) in bytes 20-21.
Has its third identifier (ID3 equivalent to iBeacon minor) in bytes 22-23.
The "p" and "d" parts of the layout refer to a "power" calibration value for distance estimates and a "data" field to store battery level and other manufacturer-specific information.
There are several other popular beacon formats like iBeacon and Eddystone. They have their own layout strings, which are both very similar to the one shown above.
While you can't use different beacon formats interchangeably, you can use all these beacon formats on both iOS and Android. Using a proprietary format on Android is just a matter of doing a Google search to find the right layout string for the beacon format, then configuring it like this:
BeaconManager.getBeaconParsers().add(
new BeaconParser().setBeaconLayout("<paste layout string here>"));

Getting ALSA card information

Once I have the card number (for example hw:0) how can I get information and descriptions from the ALSA library? I would like ot access the data similar to what I can find in /proc/asound/cards, for example:
0 [CinemaTM ]: USB-Audio - Microsoft® LifeCam Cinema(TM)
Microsoft Microsoft® LifeCam Cinema(TM) at usb-spear-ehci.0-1.1, high speed
As I have multiple such "cards" in my system, info like "CinemaTM", "USB-Audio" and "usb-ehci.0-1.1" help me to recognize what I need to open for capture.
In a separate question I found out how to iterate over all the cards and capture devices in the system, now I'd like to retrieve information about those - but my first impression with the ALSA API is that it's quite big and cumbersome for a beginner to understand how do to things.
Open the card's control device (which is also named hw:0, but doesn't have subdevices), and call snd_ctl_card_info().
snd_ctl_card_info_get_id(): CinemaTM
snd_ctl_card_info_get_driver(): USB-Audio
snd_ctl_card_info_get_name(): Microsoft® LifeCam Cinema(TM)
snd_ctl_card_info_get_longname(): Microsoft Microsoft® ... at usb-...

call recording on samsung phones(TAB 2)

I have been working on a call recorder app which is working fine on MEDIATEK(XOLO, Micromax etc) phones and Sony Xperia SP.
But Samsung is giving me nightmares. I have tried two samsung phones specifically Galaxy Tab2 and one I don't remember name of(let me know if you want to know).
Can anyone tell what settings are needed for Samsung. I have used these:
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(AudioSource.VOICE_COMMUNICATION);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
mRecorder.setOutputFile(outputFile);
I have tried almost all the combinations of every audio source VOICE_COMMUNICATION, VOICE_CALL, DEFAULT, MIC etc with every audio format and every audio encoder namely 3gpp, mp4, AMR_NB, AMR_WB etc.
I have read many forums regarding this problem but most of them are either unsatisfactory or too old to consider.

how to adapt my cocos2d-x app on iphone 5

My game is designed with cocos2d-x, the picture resource size is 320x480, which is adapted to iphone4, now I want my game adapt to iphone5, what should I do?, thanks!
It actually depends on your current cocos2d-x version and the resolutions you're planning to support. But basically if you're running the latest stable release (2.0.4) and you only want to support iPhone4 and iphone5 resolutions then you have to:
create the art for both resolutions (this is not mandatory but the graphics might be scaled too much and lose quality).
define at runtime the DesignResolutionSize and ContentScaleFactor based on the actual device's resolution
select the correct resource path
Here a simple example on how it can be implemented:
// Get the real screen size
CCDirector* pDirector = CCDirector::sharedDirector();
CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
pDirector->setOpenGLView(pEGLView);
// Set the design resolution. Please see the doc for the different modes
pEGLView->setDesignResolutionSize(480, 320, kResolutionNoBorder);
// Here you have to chose between width or height depending your game's design
if (frameSize.width > 480) {
// iphone5
pDirector->setContentScaleFactor(1136/480);
CCFileUtils::sharedFileUtils()->setResourceDirectory("hd");
} else {
// iphone4
pDirector->setContentScaleFactor(1);
CCFileUtils::sharedFileUtils()->setResourceDirectory("sd");
}
/// Now load the sprites....
If you're want to support more iOS/android resolutions please refer to the following links for fullscreen multi-resolution solutions offered by cocos2d-x:
http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Multi_resolution_support
http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Mechanism_of_loading_resources
Hope it helped.
Cocos2D-x 2.0.4+ have very easy solution for multi-resolution problem. ( either iDevices or Android devices.)
In fact you just need to set your DesignResolution and then just imagine your target device will has this resolution.
If target device really has this resolution ( or some other but with same ratio) cocos2d will handle to fix screen and your game looks same in all devices.
And when ratio of target device is different, you have many option ( as cocos2d language, policy) to manage that.
For example if you use Exact fit policy, cocos2d will force your game ( and design) to fit target device screen (without that black boarder).
Exact fit
The entire application is visible in the specified area without trying
to preserve the original aspect ratio. Distortion can occur, and the
application may appear stretched or compressed.
For more detail just take a look at this link : http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Multi_resolution_support

Resources