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?
This commit is contained in:
Tor Lillqvist 2011-11-29 01:24:01 +02:00
parent 203553e717
commit 3ad35cbadb
2 changed files with 115 additions and 0 deletions

View File

@ -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>

View File

@ -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: