Android Open Source - wifi-auto-forget Connectivity Change Service






From Project

Back to project page wifi-auto-forget.

License

The source code is released under:

GNU General Public License

If you think the Android project wifi-auto-forget listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.cebesius.wifiautoforget.service;
/*from w  ww  .ja v  a2 s .co m*/
import android.app.IntentService;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.wifi.WifiManager;
import android.preference.PreferenceManager;

import com.cebesius.wifiautoforget.gateway.AddWifiNotificationUsageStorage;
import com.cebesius.wifiautoforget.gateway.AutoForgetWifiStorage;
import com.cebesius.wifiautoforget.mvp.ConnectivityChangeModel;
import com.cebesius.wifiautoforget.mvp.ConnectivityChangePresenter;
import com.cebesius.wifiautoforget.mvp.ConnectivityChangeView;


/**
 * An {@link IntentService} subclass for handling asynchronous task requests in
 * a service on a separate handler thread.
 */
public class ConnectivityChangeService extends IntentService {

    public static final String EXTRA_NETWORK_TYPE = ConnectivityManager.EXTRA_NETWORK_TYPE;
    /**
     * Starts this service to handle the given broadcast intent. If
     * the service is already performing a task this action will be queued.
     *
     * @see IntentService
     */
    public static void start(Context context, Intent broadcastIntent) {
        Intent intent = new Intent(context, ConnectivityChangeService.class);
        intent.putExtra(EXTRA_NETWORK_TYPE, broadcastIntent.getIntExtra(EXTRA_NETWORK_TYPE, 0));
        context.startService(intent);
    }

    public ConnectivityChangeService() {
        super(ConnectivityChangeService.class.getCanonicalName());
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        AutoForgetWifiStorage autoForgetWifiStorage = new AutoForgetWifiStorage();
        ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
        WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
        NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        AddWifiNotificationUsageStorage addWifiNotificationUsageStorage = new AddWifiNotificationUsageStorage(
                PreferenceManager.getDefaultSharedPreferences(this)
        );
        ConnectivityChangePresenter presenter = new ConnectivityChangePresenter(
                new ConnectivityChangeModel(
                        autoForgetWifiStorage,
                        connectivityManager,
                        wifiManager,
                        addWifiNotificationUsageStorage
                ),
                new ConnectivityChangeView(this, notificationManager)
        );
        presenter.present();
    }
}




Java Source Code List

antoche.HockeySender.java
com.cebesius.wifiautoforget.Secrets.java
com.cebesius.wifiautoforget.WifiAutoForgetApplication.java
com.cebesius.wifiautoforget.activity.AutoForgetWifisActivity.java
com.cebesius.wifiautoforget.adapter.AutoForgetWifisAdapter.java
com.cebesius.wifiautoforget.dialog.ChangeAutoForgetBehaviorDialog.java
com.cebesius.wifiautoforget.domain.AutoForgetWifi.java
com.cebesius.wifiautoforget.gateway.AddWifiNotificationUsageStorage.java
com.cebesius.wifiautoforget.gateway.AutoForgetWifiStorage.java
com.cebesius.wifiautoforget.gateway.NotificationIds.java
com.cebesius.wifiautoforget.gateway.SharedPreferenceKeys.java
com.cebesius.wifiautoforget.gateway.UserPreferenceStorage.java
com.cebesius.wifiautoforget.model.AutoForgetWifiModel.java
com.cebesius.wifiautoforget.mvp.ActivityView.java
com.cebesius.wifiautoforget.mvp.AddWifiModel.java
com.cebesius.wifiautoforget.mvp.AddWifiPresenter.java
com.cebesius.wifiautoforget.mvp.AddWifiView.java
com.cebesius.wifiautoforget.mvp.AppModel.java
com.cebesius.wifiautoforget.mvp.AppPresenter.java
com.cebesius.wifiautoforget.mvp.AppView.java
com.cebesius.wifiautoforget.mvp.AutoForgetWifisModel.java
com.cebesius.wifiautoforget.mvp.AutoForgetWifisPresenter.java
com.cebesius.wifiautoforget.mvp.AutoForgetWifisView.java
com.cebesius.wifiautoforget.mvp.ConnectivityChangeModel.java
com.cebesius.wifiautoforget.mvp.ConnectivityChangePresenter.java
com.cebesius.wifiautoforget.mvp.ConnectivityChangeView.java
com.cebesius.wifiautoforget.receiver.ConnectivityChangeReceiver.java
com.cebesius.wifiautoforget.service.AddWifiService.java
com.cebesius.wifiautoforget.service.ConnectivityChangeService.java
com.cebesius.wifiautoforget.util.AutoForgetDelegate.java
com.cebesius.wifiautoforget.util.BusPortal.java
com.cebesius.wifiautoforget.widget.AutoForgetWifiItem.java