Important: Please read the Qt Code of Conduct -

How to access android activity(dialog..) by using qt5.2?

  • Hello!
    I want to pass a filename from qt5.2 to android, and then display a android dialog.
    This means that Camera capture file of Qt5 will be display thru any algorithm on android dialog.
    but not called android activity dialog..
    Can anyone edit below a part of code? Help~

    (qt5.2 code)

         void Camera::imageSaved(int id, const QString &fileName)
         int d, t;
         d = dateString.toInt();  qDebug() << "Date=" &lt;&lt; d;
         t = timeString.toInt();  qDebug() &lt;&lt; "Time=" &lt;&lt; t;
         jint ret = QAndroidJniObject::callStaticMethod&lt;jint&gt;("org/qtproject/example/shfguard/QtCamera", "sendDate", "(I)I", d);
         ret = QAndroidJniObject::callStaticMethod<jint>("org/qtproject/example/shfguard/QtCamera", "sendTime", "(I)I", t);


            public class QtCamera extends
            public static int sendTime(int t) {
          String s = String.format("%d", t);
          EnrollFilename += s;
          EnrollFilename += ".jpg";
          return 1;
        public static int enrollment() {
          Context c = null;
          Intent intent = new Intent(new QtCamera(), InitActivity.class);//not-static value...error part!
          intent.putExtra("filename", EnrollFilename);
          c.startActivity(intent);//not-static value...error part!
          return 1;


            public class InitActivity extends ListActivity {
         public void onCreate(Bundle savedInstanceState) {
          Intent intent = getIntent(); 
                //Bundle extras = getIntent().getExtras();
                EnrollFilename = intent.getStringExtra("filename");           


                <activity android:name=".QtCamera" android:label="QtCamera"/>
                <activity android:name=".InitActivity" android:label="@string/app_name" android:configChanges="keyboardHidden|orientation"/>


  • Moderators


    bq. This means that Camera capture file of Qt5 will be display thru any algorithm on android dialog.

    Do you mean you want to use Android Intents ?

  • Thank you for reply.
    First of all, I want to display a dialog of InitActivity's setContentView(R.layout.activity_main)..
    but , I can't access it.

  • Moderators


    Sorry but i have never called a Custom Class using Intents. But i have managed to call Standard Activity Actions.
    Have you made sure that the QtCamera class gets using callStaticMethod ?

Log in to reply