diff options
author | Tor Lillqvist <tlillqvist@suse.com> | 2011-11-29 01:24:01 +0200 |
---|---|---|
committer | Tor Lillqvist <tlillqvist@suse.com> | 2011-11-29 01:37:04 +0200 |
commit | 3ad35cbadbed5c8cf2d2bbcccd154768a5a62b34 (patch) | |
tree | 62cfc6d30c6d7677a607e847da0812cb70e262b5 /android | |
parent | 203553e71743351fcec9fc791d70ca8bb6c122e1 (diff) |
Android hacking
Start of an app to just load some document. Uses API from the
org.libreoffice.android.Bootstrap class.
Not sure what is the sanest way to build an app like this. It needs a
bunch of shared libraries of course to be copied into libs/armeabi-v7a
so that they get included in the .apk. Perhaps a Makefile similar to
the one for lo-bootstrap might be good?
But for debugging the Java code Eclipse is the way to go (?), and to
be able to do that Eclipse wants a "project". So should this then be
built only through Eclipse? Can one build Eclipse projects from the
command line?
Diffstat (limited to 'android')
-rw-r--r-- | android/examples/DocumentLoader/AndroidManifest.xml | 18 | ||||
-rw-r--r-- | android/examples/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java | 97 |
2 files changed, 115 insertions, 0 deletions
diff --git a/android/examples/DocumentLoader/AndroidManifest.xml b/android/examples/DocumentLoader/AndroidManifest.xml new file mode 100644 index 000000000000..c137311155d1 --- /dev/null +++ b/android/examples/DocumentLoader/AndroidManifest.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="org.libreoffice.android.examples" + android:versionCode="1" + android:versionName="1.0"> + <uses-sdk android:minSdkVersion="9" /> + <application android:label="@string/app_name" + android:debuggable="true"> + <activity android:name=".DocumentLoader" + android:label="LO DocumentLoader" + android:configChanges="orientation|keyboardHidden"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + </application> +</manifest> diff --git a/android/examples/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java b/android/examples/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java new file mode 100644 index 000000000000..41f69dd019b0 --- /dev/null +++ b/android/examples/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java @@ -0,0 +1,97 @@ +// -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + +// Version: MPL 1.1 / GPLv3+ / LGPLv3+ +// +// The contents of this file are subject to the Mozilla Public License Version +// 1.1 (the "License"); you may not use this file except in compliance with +// the License or as specified alternatively below. You may obtain a copy of +// the License at http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" basis, +// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +// for the specific language governing rights and limitations under the +// License. +// +// Major Contributor(s): +// Copyright (C) 2011 Tor Lillqvist <tml@iki.fi> (initial developer) +// Copyright (C) 2011 SUSE Linux http://suse.com (initial developer's employer) +// +// All Rights Reserved. +// +// For minor contributions see the git repository. +// +// Alternatively, the contents of this file may be used under the terms of +// either the GNU General Public License Version 3 or later (the "GPLv3+"), or +// the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), +// in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable +// instead of those above. + +package org.libreoffice.android.examples; + +import android.app.Activity; +import android.os.Bundle; +import android.view.KeyEvent; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.Button; +import android.widget.EditText; + +import com.sun.star.uno.UnoRuntime; + +import org.libreoffice.android.Bootstrap; + +public class DocumentLoader + extends Activity { + + @Override + public void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + + try { + + Thread.sleep(20000); + + Bootstrap.setup(this); + + Bootstrap.dlopen("libjuh.so"); + + com.sun.star.uno.XComponentContext xContext = null; + + xContext = com.sun.star.comp.helper.Bootstrap.defaultBootstrap_InitialComponentContext(); + + com.sun.star.lang.XMultiComponentFactory xMCF = + xContext.getServiceManager(); + + Object oDesktop = xMCF.createInstanceWithContext( + "com.sun.star.frame.Desktop", xContext); + + com.sun.star.frame.XComponentLoader xCompLoader = + (com.sun.star.frame.XComponentLoader) + UnoRuntime.queryInterface( + com.sun.star.frame.XComponentLoader.class, oDesktop); + + // Getting the given starting directory + String sUrl = "file:///assets/inputfile.doc"; + + // Loading the wanted document + com.sun.star.beans.PropertyValue propertyValues[] = + new com.sun.star.beans.PropertyValue[1]; + propertyValues[0] = new com.sun.star.beans.PropertyValue(); + propertyValues[0].Name = "Hidden"; + propertyValues[0].Value = new Boolean(true); + + Object oDoc = + xCompLoader.loadComponentFromURL + (sUrl, "_blank", 0, propertyValues); + } + catch (Exception e) { + e.printStackTrace(System.err); + System.exit(1); + } + } +} + +// vim:set shiftwidth=4 softtabstop=4 expandtab: |