Java function from c++

Showing 1-18 of 18 messages
Java function from c++ Sergey Chernik 2/27/12 5:59 AM
How call java function from с++? I need in detailed description
Re: Java function from c++ CMGeorge 2/27/12 6:08 AM
I'm working right now on this, but i didn't succeed on this.

JavaVM* m_javaVM = (JavaVM*)QApplication::platformNativeInterface()->nativeResourceForWidget("JavaVM",0);
return always 0xaa00

and

UnionJNIEnvToVoid uenv; uenv.venv = NULL; qDebug()<<m_javaVM->GetEnv(&uenv.venv, JNI_VERSION_1_4);


return -2;


2012/2/27 Sergey Chernik <used...@gmail.com>

How call java function from с++? I need in detailed description

Re: Java function from c++ Sergey Chernik 2/27/12 10:06 PM
You can get JavaVM using "extern" before JavaVM, if you removed static
keyword from m_javaVM in qtmain_android.cpp.
Look:  https://groups.google.com/forum/#!msg/android-qt/MesA5b2Bpv0/S1EmaNZP28IJ

It's work until I try to find my function Id,  env->GetStaticMethodID
return always 0;
Re: Java function from c++ CMGeorge 2/28/12 6:30 AM
For me the error for
jmethodID playMediaFileMethodID = m_env->GetStaticMethodID(applicationClass,"playMediaFile", "(Ljava/lang/String;)V");

No method from QtApplicaiton.java can be found.

is:

D/Qt (11827): Java Class is: 0x466fc570

W/dalvikvm(11827): threadid=9: thread exiting with uncaught exception (group=0x40020c18)

E/AndroidRuntime(11827): FATAL EXCEPTION: Thread-15

E/AndroidRuntime(11827): java.lang.NoSuchMethodError: playMediaFile

E/AndroidRuntime(11827): at dalvik.system.NativeStart.run(Native Method)

Re: Java function from c++ CMGeorge 2/28/12 9:54 AM

I successfully call Java function from Qt/C++. I will create a little tutorial in few hours. I don't know if this is the best approach, but at least it works and can be used for various tasks.

--

Sent from my Nokia N9

Re: Java function from c++ Nilson Aguiar 2/28/12 10:06 AM
Thanks CMGeorge I'm new in Qt and I will apreciate your tutorial!

Em terça-feira, 28 de fevereiro de 2012 14h54min08s UTC-3, CMGeorge escreveu:
Re: Java function from c++ CMGeorge 2/28/12 12:05 PM
I've added a post to my mini-blog related to changes made to use Java Class into the Necessitas.
http://blog.wesell.ro/2012-02/how-to-use-java-from-qtc-in-necessitas/

Best regards,
George Calugar
Re: Java function from c++ Endy Silveira 2/29/12 9:51 AM
Hello George,

I'm working over Necessitas 0.21, theres any way to do the samething
you do at necessitas 0.3 update 4? It would be REALLY great!

Bests,

Endy

On 28 fev, 17:05, Calugar Mircea - George <geo...@wesell.ro> wrote:
> I've added a post to my mini-blog related to changes made to use Java
> Class into the Necessitas.http://blog.wesell.ro/2012-02/how-to-use-java-from-qtc-in-necessitas/
>
> Best regards,
> George Calugar
>
> On 28.02.2012 20:06, Nilson Aguiar wrote:
>
>
>
>
>
>
>
> > Thanks CMGeorge I'm new in Qt and I will apreciate your tutorial!
>
> > Em terça-feira, 28 de fevereiro de 2012 14h54min08s UTC-3, CMGeorge
> > escreveu:
>
> >     I successfully call Java function from Qt/C++. I will create a
> >     little tutorial in few hours. I don't know if this is the best
> >     approach, but at least it works and can be used for various tasks.
>
> >     --
>
> >     Sent from my Nokia N9
>
> >     On 28.02.2012 08:06 Sergey Chernik wrote:
>
> >     You can get JavaVM using "extern" before JavaVM, if you removed static
> >     keyword from m_javaVM in qtmain_android.cpp.
> >     Look:
> >    https://groups.google.com/forum/#!msg/android-qt/MesA5b2Bpv0/S1EmaNZP...
> >     <https://groups.google.com/forum/#%21msg/android-qt/MesA5b2Bpv0/S1EmaN...>
Re: Java function from c++ CMGeorge 2/29/12 9:59 AM
Sorry, but i don't have 0.21. If you have the qtmain_android.cpp, you
can send it to me and take a look over it.

On 29.02.2012 19:51, Endy Silveira wrote:
> Hello George,
>
> I'm working over Necessitas 0.21, theres any way to do the samething
> you do at necessitas 0.3 update 4? It would be REALLY great!
>
> Bests,
>
> Endy
>
> On 28 fev, 17:05, Calugar Mircea - George<geo...@wesell.ro>  wrote:
>> I've added a post to my mini-blog related to changes made to use Java
>> Class into the Necessitas.http://blog.wesell.ro/2012-02/how-to-use-java-from-qtc-in-necessitas/
>>
>> Best regards,
>> George Calugar
>>
>> On 28.02.2012 20:06, Nilson Aguiar wrote:
>>
>>
>>
>>
>>
>>
>>
>>> Thanks CMGeorge I'm new in Qt and I will apreciate your tutorial!
>>> Em ter�a-feira, 28 de fevereiro de 2012 14h54min08s UTC-3, CMGeorge

>>> escreveu:
>>>      I successfully call Java function from Qt/C++. I will create a
>>>      little tutorial in few hours. I don't know if this is the best
>>>      approach, but at least it works and can be used for various tasks.
>>>      --
>>>      Sent from my Nokia N9
>>>      On 28.02.2012 08:06 Sergey Chernik wrote:
>>>      You can get JavaVM using "extern" before JavaVM, if you removed static
>>>      keyword from m_javaVM in qtmain_android.cpp.
>>>      Look:
>>>     https://groups.google.com/forum/#!msg/android-qt/MesA5b2Bpv0/S1EmaNZP...
>>>      <https://groups.google.com/forum/#%21msg/android-qt/MesA5b2Bpv0/S1EmaN...>
>>>      It's work until I try to find my function Id, env->GetStaticMethodID
>>>      return always 0;

Re: Java function from c++ Endy Silveira 2/29/12 12:20 PM
Got it, nothing of great diference, I can do it ;D

Thanks!

Endy

On 29 fev, 14:59, Calugar Mircea - George <geo...@wesell.ro> wrote:
> Sorry, but i don't have 0.21. If you have the qtmain_android.cpp, you
> can send it to me and take a look over it.
>
> On 29.02.2012 19:51, Endy Silveira wrote:
>
>
>
>
>
>
>
> > Hello George,
>
> > I'm working over Necessitas 0.21, theres any way to do the samething
> > you do at necessitas 0.3 update 4? It would be REALLY great!
>
> > Bests,
>
> > Endy
>
> > On 28 fev, 17:05, Calugar Mircea - George<geo...@wesell.ro>  wrote:
> >> I've added a post to my mini-blog related to changes made to use Java
> >> Class into the Necessitas.http://blog.wesell.ro/2012-02/how-to-use-java-from-qtc-in-necessitas/
>
> >> Best regards,
> >> George Calugar
>
> >> On 28.02.2012 20:06, Nilson Aguiar wrote:
>
> >>> Thanks CMGeorge I'm new in Qt and I will apreciate your tutorial!
> >>> Em ter a-feira, 28 de fevereiro de 2012 14h54min08s UTC-3, CMGeorge
Re: Java function from c++ Ole-Johan 3/1/12 5:43 AM
Great stuff, George! The Java <-> Qt/C++ bridge is open once again, on
Necessitas alpha 3 update 4! :)

Just wanted to add a little something that I used this for:
In my java file (JavaManager from George's blog), I needed to run
startActivity(intent). And to do that I need access to a valid
activity, like m_mainActivity in the old Java/C++ bridge. I solved
that by modifying QtActivity.java, adding a static reference to the
QtActivity class itself, and a static method that returns this
reference. I set the static value to "this" in loadApplication().
After that, in the custom java class (JavaManager), I call the static
method in QtActivity, and I get my reference from which I can call
startActivity().

Hope this helps if anyone else needs to do the same!

Best regards,
Ole-Johan



On Feb 28, 9:05 pm, Calugar Mircea - George <geo...@wesell.ro> wrote:
> I've added a post to my mini-blog related to changes made to use Java
> Class into the Necessitas.http://blog.wesell.ro/2012-02/how-to-use-java-from-qtc-in-necessitas/
>
> Best regards,
> George Calugar
>
> On 28.02.2012 20:06, Nilson Aguiar wrote:
>
>
>
>
>
>
>
> > Thanks CMGeorge I'm new in Qt and I will apreciate your tutorial!
>
> > Em terça-feira, 28 de fevereiro de 2012 14h54min08s UTC-3, CMGeorge
> > escreveu:
>
> >     I successfully call Java function from Qt/C++. I will create a
> >     little tutorial in few hours. I don't know if this is the best
> >     approach, but at least it works and can be used for various tasks.
>
> >     --
>
> >     Sent from my Nokia N9
>
> >     On 28.02.2012 08:06 Sergey Chernik wrote:
>
> >     You can get JavaVM using "extern" before JavaVM, if you removed static
> >     keyword from m_javaVM in qtmain_android.cpp.
> >     Look:
> >    https://groups.google.com/forum/#!msg/android-qt/MesA5b2Bpv0/S1EmaNZP...
> >     <https://groups.google.com/forum/#%21msg/android-qt/MesA5b2Bpv0/S1EmaN...>
unk...@googlegroups.com 3/2/12 6:17 AM <This message has been deleted.>
unk...@googlegroups.com 3/5/12 8:32 AM <This message has been deleted.>
Re: Java function from c++ Nilson Aguiar 3/6/12 9:10 AM
Hi George, can you send to us (in your blog or here) a sample project with the qtmain_android.cpp and the project, i'm having trouble to make it work

just a sample like a qDebug and a Log.e() just to discover how to setup the enviroment!



Best Regards,
Nilson Aguiar
Re: Java function from c++ Michał Kowalczyk 4/1/12 6:55 PM
For those who still have some problems with communication between Necessitas application and Java, I wrote little article:
http://mkk.ekk.pl/?wpis=3
I hope that it's clear and will be useful.


W dniu poniedziałek, 27 lutego 2012, 14:59:20 UTC+1 użytkownik Sergey Chernik napisał:
Re: Java function from c++ alicemirror 4/1/12 10:18 PM

Great! Thank you :)

El 02/04/2012 03:55, "Michał Kowalczyk" <m...@ekk.pl> escribió:
Re: Java function from c++ Tyler Mandry 4/2/12 9:15 AM
FYI, I submitted a patch for the next alpha4 that opens up Java<->C++ (both ways), just as it was before alpha3. Basically it will be as if writing a standard JNI application, with your own JNI_OnLoad and all that. No more qtmain_android. BogDan says it will be in alpha4. See https://git.reviewboard.kde.org/r/104450/
--
Tyler Mandry
Re: Java function from c++ tomasl 8/28/12 12:48 PM
Hi, has anyone been able to use this new Java <> C++ link now provided with alpha 4?  Both in alpha3 and previously, we hacked the qtmain_android.cpp and Application.java files to be able to do what we wanted (in alpha 3, we basicly followed this [1]). If anyone has an example or best practice, I think now is the time to show the world :)

Cheers,