Index: /pjproject/branches/projects/android/pjsip-apps/build/Makefile
===================================================================
--- /pjproject/branches/projects/android/pjsip-apps/build/Makefile	(revision 4193)
+++ /pjproject/branches/projects/android/pjsip-apps/build/Makefile	(revision 4194)
@@ -34,5 +34,5 @@
 export PJSUA_SRCDIR = ../src/pjsua
 export PJSUA_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \
-			main.o pjsua_app.o
+			main.o main_android.o pjsua_app.o
 export PJSUA_CFLAGS += $(_CFLAGS)
 export PJSUA_LDFLAGS += $(APP_LDFLAGS) $(APP_LDLIBS) $(LDFLAGS)
Index: /pjproject/branches/projects/android/pjsip-apps/src/apjsua/.classpath
===================================================================
--- /pjproject/branches/projects/android/pjsip-apps/src/apjsua/.classpath	(revision 4194)
+++ /pjproject/branches/projects/android/pjsip-apps/src/apjsua/.classpath	(revision 4194)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+	<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/libpjsua_app.so"/>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="src" path="gen"/>
+	<classpathentry kind="output" path="bin/classes"/>
+</classpath>
Index: /pjproject/branches/projects/android/pjsip-apps/src/apjsua/.project
===================================================================
--- /pjproject/branches/projects/android/pjsip-apps/src/apjsua/.project	(revision 4194)
+++ /pjproject/branches/projects/android/pjsip-apps/src/apjsua/.project	(revision 4194)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>apjsua</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>com.android.ide.eclipse.adt.ApkBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>
Index: /pjproject/branches/projects/android/pjsip-apps/src/apjsua/AndroidManifest.xml
===================================================================
--- /pjproject/branches/projects/android/pjsip-apps/src/apjsua/AndroidManifest.xml	(revision 4194)
+++ /pjproject/branches/projects/android/pjsip-apps/src/apjsua/AndroidManifest.xml	(revision 4194)
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="org.pjsip.pjsua"
+    android:versionCode="1"
+    android:versionName="1.0" >
+
+    <uses-sdk android:minSdkVersion="15" />
+
+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.RECORD_AUDIO" />
+    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
+    <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
+    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
+    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
+    <uses-permission android:name="android.permission.READ_CONTACTS" />
+    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
+    <uses-permission android:name="android.permission.CALL_PHONE" />
+    <uses-permission android:name="android.permission.WAKE_LOCK" />
+    <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
+    <uses-permission android:name="android.permission.VIBRATE" />
+    <uses-permission android:name="android.permission.BLUETOOTH" />
+    <uses-permission android:name="android.permission.READ_LOGS" />
+    <uses-permission android:name="android.permission.USE_SIP" />
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.CAMERA" />
+    <uses-permission android:name="android.permission.BROADCAST_STICKY" />
+    <uses-permission android:name="android.permission.READ_PROFILE" />
+    
+    <application
+        android:icon="@drawable/ic_launcher"
+        android:label="@string/app_name" >
+        <activity
+            android:screenOrientation="landscape"
+            android:name=".ApjsuaActivity"
+            android:label="@string/app_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+
+</manifest>
Index: /pjproject/branches/projects/android/pjsip-apps/src/apjsua/Makefile
===================================================================
--- /pjproject/branches/projects/android/pjsip-apps/src/apjsua/Makefile	(revision 4194)
+++ /pjproject/branches/projects/android/pjsip-apps/src/apjsua/Makefile	(revision 4194)
@@ -0,0 +1,15 @@
+include ../../../build.mak
+include $(PJDIR)/build/common.mak
+
+RULES_MAK := $(PJDIR)/build/rules.mak
+
+SWIG=swig
+
+all: pjsua_app_wrap.o
+	${APP_CXX} ${APP_CXXFLAGS} ${APP_LDFLAGS} -o libs/armeabi/libpjsua_app.so swig/pjsua_app_wrap.o ../../build/output/pjsua-$(TARGET_NAME)/*.o ${APP_LDLIBS}
+
+pjsua_app_wrap.o: pjsua_app.i
+	${CC} swig/pjsua_app_wrap.c ${APP_CFLAGS} -o swig/pjsua_app_wrap.o
+
+pjsua_app.i: swig/pjsua_app.i
+	${SWIG} -package org.pjsip.pjsua -outdir src/org/pjsip/pjsua -java swig/pjsua_app.i
Index: /pjproject/branches/projects/android/pjsip-apps/src/apjsua/gen/org/pjsip/pjsua/BuildConfig.java
===================================================================
--- /pjproject/branches/projects/android/pjsip-apps/src/apjsua/gen/org/pjsip/pjsua/BuildConfig.java	(revision 4194)
+++ /pjproject/branches/projects/android/pjsip-apps/src/apjsua/gen/org/pjsip/pjsua/BuildConfig.java	(revision 4194)
@@ -0,0 +1,6 @@
+/** Automatically generated file. DO NOT MODIFY */
+package org.pjsip.pjsua;
+
+public final class BuildConfig {
+    public final static boolean DEBUG = true;
+}
Index: /pjproject/branches/projects/android/pjsip-apps/src/apjsua/gen/org/pjsip/pjsua/R.java
===================================================================
--- /pjproject/branches/projects/android/pjsip-apps/src/apjsua/gen/org/pjsip/pjsua/R.java	(revision 4194)
+++ /pjproject/branches/projects/android/pjsip-apps/src/apjsua/gen/org/pjsip/pjsua/R.java	(revision 4194)
@@ -0,0 +1,30 @@
+/* AUTO-GENERATED FILE.  DO NOT MODIFY.
+ *
+ * This class was automatically generated by the
+ * aapt tool from the resource data it found.  It
+ * should not be modified by hand.
+ */
+
+package org.pjsip.pjsua;
+
+public final class R {
+    public static final class attr {
+    }
+    public static final class drawable {
+        public static final int ic_launcher=0x7f020000;
+    }
+    public static final class id {
+        public static final int command=0x7f060000;
+        public static final int textOut=0x7f060001;
+    }
+    public static final class layout {
+        public static final int main=0x7f030000;
+    }
+    public static final class raw {
+        public static final int config=0x7f040000;
+    }
+    public static final class string {
+        public static final int app_name=0x7f050001;
+        public static final int command=0x7f050000;
+    }
+}
Index: /pjproject/branches/projects/android/pjsip-apps/src/apjsua/lint.xml
===================================================================
--- /pjproject/branches/projects/android/pjsip-apps/src/apjsua/lint.xml	(revision 4194)
+++ /pjproject/branches/projects/android/pjsip-apps/src/apjsua/lint.xml	(revision 4194)
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lint>
+</lint>
Index: /pjproject/branches/projects/android/pjsip-apps/src/apjsua/project.properties
===================================================================
--- /pjproject/branches/projects/android/pjsip-apps/src/apjsua/project.properties	(revision 4194)
+++ /pjproject/branches/projects/android/pjsip-apps/src/apjsua/project.properties	(revision 4194)
@@ -0,0 +1,14 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-15
Index: /pjproject/branches/projects/android/pjsip-apps/src/apjsua/res/layout/main.xml
===================================================================
--- /pjproject/branches/projects/android/pjsip-apps/src/apjsua/res/layout/main.xml	(revision 4194)
+++ /pjproject/branches/projects/android/pjsip-apps/src/apjsua/res/layout/main.xml	(revision 4194)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:orientation="vertical" >
+
+    <EditText
+        android:id="@+id/command"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:ems="10"
+        android:hint="@string/command" android:maxLines="1">
+
+        <requestFocus />
+    </EditText>
+
+    <TextView
+        android:id="@+id/textOut"
+        android:layout_width="fill_parent"
+        android:layout_height="match_parent"
+        android:scrollbars="vertical"
+        android:text="" />
+
+</LinearLayout>
Index: /pjproject/branches/projects/android/pjsip-apps/src/apjsua/res/raw/config.txt
===================================================================
--- /pjproject/branches/projects/android/pjsip-apps/src/apjsua/res/raw/config.txt	(revision 4194)
+++ /pjproject/branches/projects/android/pjsip-apps/src/apjsua/res/raw/config.txt	(revision 4194)
@@ -0,0 +1,1 @@
+--clock-rate=8000
Index: /pjproject/branches/projects/android/pjsip-apps/src/apjsua/res/values/strings.xml
===================================================================
--- /pjproject/branches/projects/android/pjsip-apps/src/apjsua/res/values/strings.xml	(revision 4194)
+++ /pjproject/branches/projects/android/pjsip-apps/src/apjsua/res/values/strings.xml	(revision 4194)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+    <string name="command">Insert command here</string>
+    <string name="app_name">apjsua</string>
+
+</resources>
Index: /pjproject/branches/projects/android/pjsip-apps/src/apjsua/src/org/pjsip/pjsua/ApjsuaActivity.java
===================================================================
--- /pjproject/branches/projects/android/pjsip-apps/src/apjsua/src/org/pjsip/pjsua/ApjsuaActivity.java	(revision 4194)
+++ /pjproject/branches/projects/android/pjsip-apps/src/apjsua/src/org/pjsip/pjsua/ApjsuaActivity.java	(revision 4194)
@@ -0,0 +1,145 @@
+package org.pjsip.pjsua;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import android.app.Activity;
+import android.content.Context;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.text.Layout;
+import android.text.method.ScrollingMovementMethod;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.View.OnKeyListener;
+import android.widget.EditText;
+import android.widget.TextView;
+
+/* This class is for running pjsua in a secondary thread. */
+class PjsuaThread extends Thread {
+	public static Boolean finished;
+	
+	public void run() {
+		if (pjsua_app.initApp() != 0)
+        	return;
+		
+        pjsua_app.startPjsua(ApjsuaActivity.CFG_FNAME);
+        finished = true;
+        pjsua_app.deinitApp();
+	}
+}
+
+/**
+ * The purpose of this class is to create an async task for fetching
+ * output message from pjsua and display it in our GUI TextView.
+ */
+class TextOutTask extends AsyncTask<Void, String ,Void> {
+	public TextView tv;
+	
+	protected Void doInBackground(Void... args) {
+		while (!PjsuaThread.finished) {
+			publishProgress(pjsua_app.getMessage());
+		}
+		return null;
+	}
+	
+	protected void onProgressUpdate(String... progress) {
+		tv.append(progress[0]);
+		pjsua_app.finishDisplayMsg();
+
+		/* Auto-scroll to bottom */
+		final Layout layout = tv.getLayout();
+		if (layout != null) {
+			int scrollDelta = layout.getLineBottom(tv.getLineCount() - 1) -
+							  tv.getScrollY() - tv.getHeight();
+			if (scrollDelta > 0)
+				tv.scrollBy(0, scrollDelta);
+		}
+	}
+}
+
+public class ApjsuaActivity extends Activity {
+	public static String CFG_NAME = "config.txt";
+	public static String CFG_FNAME;
+	
+	public void setupConfig() {
+        try {
+            String readLine = null;
+            String newLine = "\n";
+            InputStream is;
+            BufferedReader br;
+        	FileOutputStream fos;
+        	File file = this.getFileStreamPath(CFG_NAME);
+    		
+    		CFG_FNAME = file.toString();
+    		/* Uncomment this when apjsua already has a built-in config editor.
+    		if (file.exists())
+    			return;
+ 			 */
+
+            /* Read the config from our raw resource and copy it to
+             * the app's private directory.
+             */
+    		is = this.getResources().openRawResource(R.raw.config);
+            br = new BufferedReader(new InputStreamReader(is));
+        	fos = this.openFileOutput(CFG_NAME, Context.MODE_PRIVATE);
+
+        	while ((readLine = br.readLine()) != null) {
+        		fos.write(readLine.getBytes());
+        		fos.write(newLine.getBytes());
+        	}
+        	br.close();
+        	is.close();
+        	fos.close();
+        } catch (IOException e) {
+        }
+	}
+	
+    /** Called when the activity is first created. */
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.main);
+        
+        TextView tv = (TextView) findViewById(R.id.textOut);
+        tv.setMovementMethod(new ScrollingMovementMethod());
+        
+        /* Send the input to pjsua_app when user presses Enter. */
+        final EditText cmd = (EditText) findViewById(R.id.command);
+        cmd.setOnKeyListener(new OnKeyListener() {
+        	public boolean onKey(View v, int keyCode, KeyEvent event) {
+        		if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
+        			(keyCode == KeyEvent.KEYCODE_ENTER))
+        		{
+        			pjsua_app.setInput(cmd.getText().toString());
+        			cmd.setText("");
+        			return true;
+        		}
+        		return false;
+        	}
+        });
+
+        /* Load pjsua_app */
+        try {
+        	System.loadLibrary("pjsua_app");
+        } catch (UnsatisfiedLinkError e) {
+        	tv.append("Failed to load pjsua_app\n");
+        	return;
+        }
+
+        /* Setup config file */
+        setupConfig();
+        
+        /* Create pjsua and output thread */
+        PjsuaThread.finished = false;
+        TextOutTask outTask = new TextOutTask();
+        outTask.tv = tv;
+        outTask.execute();
+        PjsuaThread pjsuaThread = new PjsuaThread();
+        pjsuaThread.start();
+    }
+}
Index: /pjproject/branches/projects/android/pjsip-apps/src/apjsua/src/org/pjsip/pjsua/pjsua_app.java
===================================================================
--- /pjproject/branches/projects/android/pjsip-apps/src/apjsua/src/org/pjsip/pjsua/pjsua_app.java	(revision 4194)
+++ /pjproject/branches/projects/android/pjsip-apps/src/apjsua/src/org/pjsip/pjsua/pjsua_app.java	(revision 4194)
@@ -0,0 +1,36 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.6
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.pjsip.pjsua;
+
+public class pjsua_app {
+  public static int initApp() {
+    return pjsua_appJNI.initApp();
+  }
+
+  public static void deinitApp() {
+    pjsua_appJNI.deinitApp();
+  }
+
+  public static int startPjsua(String cfgFile) {
+    return pjsua_appJNI.startPjsua(cfgFile);
+  }
+
+  public static void setInput(String s) {
+    pjsua_appJNI.setInput(s);
+  }
+
+  public static String getMessage() {
+    return pjsua_appJNI.getMessage();
+  }
+
+  public static void finishDisplayMsg() {
+    pjsua_appJNI.finishDisplayMsg();
+  }
+
+}
Index: /pjproject/branches/projects/android/pjsip-apps/src/apjsua/src/org/pjsip/pjsua/pjsua_appJNI.java
===================================================================
--- /pjproject/branches/projects/android/pjsip-apps/src/apjsua/src/org/pjsip/pjsua/pjsua_appJNI.java	(revision 4194)
+++ /pjproject/branches/projects/android/pjsip-apps/src/apjsua/src/org/pjsip/pjsua/pjsua_appJNI.java	(revision 4194)
@@ -0,0 +1,18 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.6
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package org.pjsip.pjsua;
+
+public class pjsua_appJNI {
+  public final static native int initApp();
+  public final static native void deinitApp();
+  public final static native int startPjsua(String jarg1);
+  public final static native void setInput(String jarg1);
+  public final static native String getMessage();
+  public final static native void finishDisplayMsg();
+}
Index: /pjproject/branches/projects/android/pjsip-apps/src/apjsua/swig/pjsua_app.i
===================================================================
--- /pjproject/branches/projects/android/pjsip-apps/src/apjsua/swig/pjsua_app.i	(revision 4194)
+++ /pjproject/branches/projects/android/pjsip-apps/src/apjsua/swig/pjsua_app.i	(revision 4194)
@@ -0,0 +1,18 @@
+/* File: pjsua_app.i */
+%module pjsua_app
+
+%{
+int initApp();
+void deinitApp();
+int startPjsua(char *cfgFile);
+void setInput(char *s);
+char * getMessage();
+void finishDisplayMsg();
+%}
+
+int initApp();
+void deinitApp();
+int startPjsua(char *cfgFile);
+void setInput(char *s);
+char * getMessage();
+void finishDisplayMsg();
Index: /pjproject/branches/projects/android/pjsip-apps/src/apjsua/swig/pjsua_app_wrap.c
===================================================================
--- /pjproject/branches/projects/android/pjsip-apps/src/apjsua/swig/pjsua_app_wrap.c	(revision 4194)
+++ /pjproject/branches/projects/android/pjsip-apps/src/apjsua/swig/pjsua_app_wrap.c	(revision 4194)
@@ -0,0 +1,277 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 2.0.6
+ * 
+ * This file is not intended to be easily readable and contains a number of 
+ * coding conventions designed to improve portability and efficiency. Do not make
+ * changes to this file unless you know what you are doing--modify the SWIG 
+ * interface file instead. 
+ * ----------------------------------------------------------------------------- */
+
+#define SWIGJAVA
+
+/* -----------------------------------------------------------------------------
+ *  This section contains generic SWIG labels for method/variable
+ *  declarations/attributes, and other compiler dependent labels.
+ * ----------------------------------------------------------------------------- */
+
+/* template workaround for compilers that cannot correctly implement the C++ standard */
+#ifndef SWIGTEMPLATEDISAMBIGUATOR
+# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
+#  define SWIGTEMPLATEDISAMBIGUATOR template
+# elif defined(__HP_aCC)
+/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
+/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
+#  define SWIGTEMPLATEDISAMBIGUATOR template
+# else
+#  define SWIGTEMPLATEDISAMBIGUATOR
+# endif
+#endif
+
+/* inline attribute */
+#ifndef SWIGINLINE
+# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
+#   define SWIGINLINE inline
+# else
+#   define SWIGINLINE
+# endif
+#endif
+
+/* attribute recognised by some compilers to avoid 'unused' warnings */
+#ifndef SWIGUNUSED
+# if defined(__GNUC__)
+#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
+#     define SWIGUNUSED __attribute__ ((__unused__)) 
+#   else
+#     define SWIGUNUSED
+#   endif
+# elif defined(__ICC)
+#   define SWIGUNUSED __attribute__ ((__unused__)) 
+# else
+#   define SWIGUNUSED 
+# endif
+#endif
+
+#ifndef SWIG_MSC_UNSUPPRESS_4505
+# if defined(_MSC_VER)
+#   pragma warning(disable : 4505) /* unreferenced local function has been removed */
+# endif 
+#endif
+
+#ifndef SWIGUNUSEDPARM
+# ifdef __cplusplus
+#   define SWIGUNUSEDPARM(p)
+# else
+#   define SWIGUNUSEDPARM(p) p SWIGUNUSED 
+# endif
+#endif
+
+/* internal SWIG method */
+#ifndef SWIGINTERN
+# define SWIGINTERN static SWIGUNUSED
+#endif
+
+/* internal inline SWIG method */
+#ifndef SWIGINTERNINLINE
+# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
+#endif
+
+/* exporting methods */
+#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+#  ifndef GCC_HASCLASSVISIBILITY
+#    define GCC_HASCLASSVISIBILITY
+#  endif
+#endif
+
+#ifndef SWIGEXPORT
+# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+#   if defined(STATIC_LINKED)
+#     define SWIGEXPORT
+#   else
+#     define SWIGEXPORT __declspec(dllexport)
+#   endif
+# else
+#   if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
+#     define SWIGEXPORT __attribute__ ((visibility("default")))
+#   else
+#     define SWIGEXPORT
+#   endif
+# endif
+#endif
+
+/* calling conventions for Windows */
+#ifndef SWIGSTDCALL
+# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+#   define SWIGSTDCALL __stdcall
+# else
+#   define SWIGSTDCALL
+# endif 
+#endif
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
+#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
+# define _SCL_SECURE_NO_DEPRECATE
+#endif
+
+
+
+/* Fix for jlong on some versions of gcc on Windows */
+#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
+  typedef long long __int64;
+#endif
+
+/* Fix for jlong on 64-bit x86 Solaris */
+#if defined(__x86_64)
+# ifdef _LP64
+#   undef _LP64
+# endif
+#endif
+
+#include <jni.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+/* Support for throwing Java exceptions */
+typedef enum {
+  SWIG_JavaOutOfMemoryError = 1, 
+  SWIG_JavaIOException, 
+  SWIG_JavaRuntimeException, 
+  SWIG_JavaIndexOutOfBoundsException,
+  SWIG_JavaArithmeticException,
+  SWIG_JavaIllegalArgumentException,
+  SWIG_JavaNullPointerException,
+  SWIG_JavaDirectorPureVirtual,
+  SWIG_JavaUnknownError
+} SWIG_JavaExceptionCodes;
+
+typedef struct {
+  SWIG_JavaExceptionCodes code;
+  const char *java_exception;
+} SWIG_JavaExceptions_t;
+
+
+static void SWIGUNUSED SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg) {
+  jclass excep;
+  static const SWIG_JavaExceptions_t java_exceptions[] = {
+    { SWIG_JavaOutOfMemoryError, "java/lang/OutOfMemoryError" },
+    { SWIG_JavaIOException, "java/io/IOException" },
+    { SWIG_JavaRuntimeException, "java/lang/RuntimeException" },
+    { SWIG_JavaIndexOutOfBoundsException, "java/lang/IndexOutOfBoundsException" },
+    { SWIG_JavaArithmeticException, "java/lang/ArithmeticException" },
+    { SWIG_JavaIllegalArgumentException, "java/lang/IllegalArgumentException" },
+    { SWIG_JavaNullPointerException, "java/lang/NullPointerException" },
+    { SWIG_JavaDirectorPureVirtual, "java/lang/RuntimeException" },
+    { SWIG_JavaUnknownError,  "java/lang/UnknownError" },
+    { (SWIG_JavaExceptionCodes)0,  "java/lang/UnknownError" }
+  };
+  const SWIG_JavaExceptions_t *except_ptr = java_exceptions;
+
+  while (except_ptr->code != code && except_ptr->code)
+    except_ptr++;
+
+  (*jenv)->ExceptionClear(jenv);
+  excep = (*jenv)->FindClass(jenv, except_ptr->java_exception);
+  if (excep)
+    (*jenv)->ThrowNew(jenv, excep, msg);
+}
+
+
+/* Contract support */
+
+#define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, msg); return nullreturn; } else
+
+
+int initApp();
+void deinitApp();
+int startPjsua(char *cfgFile);
+void setInput(char *s);
+char * getMessage();
+void finishDisplayMsg();
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+SWIGEXPORT jint JNICALL Java_org_pjsip_pjsua_pjsua_1appJNI_initApp(JNIEnv *jenv, jclass jcls) {
+  jint jresult = 0 ;
+  int result;
+  
+  (void)jenv;
+  (void)jcls;
+  result = (int)initApp();
+  jresult = (jint)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_pjsip_pjsua_pjsua_1appJNI_deinitApp(JNIEnv *jenv, jclass jcls) {
+  (void)jenv;
+  (void)jcls;
+  deinitApp();
+}
+
+
+SWIGEXPORT jint JNICALL Java_org_pjsip_pjsua_pjsua_1appJNI_startPjsua(JNIEnv *jenv, jclass jcls, jstring jarg1) {
+  jint jresult = 0 ;
+  char *arg1 = (char *) 0 ;
+  int result;
+  
+  (void)jenv;
+  (void)jcls;
+  arg1 = 0;
+  if (jarg1) {
+    arg1 = (char *)(*jenv)->GetStringUTFChars(jenv, jarg1, 0);
+    if (!arg1) return 0;
+  }
+  result = (int)startPjsua(arg1);
+  jresult = (jint)result; 
+  if (arg1) (*jenv)->ReleaseStringUTFChars(jenv, jarg1, (const char *)arg1);
+  return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_pjsip_pjsua_pjsua_1appJNI_setInput(JNIEnv *jenv, jclass jcls, jstring jarg1) {
+  char *arg1 = (char *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  arg1 = 0;
+  if (jarg1) {
+    arg1 = (char *)(*jenv)->GetStringUTFChars(jenv, jarg1, 0);
+    if (!arg1) return ;
+  }
+  setInput(arg1);
+  if (arg1) (*jenv)->ReleaseStringUTFChars(jenv, jarg1, (const char *)arg1);
+}
+
+
+SWIGEXPORT jstring JNICALL Java_org_pjsip_pjsua_pjsua_1appJNI_getMessage(JNIEnv *jenv, jclass jcls) {
+  jstring jresult = 0 ;
+  char *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  result = (char *)getMessage();
+  if (result) jresult = (*jenv)->NewStringUTF(jenv, (const char *)result);
+  return jresult;
+}
+
+
+SWIGEXPORT void JNICALL Java_org_pjsip_pjsua_pjsua_1appJNI_finishDisplayMsg(JNIEnv *jenv, jclass jcls) {
+  (void)jenv;
+  (void)jcls;
+  finishDisplayMsg();
+}
+
+
+#ifdef __cplusplus
+}
+#endif
+
Index: /pjproject/branches/projects/android/pjsip-apps/src/pjsua/main_android.c
===================================================================
--- /pjproject/branches/projects/android/pjsip-apps/src/pjsua/main_android.c	(revision 4194)
+++ /pjproject/branches/projects/android/pjsip-apps/src/pjsua/main_android.c	(revision 4194)
@@ -0,0 +1,159 @@
+/* $Id$ */
+/* 
+ * Copyright (C) 2012-2012 Teluu Inc. (http://www.teluu.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ */
+
+#include <pjsua-lib/pjsua.h>
+
+#if defined(PJ_ANDROID) && PJ_ANDROID != 0
+
+#define THIS_FILE	"main_android.c"
+
+#include <android/log.h>
+
+#define SHOW_LOG 1
+
+struct {
+    pj_caching_pool  caching_pool;
+    pj_pool_t       *pool;
+    pj_sem_t        *input_sem;
+    pj_sem_t        *output_sem;
+    pj_sem_t        *out_print_sem;
+    char             line[200];
+    char             out_buf[1000];
+} app_var;
+
+int main(int argc, char *argv[]);
+extern pj_log_func *log_cb;
+
+char argv_buf[200];
+char *_argv[] = {"", "--config-file", argv_buf};
+
+void setInput(char *s)
+{
+    app_var.line[0] = 0;
+    if (strlen(s) < sizeof(app_var.line))
+        strncpy(app_var.line, s, strlen(s));
+    pj_sem_post(app_var.input_sem);
+}
+
+char * getMessage()
+{
+    pj_sem_wait(app_var.output_sem);
+    return app_var.out_buf;
+}
+
+void finishDisplayMsg()
+{
+    pj_sem_post(app_var.out_print_sem);
+}
+
+void showMsg(const char *format, ...)
+{
+    va_list arg;
+    
+    va_start(arg, format);
+#if SHOW_LOG
+    __android_log_vprint(ANDROID_LOG_INFO, "apjsua", format, arg);
+#endif
+    vsnprintf(app_var.out_buf, sizeof(app_var.out_buf), format, arg);
+    va_end(arg);
+    
+    pj_sem_post(app_var.output_sem);
+    pj_sem_wait(app_var.out_print_sem);
+}
+
+char * getInput(char *s, int n, FILE *stream)
+{
+    if (stream != stdin)
+        return fgets(s, n, stream);
+    
+    pj_sem_wait(app_var.input_sem);
+    strncpy(s, app_var.line, n);
+    return app_var.line;
+}
+
+pj_bool_t showNotification(pjsua_call_id call_id)
+{
+    return PJ_TRUE;
+}
+
+void showLog(int level, const char *data, int len)
+{
+    showMsg("%s", data);
+}
+
+void deinitApp()
+{
+    showMsg("Quitting...");
+    
+    if (app_var.input_sem) {
+        pj_sem_destroy(app_var.input_sem);
+        app_var.input_sem = NULL;
+    }
+    if (app_var.output_sem) {
+        pj_sem_destroy(app_var.output_sem);
+        app_var.output_sem = NULL;
+    }
+    if (app_var.out_print_sem) {
+        pj_sem_destroy(app_var.out_print_sem);
+        app_var.out_print_sem = NULL;
+    }
+    
+    pj_pool_release(app_var.pool);
+    pj_caching_pool_destroy(&app_var.caching_pool);
+    pj_shutdown();
+}
+
+int initApp()
+{
+    pj_status_t status = PJ_SUCCESS;
+    
+    pj_init();
+    pj_caching_pool_init(&app_var.caching_pool,
+                         &pj_pool_factory_default_policy, 0);
+    app_var.pool = pj_pool_create(&app_var.caching_pool.factory, "apjsua",
+                                  256, 256, 0);
+
+    app_var.input_sem = app_var.output_sem = app_var.out_print_sem = NULL;
+    status = pj_sem_create(app_var.pool, NULL, 0, 1, &app_var.input_sem);
+    if (status != PJ_SUCCESS)
+        goto on_return;
+    status = pj_sem_create(app_var.pool, NULL, 0, 1, &app_var.output_sem);
+    if (status != PJ_SUCCESS)
+        goto on_return;
+    status = pj_sem_create(app_var.pool, NULL, 0, 1, &app_var.out_print_sem);
+    if (status != PJ_SUCCESS)
+        goto on_return;
+    
+    pj_log_set_log_func(&showLog);
+    log_cb = &showLog;
+    
+    return status;
+    
+on_return:
+    deinitApp();
+    return status;
+}
+
+int startPjsua(char *cfgFile)
+{
+    strncpy(argv_buf, cfgFile, sizeof(argv_buf));
+    return main(3, _argv);
+}
+
+#endif /* PJ_ANDROID */
