Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to access android activity(dialog..) by using qt5.2?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Mobile and Embedded
4 Posts 2 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jamesLee
    wrote on last edited by
    #1

    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;
    
         Q_UNUSED(id);
            Q_UNUSED(fileName);
    
         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);
        }
    

    (Android-4.2.2)
    (QtCamera.java)

            public class QtCamera extends org.qtproject.qt5.android.bindings.QtActivity
        {
        ...........
            public static int sendTime(int t) {
         
          String s = String.format("%d", t);
          EnrollFilename += s;
          EnrollFilename += ".jpg";
          System.out.println(EnrollFilename);
        
          enrollment();
        
          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!
          System.out.println("enrollment:");
        
          return 1;
        }
        }
    

    (InitActivity.java)

            public class InitActivity extends ListActivity {
        ..............
         @Override
         public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          
           setContentView(R.layout.activity_main);
          System.out.println("InitActivity:");
                       ...............
          Intent intent = getIntent(); 
        
                //Bundle extras = getIntent().getExtras();
                EnrollFilename = intent.getStringExtra("filename");           
                   ..............
        }
    

    (AndroidManifest.xml)

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

    @

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      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 ?

      157

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jamesLee
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          Hi,

          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 ?

          157

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved