Skip to content

Instantly share code, notes, and snippets.

View jonalter's full-sized avatar

Jonathan Alter jonalter

View GitHub Profile
@jonalter
jonalter / app.js
Created September 22, 2011 16:30
Android: open url in browser via intent
var win = Ti.UI.createWindow({
backgroundColor : 'white'
});
win.open();
win.addEventListener('click', function(e) {
var intent = Ti.Android.createIntent({
action : Ti.Android.ACTION_VIEW,
data : "https://www.google.com/"
@jonalter
jonalter / app.js
Created September 22, 2011 00:05
iOS: disable snapshot from being taken when app backgrounded (for security reasons)
// by Blain Hamon
var win = Ti.UI.createWindow({
backgroundColor : 'white',
orientationModes : [Ti.UI.PORTRAIT]
});
win.open();
var label = Ti.UI.createLabel({
text : 'No app event received. Make call while running app',
textAlign : 'center',
@jonalter
jonalter / app.js
Created September 16, 2011 17:04
iOS: using videoPlayer to play remote content
var win = Ti.UI.createWindow({
backgroundColor : 'black',
orientationModes : [Ti.UI.PORTRAIT]
});
win.open();
var activeVideo = Titanium.Media.createVideoPlayer({
top : 0,
height : 200
});
win.add(activeVideo);
@jonalter
jonalter / app.js
Created September 15, 2011 22:43
iOS: open window on orientation change to landscape
// Must use TiSDK 1.8.0.v20110915133349 or newer
var tabGroup = Ti.UI.createTabGroup();
var win1 = Ti.UI.createWindow({
backgroundColor : 'white',
orientationModes : [Ti.UI.PORTRAIT]
});
var label1 = Ti.UI.createLabel({
text : 'I am a label'
});
win1.add(label1);
@jonalter
jonalter / app.js
Created September 14, 2011 16:01
BlackBerry: 1.7.0.RC2 appending complex rows to a tableView
var win = Ti.UI.createWindow();
var data = [];
for (var i = 0; i < 10; i++) {
data.push({title:'I am row text '+i });
}
var tableView = Ti.UI.createTableView({
data:data
});
tableView.setCreateCallback(function(e) {
@jonalter
jonalter / app.js
Created September 14, 2011 00:07
Android: open pdf with external pdf reader
// Must have a pdf reader app installed, maybe Adobe Reader, maybe something else
var win = Ti.UI.createWindow({
navBarHidden: true,
backgroundColor: 'blue'
});
win.open();
var button = Ti.UI.createButton({
title: 'Get PDF',
height: 50,
@jonalter
jonalter / app.js
Created September 13, 2011 16:57
Android: back button finish activities and exit app
Titanium.UI.setBackgroundColor('#000');
var windows = [];
//
// create base UI tab and root window
//
var win1 = Titanium.UI.createWindow({
title : 'Tab 1',
backgroundColor : '#fff',
exitOnClose : true
});
@jonalter
jonalter / tiapp.xml
Created September 8, 2011 20:36
Android: splash screen orientation set from tiapp.xml as of Sep 8 2011 11:25 r5be876f7 1.8.0
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<supports-screens android:anyDensity="false"/>
<application android:debuggable="true">
<activity android:alwaysRetainTaskState="true"
android:name=".TitestActivity"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="portrait"
android:theme="@style/Theme.Titanium">
<intent-filter>
@jonalter
jonalter / AndroidManifest.xml
Created September 8, 2011 17:31
Android: app and splash screen orientation with TiSDK 1.7.2 (must use custom AndroidManifest.xml)
<!-- add android:screenOrientation="portrait" to the main activity -->
<!-- This sets the splash screen -->
<activity android:name=".Test1Activity" android:screenOrientation="portrait"
android:label="Test1" android:theme="@style/Theme.Titanium"
android:configChanges="keyboardHidden|orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
@jonalter
jonalter / app.js
Created September 6, 2011 23:03
Android/iOS: copy folder with contents
var win = Ti.UI.createWindow({
backgroundColor : '#fff',
layout : 'vertical'
});
var testButton = Ti.UI.createButton({
title : "Copy Folder",
top : 20,
height : 50,
width : 250,