mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 00:19:25 -05:00
Start RetroShare Android Service when needed
RetroShareQmlActivity checks if the service is running, and start it if not The service is restarted on package update Remove non existents qml files from qrc
This commit is contained in:
parent
c6ec085519
commit
ad21d7202a
@ -68,6 +68,12 @@
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver android:name=".AppUpdatedReceiver" android:enabled="true" android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->
|
||||
<service android:process=":rs" android:name=".RetroShareAndroidService" android:label="RetroShare Service" android:exported="true"> <!-- Added to be able to run the service from adb shell -->
|
||||
<!-- android:process=":qt" is needed to force the service to run on a separate process than the Activity -->
|
||||
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* RetroShare Android Service
|
||||
* Copyright (C) 2016 Gioacchino Mazzurco <gio@eigenlab.org>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>main.qml</file>
|
||||
<file>Page1.qml</file>
|
||||
<file>Page1Form.ui.qml</file>
|
||||
<file>qml/main.qml</file>
|
||||
<file>qml/icons/star-2-128.png</file>
|
||||
<file>qml/icons/settings-4-128.png</file>
|
||||
|
Loading…
Reference in New Issue
Block a user