You are browsing the archive for Necessitas.

Qt Android (Necessitas) soft-keys control volume

March 1, 2012 in C++, Programming, Qt framework, Tutorials

To control application volume from Necessitas the following changes are required into QtActivity.java file

import android.media.AudioManager;

public class QtActivity extends Activity
{
private AudioManager audio;
……..
}

and add into public boolean onKeyDown(int keyCode, KeyEvent event) following code:

public boolean onKeyDown(int keyCode, KeyEvent event)
{
switch (keyCode)
{
case KeyEvent.KEYCODE_VOLUME_UP:
audio.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, AudioManager.FLAG_SHOW_UI);
return true;

case KeyEvent.KEYCODE_VOLUME_DOWN:
audio.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER, AudioManager.FLAG_SHOW_UI);
return true;
}

…………
}

Source: here

How to use Java from Qt/C++ in Necessitas

March 1, 2012 in C++, Java, Qt framework, Tutorials

This steps are valid for Necessitas Alpha 3 Update 4
Add your java class inside org.kde.necessitas.origo (i will refer in this article as JavaManager.Java)
Edit qtmain_android.cpp

Replace

static JavaVM *m_javaVM = NULL;
static JNIEnv *m_env = NULL;
static jobject objptr;

with

JavaVM *m_javaVM = NULL;
static JNIEnv *m_env = NULL;
jobject objptr;

//new pointer to my Java class
jobject customClassPtr;

//my class
static const char * const customClass = “org/kde/necessitas/origo/JavaManager”;

Add next lines to your file

static int registerNativeMethodsCustom(JNIEnv* env, const char* className, JNINativeMethod* gMethods, int numMethods)
{
jclass clazz=env->FindClass(className);
if (clazz == NULL)
{
__android_log_print(ANDROID_LOG_FATAL,”Qt”, “Custom Native registration unable to find class ‘%s’”, className);
return JNI_FALSE;
}

jmethodID constr = env->GetMethodID(clazz, “”, “()V”);
if(!constr) {
__android_log_print(ANDROID_LOG_FATAL,”Qt”, “Custom Native registration unable to find constructor for class ‘%s’”, className);
return JNI_FALSE;
}

jobject obj = env->NewObject(clazz, constr);
customClassPtr = env->NewGlobalRef(obj);
// if (env->RegisterNatives(clazz, gMethods, numMethods) < 0)
// {
// __android_log_print(ANDROID_LOG_FATAL,”Qt”, “Custom RegisterNatives failed for ‘%s’”, className);
// return JNI_FALSE;
// }
return JNI_TRUE;
}

static int registerNativesCustom(JNIEnv* env)
{
if (!registerNativeMethodsCustom(env, customClass, methods, sizeof(methods) / sizeof(methods[0])))
return JNI_FALSE;
return JNI_TRUE;
}

Add next lines to Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* /*reserved*/)

if (!registerNativesCustom(m_env))
{
__android_log_print(ANDROID_LOG_FATAL, “Qt”, “Custom registerNatives failed”);
return -1;
}

Prepare and call your java class from your file. Prepare your C++ class adding next lines:

extern JavaVM *m_javaVM;
extern jobject objptr;
extern jobject customClassPtr;

Now, in your method call the Java method:

JNIEnv* env;
if (m_javaVM->AttachCurrentThread(&env, NULL)<0)
{
qCritical()<    return;
}

jclass applicationClass = env->GetObjectClass(customClassPtr);

qDebug()<
if (applicationClass) {
jmethodID playMediaFileMethodID = env->GetMethodID(applicationClass,”playMediaFile”, “(Ljava/lang/String;)V”);
jstring path = env->NewStringUTF(“my song”);
env->CallStaticVoidMethod(applicationClass, playMediaFileMethodID, path);
}

m_javaVM->DetachCurrentThread();

WARNING
1. The qtmain_android.cpp cand be changed by any Necessitas updates
2. You must change the qtmain_android.coo in both armabi and armabi-v7a
3. Any suggestions and/or questions are welcome.

Source: here.

Necessitas alpha 3 update 2

December 13, 2011 in Android X86, Applications, C++, Frameworks, News, Qt framework

Hello folks,

I’m honored to announce the second update of Necessitas alpha 3 release [1].
This release brings a new keyboard implementation which I announce it early this month [2]. As I said before there are a few small things which are still missing (I’d like to mention the selection which is not the best in town), but, overall I can say that all Qt users will enjoy a first class experience when it comes to input support. Also I tied to make it a little bit smarter:

  • If the input widget is bigger than 2/3 of the screen size your window will be resized.
  • Else the window will be moved in order to ensure widget visibility.

Yours sincerely,
BogDan.

[1] http://groups.google.com/group/android-qt/browse_thread/thread/1d729d895b0379ed
[2] http://groups.google.com/group/android-qt/browse_thread/thread/3be1cba871e7e51c

[Ed:The sdk files from sourceforge are the same  for example i have downloaded for linux and ran  ./necessitas-0.3-online-sdk-installer-linux and it will download the new release ,If you have the sdk already installed you should upgrade from the menu Help-Start-Updater ]

Android Development liked this post

QML components for Android “demo” apps available

December 6, 2011 in C++, Frameworks, NDK, Tutorials

Here are 2 apps to demo the qml components on Android. So far, nothing fancy regarding the look&feel, it is the symbian one. The components are not (yet) integrated in Ministro, so they are embedded in each application.

SemperWebML: Simple browser
sources: https://gitorious.org/semperwebml/semperwebml
apk: http://dl.dropbox.com/u/7264433/Android/SemperWebML-debug.apk (armv7a/api lvl 10)

SemperXbmc: XBMC (http://xbmc.org/) remote control
sources: https://gitorious.org/semperxbmc/semperxbmc
apk: http://dl.dropbox.com/u/7264433/Android/SemperXbmc-debug.apk (armv7a/api lvl 7)

Thanks again to the Qt for Android team for allowing this to happen.

Enjoy
- Chris -

#Android #QT Necessitas alpha4 status report

December 6, 2011 in C++, Frameworks, News, Programming

Hello folks,

I writing this mail to inform you about Necessitas alpha4 release status. When we released alpha 3 we said that will try to release alpha 4 (the last one) till the end of November, but I forgot to mention the most important thing: that we also depend on Nokia to release the sable 4.8, because we can’t guarantee something which is not guaranteed by its creator.

Meanwhile we’ll release new updates for current release which will bring more fixes and improved features.
On this occasion I’d like to let you know that I just close the very first (and the oldest) Necessitas issue [1]. It is about virtual keyboard support which I managed to rewrite it and (almost) finish it

[2]. There are a few small things which are still missing (I’d like to mention the selection which is not the best in town), but, overall I can say that all Qt users will enjoy a first class experience when it comes to input support. The new implementation will be added to the
next update (which will come soon).

Cheers,
BogDan.

[1] http://code.google.com/p/android-lighthouse/issues/detail?id=1
[2] http://commits.kde.org/android-qt/d4853d1ce71e591fc031c0f9e505b814f833e332

Necessitas Hands on workshop

June 27, 2011 in Applications, C++, Frameworks, NDK, Programming, Qt framework, Tutorials

Pretty cool presentation that takes you from necessitas installation to running the qt demo on your android device
Workshop presentation:
https://docs.google.com/present/edit?id=0AaZO9Wm2FFZsZGN2eGd6NnhfNGQ1bTV4cmN3&hl=en_US&authkey=CNSL0ZoI

Generic necessitas presentation:
https://docs.google.com/present/edit?id=0ARgwtSVCT8WtZGR2cHFzd3dfMGQ0aHdiZGhx&hl=en_US&authkey=CMac6-kO

ps:It was posted on necessitas-devel

I have put together some slides for the Necessitas workshop[s]. They share the beginning with the normal presentation but then describe in 3 slides how to set up the software.

Marius Popa liked this post

Necessitas – Qt for Android in one page

June 27, 2011 in Applications, C++, Frameworks, NDK, News, Qt framework

Necessitas migrates to kde infrastructure and hosting , here are some of the pages that you need to bookmark and use (if is not clear where too look for project’s resources):

Necessitas is a community-driven lighthouse-based port of Qt to Android [android.com]. It features the framework port but also a QtCreator plugin for development and debugging. There is also a installer application for Android called Ministro which does the task of downloading the Qt libraries to your device and interacting with a Qt application.

The project’s website is hosted at Sourceforge but development is done through KDE’s servers.

The project follows Qt’s own license policy and strives to be upstreamed ASAP.

Project resources:
Homepage [necessitas.sf.net]
Community page [community.kde.org]
General purpose mailing list [groups.google.com]
Development mailing list [mail.kde.org]
Ticket (bugs, features) system [bugs.kde.org]

ps: page was contributed on qt developer network (bug fixes and contributors are wellcome)

Necessitas alpha2 update 1

June 27, 2011 in Applications, C++, Frameworks, NDK, News, Programming, Qt framework

Today I have the honor to announce the first update of alpha2 release for Necessitas, we didn’t made big changes, we just tried to fix the most annoying issues:

  • fix compilation on all supported platforms.
  • update QtWebKit update to 2.1.1
  • better support of un-rooted devices

To test/use this release on your device, you must download Ministro configuration tool and switch to “unstable” repository, also you must uninstall the older version and download the newest installer from http://sourceforge.net/projects/necessitas/files/

For full change log please run:
$ git log n0.2..n0.21

Other changes:
ndk-r5c
android-sdk-r11
platform tools-r05

Special thanks goes to:
Ray Donnelly, Espen Riskedal, Marius Bugge Monsen.

Yours sincerely,
BogDan.