[Interest] Fwd: How to shutdown Qt app on Android.

Robert Iakobashvili coroberti at gmail.com
Tue Jan 27 11:27:43 CET 2015


Dear Igor,

1. Arrange forceClosingMyApp in your derived activity:

package com.myComp.MyProduct.activity;

import java.lang.String;
import android.os.Bundle;
import android.util.Log;
import android.content.Intent;
import android.app.Activity;
import android.view.KeyEvent;

import org.qtproject.qt5.android.bindings.QtActivity;

public class MyActivity extends org.qtproject.qt5.android.bindings.QtActivity
{
private static final String TAG = "MyActivity";
private static MyActivity m_MyActivityInstance = null;

public static MyActivity getMyActivityInstance()
{
    return MyActivity.m_MyActivityInstance;
}

@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);

    /* Do your staff here: */
    MyActivity.m_MyActivityInstance = this;
}

@Override
protected void onResume()
{
    super.onResume();
    //Log.v(TAG, "onResume - entered");
}

@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
    if( (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_UP) ||
    (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_DOWN) ||
    (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_MUTE ) ) {
        return super.super_onKeyDown(keyCode,event);
    }
    else{
        return super.onKeyDown(keyCode,event);
    }
}

public static void forceClosingMyActivity()
{
    //Log.v(TAG, "forceClosingMyActivity - entered");
    m_MyActivityInstance.finish();

}
}

2. Catch the Home Button event
and call forceClosingMyActivity() via JNI

3. If not helpful, ask at android-development at qt-project.org

I hope this has help.

Regards,
Robert


On Mon, Jan 26, 2015 at 8:24 AM, Igor Mironchik
<igor.mironchik at gmail.com> wrote:
> Hi.
>
> How to completely shutdown Qt app on Adnroid when "Home" button pressed?
>
> I want to say when user presses "Home" button app will continue to work in
> background, i.e. the app shown in the list of apps when long touch "Home"
> button.
>
> How to prevent it and completely shutdown Qt app?
>
> Is it possible?
>
> --
> Best Regards,
> Igor Mironchik.
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest



More information about the Interest mailing list