The only documentation of Adobe AIR's openWithDefaultApplication() function I can find is a tutorial for it in the Flex SDK. Is Flex required to use this function?
Calling it via JavaScript results in:
TypeError: Value undefined does not allow function calls.
The code I'm using:
var poster = air.File.applicationDirectory.resolvePath('posters/CR-1/CR-1.pps');
air.trace(poster); // [object File]
poster.openWithDefaultApplication();
The application file is likely set to....
<application xmlns="http://ns.adobe.com/air/application/1.5">
You must change it to
<application xmlns="http://ns.adobe.com/air/application/2.0">
for the 2.0 + functionality to work....
Related
I'm writing a vscode extension where I'm hoping to squeeze more dynamic functionality out of markdown preview. Effectively the problem I'm trying to solve is:
In markdown preview, there's a checkbox
When user clicks the checkbox in markdown preview, send a message/event to the vscode extension runtime
Vscode extension can listen for this message/event and store the action in local storage
Checkbox state is saved - and subsequent renders of the markdown preview can use this action
Ideally, I'd like to do this while keeping the default markdown preview security (https://code.visualstudio.com/Docs/languages/markdown#_strict). After all, I don't need the extension to or markdown preview script to talk to a remote server - I just want them to be able to talk to one another.
Problem as code
To write the problem as sudo code, I want my markdown preview script to contain something like:
const button = ... // get button element
button.addEventListener('click', () => {
... /*
* Send a message to the vscode extension. Something like:
* `vscode.postMessage('vscode.my-extension.preview-action' + value)`
* (which I can't get to work, I'll discuss why)
*/
});
where then my extension can listen for messages like 'vscode.my-extension.preview-action'.
What I've Tried Already
I have tried acquireVsCodeApi() but because the markdown extension already does that, I can't do it again in the subsequent loaded script. I've also tried registering a uri handler but as far as I can try out the preview script still needs to fetch to that uri, which is still blocked by the default markdown security settings.
Perhaps markdown preview scripts are not the place to do this kind of thing, but I just wanted to leverage as much as possible that's already there with the vscode markdown extension. I want to supplement markdown but not replace it, the functionality I want to add is just icing on markdown documentation.
I've read https://code.visualstudio.com/api/extension-guides/markdown-extension#adding-advanced-functionality-with-scripts and it doesn't tell me much about markdown extension scripts capabilities and limitations.
Thanks to #LexLi I looked at some of the source code in the markdown extension and was able to come up with an ugly hack to make this work in preview scripts. Markdown allows normal clicks. And vscode extensions can handle normal clicks. I've paraphrased the code so there could be small syntax errors.
In the extension I did this:
vscode.window.registerUriHandler({
handleUri(uri: vscode.Uri): vscode.ProviderResult<void> {
console.log(`EXTENSION GOT URL: ${uri.toString()}`);
},
});
Then I made sure my extension/preview script put this in the document
<!-- in the preview script I place a button like this -->
<!-- it even works with hidden :) so I can do more app customization -->
<a
hidden
id="my-extension-messager"
href="vscode://publisher-id.my-extension"
>
cant see me but I'm there
</a>
Then my preview script I can even set href before faking a click:
const aMessager = document.querySelector("#my-extension-messager");
console.log('client is setting attribute and clicking...')
aMessager.setAttribute('href', 'vscode://publisher-id.my-extension?action=do-something');
aMessager.click();
console.log('client clicked');
Logs I saw (trimmed/tweaked from my particular extension to match the contrived example):
client is setting attribute and clicking...
client clicked
[Extension Host] EXTENSION GOT URL: vscode://publisher-id.my-extension?action%3Ddo-something
It's a hack but I can do a lot with this. Within the URL I can encode data back to the extension and kind of pass whatever I want (as long as data is relatively small).
I have been facing an issue regarding Geolocation in iOS/Android app. I am using Titanium Js and have upgraded Ti v7.5.0 to v8.3.1. I checked my legacy code and came to know that this below function
Titanium.Geolocation.setFrequency()
creating a problem. It seems like this function gets deprecated.
this.locationFrequency = 100;
Geolocate.prototype.getCurrentPosition = function(callback){
var self = this;
// initialize the callback
this.locationReceivedCallback = callback;
// Set this so we get updates rapidly
Titanium.Geolocation.setFrequency(this.locationFrequency)
// Register for the actual event
Titanium.Geolocation.addEventListener('location', someCallBackFunc);
};
Now, I need help to understand what actually this Titanium.Geolocation.setFrequency() does. Is there any alternate way to achieve the same in latest version of Ti?
Since it is open source you can look at the github repo:
https://github.com/appcelerator/titanium_mobile/blob/7_5_X/android/modules/geolocation/src/java/ti/modules/titanium/geolocation/GeolocationModule.java#L469
and check the official documentation at frequency
https://docs.appcelerator.com/platform/latest/?print=/api/Titanium.Geolocation#property-frequency and use the recommendation there.
I am trying to write a custom camera application in android.
For that I need to open the camera application.
for that i am tring following code..
Camera camera = Camera.open();
but is showing error like
method open undefined for type Camera
i did as suggested here http://developer.android.com/reference/android/hardware/Camera.html#open(int)
any suggestion..
Thanks,
Ravindra Gupta
You most likely imported the wrong camera class at the top of your source file, which is android.graphics.Camera.
You need android.hardware.Camera instead.
Thanks
I think you have not added the camera permission. See below - you need to add this in your manifest;
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
Check your imports. I had a similar problem and the Camera object Eclipse chose for me was: import android.graphics.Camera; instead it should be: import android.hardware.Camera;
If none of the above work:
check to see if you are requesting camera permission manually. Newer Android permissions (API > 23) are set at runtime, not install time.
See: https://developer.android.com/training/permissions/requesting.html
Please create a variable like this:
android.hardware.Camera camera ;
and then try open method :
camera = camera.open();
// this is working on my android studio
I have Faced the same problem till i reached that older versions of android will work properly until Android Marshmallow so it needs a runtime permission in order to proceed and show the camera ...
you can read about it in this link https://developer.android.com/training/permissions/requesting.html
for me i used a 3rd party library to do all this stuff for me from this link and all resolved ..
https://android-arsenal.com/details/1/2804
Hope it helps
I have faced a lot of issues while using integrating camera native/camera2 api. The code was bulky. To avoid complexity and compatibility issues google provide new CameraX api in new android jetpack library. See the google provided documentation https://developer.android.com/training/camerax. There is also a Kotlin based library i found on github https://github.com/robertlevonyan/CameraXDemo. You can get more clearity with less code.
Waged right!!!
A permission request is required. And I found the right code. he works.
I advise you to look at this article to initially connect the camera:
https://habr.com/ru/post/112272/
enter image description here
if(ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(MainActivity.this, new String[] {Manifest.permission.CAMERA}, 15); }
I`m getting js error, after loading below function,
Ext.onReady(function(){
aFunc123([{header:'ss',Fn:'aFunc1(1)'}],"",undefined,{showCheck:true})
})
After coming out of "aFunc123" function,extjs immediatly calls "onDocumentReady" function, problem is, passed arguments are undefined,and also I dont know how it`s getting called.Please check out, for this problem I`m getting error like `"Unable to get property 'apply' of undefined or null reference"`.
Please suggest me what wrong I`m doing here.
I`m using ExtJS 3.2,IE10.
Thanks in advance.
Ext 3.4.1a was released recently to add IE10 support. You can download it from the Ext website. Otherwise, older versions don't have support for IE10.
I have a simple plugin that just does something like this:
chrome.extension.onMessage.addListener(function(msg, _, sendResponse) {
log("Got message from background page: " + msg);
});
unfortunately when my panel is loaded the following error is shown:
TypeError: Cannot call method 'addListener' of undefined
and according to my tests chrome.extension.onMessage is undefined
According to this page http://code.google.com/chrome/extensions/messaging.html I should be able to access this chrome API from my page so it has to be something small that I am missing here...
Please note methods chrome.extension.onRequest and chrome.extension.sendRequest, as originally suggested in this answer, are deprecated as of Chrome 33.
You should use
chrome.extension.onRequest
instead of
chrome.extension.onMessage
And in background page or any other extension scripts:
chrome.tabs.sendRequest
instead of
chrome.tabs.sendMessage
( the documentation is outdated... alert to google team ;) )
Just a side note: the Yandex browser (mostly oriented for Russians) which is also based on Chromium still (as of 11/10/2012, ver. 1.0) has the .*Request methods instead of .*Message. Many thanks to Ciprian Amariei for the tip, it saved me a lot of time!
PS: This should actually be a comment to Ciprian Amariei's answer but unfortunately I can't leave comments yet and I though this information could be very helpful to those who develop extensions for Yandex browser.
Make sure you're using the latest Google Chrome version. Older versions don't have the chrome.extension.onMessage API.