I'm creating a watch face for my Gear 2 Neo (using Tizen Wearable SDK), and I've spent hours looking (with no luck) for a way to determine if the bluetooth is enabled or not (and if possible if it's connected).
I've tried looking at the Tizen.SystemInfo API documents, but I can't find anything. I've even tried tizen.systeminfo.getPropertyValue(); with "BLUETOOTH" / "NETWORK" as the property name, but this doesn't work. It seems the Tizen.Bluetooth namespace isn't usable either.
I know there must be a way, as I have seen several watch faces out there that are able to get the status.
Is anyone able to help me out / point me in the right direction?
Edit:
Using tizen.bluetooth.getDefaultAdapter(); returns the following: "The application does not have the privilege to call this method"
Yes, it is possible.
To get the bluetooth status, you need to first get the defaultAdapter using following API
var blueAdapter = tizen.bluetooth.getDefaultAdapter();
console.log(blueAdapter); // To log the object
/* Output of above log
BluetoothAdapter
address: ""
name: ""
powered: false
visible: true
*/
if (blueAdapter.powered) {
// Bluetooth is on, you can off using
blueAdapter.setPowered(false);
} else {
// Bluetooth is off, you can switch on using
blueAdapter.setPowered(true);
}
Don't forget to add the privilege in config.xml of your app.
<tizen:privilege name="http://tizen.org/privilege/bluetooth.gap"/>
Note: Whenever you try to use platform, you need to provide the corresponding privilege in your apps config.xml file
Related
I've encountered a paywall and I'm trying to bypass it using javascript in the console. I did some research and found a few different approaches, one of which is changing the requestheader in order to make a given website believe that you got there through a twitter link (thus allowing you to view the content for free). The function I use aims to change the referer by listening to the onBeforeSendHeaders event as specified on https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/onBeforeSendHeaders. It looks like the following (NOTE: This function is typed and executed directly inside of the devtools console):
function setReferer(x){
x.requestHeaders = x.requestHeaders.filter(function(header){
if(header.name === 'Referer'){
return false
return true
)}
x.requestheaders.push(
{
"name: "Referer",
"value": "https://t.co/" //Twitter website
}
return {requestHeaders: x.requestHeaders};
}
//this example uses chrome browser
chrome.webRequest.onBeforeSendHeaders.addListener(setReferer,
{
urls: ["<all_urls>"],
types: ["main_frame"], },
["requestHeaders", "blocking", "extraHeaders"] //extraHeaders meant to bypass CORS protocol
);
Unfortunately upon refreshing the window, this approach gives me folllowing error:
GET <some_url> net:ERR_BLOCKED_BY_CLIENT
Behind this error is the URL to the source code of the article, which I was able to load and copy into word, so I got the article I was looking for anyway. However I wasn't able to view it inside of the browsers main frame. Note that I am doing this only for the purpose of polishing my coding skills. I am trying to get a better understanding of the more complicated facets of the HTTP protocol, especially the way headers get sent clientside and interpreted serverside. If anyone knows more about the subject or knows / has a resource that he or she wants to share, this would me greatly appreciated!
I have a web application that needs to open a destination in the native maps/navigation app on the device. On most Android devices this is google maps, and I can simply open a link that will open google maps with the directions to the passed destination (latitude, longitude coordinates). In the case of the TomTom Pro 8375, there seems to be no way of opening a destination in the navigator app from the browser.
We have tried this, amongst others, with the following:
tomtomgo://x-callback-url/navigate?destination=52.371183,4.892504
tomtomhome://geo:action=navigateto&lat=mylat&long=mylon&name=myname
Are there any known workarounds to achieve this?
I have received this as a response from the support but this applies only for kotlin or java.
Uri gmmIntentUri = Uri.parse("google.navigation:q=52.0000,12.0000");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
startActivity(mapIntent)
Is there a way that I can make this work in Javascript ?
I would really appreciate any suggestions!
Thank you!
Too Long to be a comment
Not overly familiar with webapps however we do have 3 apps with Webfleet. Sadly we use Java not Javascript. And the intent we use is
String uri = "geo:0,0?q=" + <destination>;
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(uri)));
Not overly helpful for you however we must support both phones and the Pro tablets.
The format below is the standard for JavaScript ?
intent:
HOST/URI-path // Optional host
#Intent;
package=[string];
action=[string];
category=[string];
component=[string];
scheme=[string];
end;
Which i would give you a rough estimate of:
intent://#Intent;action=android.intent.action.PICK;type=text/plain;S.android.intent.extra.TEXT=geo:0,0?q=52.0000,12.0000;end
I will also add the App that is Webfleets version of maps is called NavPadNavAppActivity, can try targeting that directly?
I am developing wallet to pay for e-commerce websites.
I need to add a check on the JS page if the user has installed chrome extension ( iwallet ) or not.
As said in a previous answer you can't do that. That's because if such a thing was actually present it will be a privacy issue for the chrome users.
Actually the chrome web store is the only website that has access to such a chrome api.
BUT - looking at the source code of the extension you can check what the extension is altering in you browser or even which messages its listening to.
In the Iwallet source code I found in content-script.js and inpage.js that it sets a special window object property window.IWalletJS and you can simply check if it exist to determine if the extension is installed or not.
As simple as:
if('IWalletJS' in window){
console.log("IWallet is installed", window.IWalletJS);
} else {
console.log("IWallet is not installed");
}
Take a look at the object attached to this property you can check if the user is logged, account name and more.
We have a web based jquery mobile app that records activity of a user. This app is long standing and in use at the moment, so re-writing the application is not an option unfortunatly.
The problem is that we are trying to get GPS location at certain points using the application.. But as it is running in an instance of chrome, the javascript will not record correctly when the phone is locked, or the chrome is minimised.
So to get around that we are writing an Ionic App with Cordova in order to get the GPS coordinates in the background, regardless of the state of the browser.
Currently, this is working great. The issue however is there are certain events in our javascript that require a specific 'type' associated to our GPS logging.
My question is: How do I actually hook onto this javascript event in CHROME from the GPS background ionic/cordova application.
What we have tried so far:
Finding the chrome localstorage via Ionic/Cordova and reading a value from that on a timer.
The issue with this is we can't find the location of the localstorage/cache.
From this question it says its here:
/data/data/com.android.chrome/cache
but we can't find/access it from our ionic app or file browser on the android
https://android.stackexchange.com/questions/85998/android-google-chrome-browser-cache-location
We have also looked for ways to hook the javascript events to fire something inside the other application but we are having no luck there either..
Apologies for the long post.. Its hard to explain. If you have any suggestions on alternative methods to do this kind of cross-application event firing from Chrome to Ionic/Cordova I would be greatly interested to hear your oppinion.
To fix this I created a 'stack' where I could push an object to an array that would be picked up by the cordova app using executeScript as follows:
In the inappbrowser site:
var stackName = stackN1
function addEventToStack(numid, type) {
var stackRow = { 'numb': numid, 'type': type};
var stack = localGet(stackName); //localstorage
if (!stack)
stack = StackInit();
stack.push(stackRow);
localStore(stackName, stack);
console.log('Added to stack ', stack);
return 'Row Added';
}
In the cordova application:
ref.executeScript(
{
code: 'localStorage.getItem("stackN1")'
},
function(rdObj) {
//Iterate and use rdObj here
}
This is repeat of
Apache Cordova GeoLocation not providing data
Following code returns an empty object:
function onDeviceReady(){
$cordovaGeolocation.getCurrentPosition({}).then(function(resp) {
console.log(resp);
$scope.geo.get = resp;
});
}
No errors or anything, just empty {}
Update 1
Works fine Samsung S3, but doesnt work on Nexus 4.
Update 2
LogCat shows the following line:
Caught security exception registering for location updates from the system.
You need to make sure that you added the corresponding location permissions.
If you are using iOS, it might ask you if you want to allow the app to determine your location.
If you are not sure, check the settings on both devices (android/ios) to check the requested permissions.