Blackberry localstorage - blackberry-webworks

I am developing a hybrid(phonegap and webworks) Blackberry application.I am using localstroage to save variable data.Please tell me how we can view the variable data and where blackberry application is stroing that data in the devie

Basic demo:
//Insert/Update
window.localStorage.setItem("foo", "bar"); //foo = bar
//Read
var value = window.localStorage.getItem("foo"); //bar
//Remove
window.localStorage.removeItem("foo"); //foo = undefined
//Remove all
window.localStorage.clear(); //length = 0
Here is an example I wrote that shows how to use the localStorage API on BlackBerry:
http://blackberry.github.io/WebWorks-Samples/kitchenSink/html/html5/storage.html
You can re-use this code in either a browser-based web page, a PhoneGap application or a WebWorks application.

Related

RE:Create a button which when pressed it replaces an existing object on the screen to another object in Smartface App Studio?

After seeing #catherinelagoon's post I also having difficulty in quite understand how to replace an object using a button so is it possible to create a button which when pressed it replaces an existing object on the screen to another object in Smartface App Studio?
I tried using the answer provided in the post however I couldn't understand it much due to I'm a beginner in using Smartface App Studio and coding itself.
Thankyou and sorry for any inconvienience
After you create an image you should add it to a Page so it can show on that page. So here is a simple code for creating and showing an image on the page.
var image = new SMF.UI.Image({
visible: false
});
Pages.Page1.add(image);
function Page1_TextButton1_OnPressed(e) {
image.visible = true;
}

How to add Google analytics to android app widget?

I've been struggle to had Google analytics to my app widget, without any success, The code works fine when using from Activity but not from the app widget.
Hi use this code inside your AppWidgetProvider onEnabled() method
Tracker t = ((MyApplication) context.getApplicationContext()).getTracker(
MyApplication.TrackerName.APP_TRACKER);
// Set screen name.
t.setScreenName(screenName);
// Send a screen view.
t.send(new HitBuilders.AppViewBuilder().build());

Is it possible to set a subject to the mail app in Windows 8 metro application, if I am using share contract and sharing files?

First of all, I am sharing the content from my windows 8 metro application to another app (for example Mailto app) so:
Now I am sharing files to mailto app using share contract and sharing files from my application,
I wanted to know if: -
Can I set the subject to the mailto app to which I am sharing files as an attachement to that mailto app, if so please let me know how can I do this?
If not, please let me know what is the work around?
As of now, it's not possible.
Windows 8 recently introduced a new API called protocol activation. With Protocol activation, you can launch other windows 8 apps from your application and pass in data. Microsoft worked on Maps app and you can now pass information to the Map app as shown here (URI Scheme for maps application) http://msdn.microsoft.com/en-us/library/windows/apps/jj635237.aspx
See a code walkthrough at http://blog.jerrynixon.com/2012/10/walkthrough-using-windows-8-custom.html
Now, i am sure very soon, you will see some custom parameters for Mail app that you can pass from your app using protocol activation.
Just my 2 cents
No, it isn't possible to do this at the moment.
I may not be understanding the question correctly but if all you want to do is have the ability to click the "Share" button on the Charms Bar, then select the "Mail" app and have the ability to populate the subject line shown when the "Mail" app's share fly-out is displayed then you can follow this approach:
private DataTransferManager dataTransferManager; //class member
// put the following code block wherever you need it:
// Register as a share source
if (this.dataTransferManager == null)
{
this.dataTransferManager = DataTransferManager.GetForCurrentView();
this.dataTransferManager.DataRequested -= this.OnDataRequested;
try
{
this.dataTransferManager.DataRequested += new TypedEventHandler<DataTransferManager, DataRequestedEventArgs>(this.OnDataRequested);
}
catch
{
};
}
private void OnDataRequested(DataTransferManager sender, DataRequestedEventArgs e)
{
DataRequest request = e.Request;
DataRequestDeferral deferal = request.GetDeferral();
try
{
// this property will set your subject line
// it will also be shown on the Share fly-out (right below the main
// heading that says 'Share'
request.Data.Properties.Title = GetCustomMailSubjectLine();
if (string.IsNullOrEmpty(request.Data.Properties.Title))
{
request.FailWithDisplayText("An operation failed. Please try again.");
}
else
{
// this will also be shown on the Share fly-out, right below the 'Title'
// property set above
request.Data.Properties.Description = GetMyAppsSharingDesciption();
// use request.Data.SetDataProvider() if your data needs to be asynchronously retrieved
// otherwise directly use request.Data.SetData() (or one of the other
//methods depending on what you need)
request.Data.SetDataProvider(StandardDataFormats.Html, RetrieveSharedData);
}
}
finally
{
deferal.Complete();
}
}
private async void RetrieveSharedData(DataProviderRequest request)
{
DataProviderDeferral deferal = request.GetDeferral();
try
{
// this will set your email's body
request.SetData(await GetCustomMailBodyAsync());
}
finally
{
deferal.Complete();
}
}

Open File Picker in snap view of Metro Style App

When I try to open file picker on snap view in Metro Style App, exception occurs and exception dialog box was shown. How to solve that problem? Is there any good idea? I want my app works properly even on snap view.
Before opening the file picker, you must try to leave the snapped mode.
Here is the code I use:
var ready = true;
if (ApplicationView.Value == ApplicationViewState.Snapped)
ready = ApplicationView.TryUnsnap();
if (!ready)
return;
The SDK samples available on msdn use the following snippet
// FilePicker APIs will not work if the application is in a snapped state.
// If an app wants to show a FilePicker while snapped, it must attempt to unsnap first
bool unsnapped = ((ApplicationView::Value != ApplicationViewState::Snapped) || ApplicationView::TryUnsnap());
if (!unsnapped)
{
// Unsnapping failed
}

google chrome app script ask to save as userAppPanel

I encounter a problem using UIApplication in google app script, but only on Chrome 18.0.1025.142 m, my application works fine on Firefox 3.6, and also on chrome 16.x.x.
I updated my chrome version to 19.0.1084.56 m. And the problem still occurs.
On Chrome 18.0.1025.142 m and 19.0.1084.56 m, I have the following behaviour:
A blank frame is displayed over my spreadsheet when I try to display the UI Application and I'm asked to perform a "Save As" operation for an object userAppPanel.
On Chrome 16.x.x or Firefox 3.6, I have a UI application with a panel, a textbox and a button.
Here is my application creation code:
// Create my application
var mydoc = SpreadsheetApp.getActiveSpreadsheet();
var myapp = UiApp.createApplication();
myapp.setTitle("Translation selector");
// create panels, text boxes and widgets
var mypanel = myapp.createVerticalPanel();
// Create input boxes and button
var textBoxA = myapp.createTextBox();
textBoxA.setName('Input search filter here').setId('SearchText');
var MyButton = myapp.createButton("Fill the tables");
mypanel.add(textBoxA);
mypanel.add(MyButton);
// create handler to respond to events
var clickHandler = myapp.createServerClickHandler("respondToSubmit");
MyButton.addClickHandler(clickHandler);
clickHandler.addCallbackElement(mypanel);
// assemble everything in app
myapp.add(mypanel);
//mydoc.show(myapp);
//return myapp;
var doc = SpreadsheetApp.getActive();
// show the app
doc.show(myapp);
}
I've a similar issue on Chrome 21.0.1180.89 for OSX. Working with a mail merge script which worked perfectly on a, similar up-to-date, chrome on Win8 just a few hours ago.
I'm pretty sure it's a security issue.
De-authorising the app (under account->security) and then reloading the script and re-authorising it helps. Not sure if it's on a per-browser level or something else..
Kindly Add this Code,
As per your question, It works on chrome.
function saveTextAsFile()
{
var textToWrite = document.getElementById('area').value;
var textFileAsBlob = new Blob([textToWrite], {type:'text/plain'});
var fileNameToSaveAs = "ecc.plist"/*Your file name*/;
var downloadLink = document.createElement("a");
downloadLink.download = fileNameToSaveAs;
downloadLink.innerHTML = "Download File";
if (window.webkitURL != null)
{
// Chrome allows the link to be clicked
// without actually adding it to the DOM.
downloadLink.href =
window.webkitURL.createObjectURL(textFileAsBlob);
}
else
{
// Firefox requires the link to be added to the DOM
// before it can be clicked.
downloadLink.href = window.URL.createObjectURL(textFileAsBlob);
downloadLink.onclick = destroyClickedElement;
downloadLink.style.display = "none";
document.body.appendChild(downloadLink);
}
downloadLink.click();
}
I have some users of a script I've developed, FormEmailer (available in the Script Gallery) that are also having this problem. But we were not able to nail the situation that generates this yet.
Is the spreadsheet you're testing yours? Or is it shared and you're not the owner? Do you have other scripts projects on this same spreadsheet? Are you the owner of all scripts?
(I think it's better if you change you edit your question and I my answer, instead of talking in the "limited" comments).
I have the same problem :
More details about this after a few tests. It seems it is due both to user triggering the script to execute, as well as characteristics of the trigger :
- if the function is called from a custom menu in a spreadsheet, everything works fine for everyone
- if function is called onOpen(), everything works fine for everyone
- if an installable onEdit or onOpen trigger has been set on the function, then everything works fine for the person who set it, and bad for others.
The last behavior is observed whether that person is owner or not.
Basically it seems the only times when it doesn't work well is when someone opens or edits a spreadsheet and the function is triggered by an installable trigger installed by somebody else.
This is a pain.