Skip to content

Instantly share code, notes, and snippets.

var win = Titanium.UI.currentWindow;
// the following example orientationModes values would set orientation to sensor portrait
win.orientationModes = [Ti.UI.PORTRAIT, Ti.UI.UPSIDE_PORTRAIT];
Ti.Media.showCamera({
success: function(e) {
// Open stream on blob.
var instream = Titanium.Stream.createStream({
mode: Titanium.Stream.MODE_READ,
source: e.media // e.media is a Blob
});
// Open an output stream for a file
// to hold the blob data.
var f =
@billdawson
billdawson / ex01-filestream-getfile.js
Created May 2, 2011 21:33
Examples - Stream blog post - FileStream
// Get the source file (this one is in Resources).
var infile = Titanium.Filesystem.getFile('emmy.jpg');
if (!infile.exists()) {
Ti.API.error("File not exists()");
return;
}
@billdawson
billdawson / ex01-bufferstream-create.js
Created May 2, 2011 11:14
Examples - Stream blog post - BufferStream
// Create the buffer & stream
var paragraph = Titanium.createBuffer({length: 1024});
var stream = Titanium.Stream.createStream({
mode: Titanium.Stream.MODE_WRITE, // There is also MODE_APPEND for writing
source: paragraph
});
@billdawson
billdawson / Felixge_Faves.md
Created April 7, 2011 10:49
Felix Geisendörfer's favorite utils, from his tweet storm of 07 April 2011

Felix Geisendörfer's (@felixge) faves, and what he said about them in his tweets of 07 April 2011:

I really wonder how I was able to use Terminal app all this time. iTerm2 is so much better, it hurts. (#)

If you find yourself arranging windows with your mouse on osx,

@billdawson
billdawson / record_and_share.js
Created February 22, 2011 21:32
Uses Titanium Mobile (Android) to make a voice recording and share it
var win = Ti.UI.createWindow({
title: 'Sound Recorder Test',
exitOnClose: true,
fullscreen: false,
backgroundColor: 'black'
});
// const value grabbed from
// http://developer.android.com/reference/android/provider/MediaStore.Audio.Media.html#RECORD_SOUND_ACTION
var RECORD_SOUND_ACTION = "android.provider.MediaStore.RECORD_SOUND";
@billdawson
billdawson / qrscan.js
Created February 22, 2011 18:21
QR Code Scan Example from Marshall's "Developing Native Android Apps with Titanium" Webinar
qrScanButton.addEventListener("click", function(e) {
var intent = Ti.Android.createIntent({
action: "com.google.zxing.client.android.SCAN"
});
intent.putExtra("SCAN_MODE", "QR_SCAN_MODE");
var activity = Ti.Android.currentActivity;
activity.startActivityForResult(intent, function(e) {
if (e.resultCode == Ti.Android.RESULT_OK) {
var contents = e.intent.getStringExtra("SCAN_RESULT");
var format = e.intent.getStringExtra("SCAN_RESULT_FORMAT");
@billdawson
billdawson / facebook_stream.js
Created February 15, 2011 20:02
Using Titanium.Facebook.requestWithGraphPath to publish to a Facebook Stream
function showFBResult(eventData) {
if (eventData.success) {
alert("Success! From FB: " + eventData.result);
} else {
if (eventData.error) {
alert(eventData.error);
} else {
alert("Unknown result");
}
}
@billdawson
billdawson / facebook_blog_post.md
Created February 15, 2011 16:48
Titanium 1.6.0's new Facebook module

Titanium Mobile 1.6.0 (currently in its release-candidate stage) contains an upgraded Facebook module which uses new authentication features on both Android and iOS as well as a new set of methods to retrieve and submit data. Our new API documentation won't get generated and put up on the site until 1.6.0 actually ships, but until then you can peruse the "raw" version of the docs in our Github repository. Some sample code is included therein as well as in the latest KitchenSink Facebook examples (search for "facebook" when you get there).

Authentication and Authorization

Our iOS and Android implementations both use Facebook's OAuth 2.0 authentication scheme, as Facebook has deprecated all other forms of authentication. Y

* KS general: opening tests (clicking on tv rows to open a window and show a test) -- seem slower for window to open?
* KS Platform - XHR - Error Callback test ??? try it with old
* KS Platform - XHR - Cookies test fails. But I've never tried it before. Try it with old.
* KS Platform - Platform Data locks up KS
* KS Phone - Sound - Remote Url. Doesn't play, and logcat shows a media exception
* KS Phone - Sound - Remote Streaming. Doesn't play and logcat shows a media exception
* KS Phone - Camera - Basic. Isn't it supposed to show the photo after you take it? (maybe not)
* KS Phone - Orientation. Allow Landscape -> Set Portrait -> rotate to landscape and it never goes back to landscape. This is different.
* KS Controls - Slider - Min/Max Range. Nothing shows up.