Skip to content

Instantly share code, notes, and snippets.

@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 / android_scons_speedups.md
Created January 11, 2012 21:41
Speeding up Titanium Build

Speeding up Titanium Mobile Build

(The command examples assume OS X).

Just about everything that happens when you enter scons is for Android. So anything you can do to speed up the Android part of our build will be useful.

  • Android NDK r7 can use ccache. We get huge improvements in build time with it. So install it (if you have HomeBrew, brew install ccache) then set a shell variable NDK_CCACHE to point to it. I.e., for me, having installed it with brew, it would be export NDK_CCACHE=/usr/local/bin/ccache.

  • NDK can also parallelize while compiling. Set a shell variable NUM_CPUS to (according to Opie) 2x the number of cores in your machine. A quick way to get the # cores on your machine in OS X is system_profiler | grep "Number Of Cores" in terminal. I have 2 cores, so my shell var setting is export NUM_CPUS=4.

@billdawson
billdawson / Mixedmodulemodule.java
Last active December 15, 2015 13:28
Mixed Javascript/Java Titanium Android module code example. This specific example is to help overcome [TIMOB-13097](https://jira.appcelerator.org/browse/TIMOB-13097).
//...
@Kroll.method
public ExampleProxy exampleFactory() {
ExampleProxy proxy = new ExampleProxy();
// ... do stuff (or not) to get
// ... proxy ready however you want
// ...
return proxy;
}
01:10:58 web.1 | GET /api/imports/import-83850355f4e928818b12f296af519dd8-34bcf7ec-6fc0-4ecf-9763-783f7c359eff/status 304 5699ms
01:10:59 web.1 | getting task id 564fb685f8dbfd000700611e from worker
01:11:02 web.1 | resulting task data:
01:11:02 web.1 | {
01:11:02 web.1 | "id": "564fb685f8dbfd000700611e",
01:11:02 web.1 | "created_at": "2015-11-21T00:10:45Z",
01:11:02 web.1 | "updated_at": "2015-11-21T00:11:01Z",
01:11:02 web.1 | "project_id": "55c3969401aaf3000a00002d",
01:11:02 web.1 | "code_id": "55c3984f1aef88000600c019",
01:11:02 web.1 | "code_history_id": "564f9085f8dbfd00090019b4",
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Titanium" parent="android:Theme">
<item name="android:windowBackground">@drawable/background</item>
</style>
</resources>
diff --git a/android/modules/map/src/java/ti/modules/titanium/map/ViewProxy.java b/android/modules/map/src/java/ti/modules/titanium/map/ViewProxy.java
index 181debc..540f04a 100644
--- a/android/modules/map/src/java/ti/modules/titanium/map/ViewProxy.java
+++ b/android/modules/map/src/java/ti/modules/titanium/map/ViewProxy.java
@@ -185,33 +185,29 @@ public class ViewProxy extends TiViewProxy
}
@Kroll.method
- @SuppressWarnings({"rawtypes", "unchecked"})
- public void addRoute(Object route)
diff --git a/support/android/builder.py b/support/android/builder.py
index e1dfc6f..d8a75d8 100755
--- a/support/android/builder.py
+++ b/support/android/builder.py
@@ -1437,13 +1437,13 @@ class Builder(object):
for jar_file in self.android_jars:
add_resource_jar(jar_file)
- def add_native_libs(libs_dir):
+ def add_native_libs(libs_dir, exclude=[]):
[?1034hscons: Reading SConscript files ...
Building MobileSDK version 2.1.0, githash c7fc284
java -cp /Users/bill/src/titanium_mobile/android/build/lib/ant.jar:/Users/bill/src/titanium_mobile/android/build/lib/ant-launcher.jar:/Users/bill/src/titanium_mobile/android/build/lib/xercesImpl.jar:/Users/bill/src/titanium_mobile/android/build/lib/xml-apis.jar:/Users/bill/src/titanium_mobile/android/build/lib/ant-nodeps.jar org.apache.tools.ant.launch.Launcher -Dant.home=build -Dandroid.sdk=/opt/android-sdk-macosx -Dandroid.platform=/opt/android-sdk-macosx/platforms/android-8 -Dndk.build.args=JAVAH=javah -Dbuild.githash=c7fc284 -Dgoogle.apis=/opt/android-sdk-macosx/add-ons/addon-google_apis-google-8 -Dbuild.version=2.1.0 -buildfile build.xml full.build
Buildfile: /Users/bill/src/titanium_mobile/android/build.xml
clean.all:
[mkdir] Created dir: /Users/bill/src/titanium_mobile/dist/android/classes/ant-tasks
[javac] Compiling 7 source files to /Users/bill/src/titanium_mobile/dist/android/classes/ant-tasks
@billdawson
billdawson / app_in_ddms.md
Created January 18, 2012 00:23
Seeing an app in DDMS

Seeing an app in DDMS

If the app is running on an emulator, you see it automatically in DDMS.

If the app is running on a device connected to your development machine, you will only see it in DDMS if the <application/> element in AndroidManifest.xml has the android:debuggable="true" attribute.

You can set that attribute using just tiapp.xml. Make the <android/> section of tiapp.xml look like this:

<android xmlns:android="http://schemas.android.com/apk/res/android">
@billdawson
billdawson / desktop_perf_results.txt
Created August 24, 2011 20:06 — forked from marshall/desktop_perf_results.txt
Various V8 perf test results
Rhino (Interpreted)
-------------------
Score: 362
Richards: 425
DeltaBlue: 340
Crypto: 369
RayTrace: 535
EarleyBoyer: 474
RegExp: 108