diff --git a/retroshare-qml-app/src/android/AndroidManifest.xml b/retroshare-qml-app/src/android/AndroidManifest.xml index c5552d619..64b2bca6a 100644 --- a/retroshare-qml-app/src/android/AndroidManifest.xml +++ b/retroshare-qml-app/src/android/AndroidManifest.xml @@ -68,6 +68,12 @@ + + + + + + diff --git a/retroshare-qml-app/src/android/src/org/retroshare/android/qml_app/AppUpdatedReceiver.java b/retroshare-qml-app/src/android/src/org/retroshare/android/qml_app/AppUpdatedReceiver.java new file mode 100644 index 000000000..d9f87f650 --- /dev/null +++ b/retroshare-qml-app/src/android/src/org/retroshare/android/qml_app/AppUpdatedReceiver.java @@ -0,0 +1,36 @@ +/* + * RetroShare Android Service + * Copyright (C) 2016 Gioacchino Mazzurco + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package org.retroshare.android.qml_app; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.util.Log; + +public class AppUpdatedReceiver extends BroadcastReceiver +{ + @Override + public void onReceive(Context context, Intent intent) + { + Log.i("AppUpdatedReceiver", "onReceive() Restarting RetroShare Android Service After Update"); + Intent myIntent = new Intent(context, RetroShareAndroidService.class); + context.stopService(myIntent); + context.startService(myIntent); + } +} diff --git a/retroshare-qml-app/src/android/src/org/retroshare/android/qml_app/RetroShareQmlActivity.java b/retroshare-qml-app/src/android/src/org/retroshare/android/qml_app/RetroShareQmlActivity.java index 8e47563c8..faabc266b 100644 --- a/retroshare-qml-app/src/android/src/org/retroshare/android/qml_app/RetroShareQmlActivity.java +++ b/retroshare-qml-app/src/android/src/org/retroshare/android/qml_app/RetroShareQmlActivity.java @@ -18,6 +18,36 @@ package org.retroshare.android.qml_app; +import android.app.ActivityManager; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.util.Log; + import org.qtproject.qt5.android.bindings.QtActivity; -public class RetroShareQmlActivity extends QtActivity {} +public class RetroShareQmlActivity extends QtActivity +{ + @Override + public void onCreate(Bundle savedInstanceState) + { + if (!isMyServiceRunning(RetroShareAndroidService.class)) + { + Log.i("RetroShareQmlActivity", "onCreate(): RetroShareAndroidService is not running, let's start it by Intent"); + Intent rsIntent = new Intent(this, RetroShareAndroidService.class); + startService(rsIntent); + } + else Log.v("RetroShareQmlActivity", "onCreate(): RetroShareAndroidService already running"); + + super.onCreate(savedInstanceState); + } + + private boolean isMyServiceRunning(Class serviceClass) + { + ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); + for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) + if (serviceClass.getName().equals(service.service.getClassName())) + return true; + return false; + } +} diff --git a/retroshare-qml-app/src/qml.qrc b/retroshare-qml-app/src/qml.qrc index c2fd19fdc..a0211e789 100644 --- a/retroshare-qml-app/src/qml.qrc +++ b/retroshare-qml-app/src/qml.qrc @@ -1,8 +1,5 @@ - main.qml - Page1.qml - Page1Form.ui.qml qml/main.qml qml/icons/star-2-128.png qml/icons/settings-4-128.png