Implemented starting service when connectivity is changed (for ex, Internet are available)

This commit is contained in:
ChronosX88 2019-05-24 16:25:22 +04:00
parent 6189252f2c
commit 88c061da45
2 changed files with 33 additions and 1 deletions

View File

@ -36,10 +36,14 @@
android:enabled="true"
android:exported="true" />
<receiver android:name=".ConnectivityChangeListener" >
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
<activity android:name=".views.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

View File

@ -0,0 +1,28 @@
/*
* Copyright 2019 ChronosX88
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.chronosx88.influence;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class ConnectivityChangeListener extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
context.startService(new Intent(context, XMPPConnectionService.class));
}
}