Kill service when task manager kills UI and restart it when receiving push notification
This commit is contained in:
parent
1bea88a3d0
commit
a49cf71f54
5 changed files with 21 additions and 2 deletions
|
@ -14,6 +14,7 @@ size=vga
|
|||
[app]
|
||||
sharing_server=https://www.linphone.org:444/lft.php
|
||||
tunnel=disabled
|
||||
push_notification=1
|
||||
|
||||
[tunnel]
|
||||
host=
|
||||
|
|
|
@ -14,6 +14,7 @@ size=qvga
|
|||
[app]
|
||||
sharing_server=https://www.linphone.org:444/lft.php
|
||||
tunnel=disabled
|
||||
push_notification=1
|
||||
|
||||
[tunnel]
|
||||
host=
|
||||
|
|
|
@ -73,7 +73,6 @@
|
|||
<bool name="intercept_outgoing_gsm_calls">false</bool>
|
||||
<bool name="automatically_start_intercepted_outgoing_gsm_call">true</bool>
|
||||
<bool name="use_linphonecore_ringing">false</bool>
|
||||
|
||||
<!-- This settings handle the behavior of the view waiting for the remote provisioning configuration to be done -->
|
||||
<bool name="display_sms_remote_provisioning_activity">false</bool>
|
||||
<bool name="forbid_app_usage_until_remote_provisioning_completed">false</bool>
|
||||
|
@ -91,5 +90,6 @@
|
|||
<string name="temp_photo_name_with_date">linphone-android-photo-%s.jpg</string>
|
||||
|
||||
<bool name="enable_call_notification">true</bool>
|
||||
<bool name="kill_service_with_task_manager">true</bool>
|
||||
</resources>
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.linphone.core.LinphoneProxyConfig;
|
|||
import org.linphone.mediastream.Log;
|
||||
import org.linphone.mediastream.Version;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.AlarmManager;
|
||||
import android.app.Notification;
|
||||
|
@ -553,6 +554,17 @@ public final class LinphoneService extends Service {
|
|||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
|
||||
@Override
|
||||
public void onTaskRemoved(Intent rootIntent) {
|
||||
if (getResources().getBoolean(R.bool.kill_service_with_task_manager)) {
|
||||
Log.d("Task removed, stop service");
|
||||
LinphoneManager.getLc().setNetworkReachable(false);
|
||||
stopSelf();
|
||||
}
|
||||
super.onTaskRemoved(rootIntent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onDestroy() {
|
||||
|
|
|
@ -18,8 +18,11 @@ along with this program; if not, write to the Free Software
|
|||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
import static android.content.Intent.ACTION_MAIN;
|
||||
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphonePreferences;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.R;
|
||||
import org.linphone.UIThreadDispatcher;
|
||||
import org.linphone.mediastream.Log;
|
||||
|
@ -47,7 +50,9 @@ public class GCMService extends GCMBaseIntentService {
|
|||
@Override
|
||||
protected void onMessage(Context context, Intent intent) {
|
||||
Log.d("Push notification received");
|
||||
if (LinphoneManager.isInstanciated() && LinphoneManager.getLc().getCallsNb() == 0) {
|
||||
if (!LinphoneService.isReady()) {
|
||||
startService(new Intent(ACTION_MAIN).setClass(this, LinphoneService.class));
|
||||
} else if (LinphoneManager.isInstanciated() && LinphoneManager.getLc().getCallsNb() == 0) {
|
||||
UIThreadDispatcher.dispatch(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
Loading…
Reference in a new issue