Back to project page wifi-auto-forget.
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.
package com.cebesius.wifiautoforget.service; /* w w w. j a v a 2s . com*/ import android.app.IntentService; import android.app.NotificationManager; import android.content.Intent; import android.content.Context; import android.preference.PreferenceManager; import com.cebesius.wifiautoforget.domain.AutoForgetWifi; import com.cebesius.wifiautoforget.gateway.AddWifiNotificationUsageStorage; import com.cebesius.wifiautoforget.gateway.AutoForgetWifiStorage; import com.cebesius.wifiautoforget.gateway.NotificationIds; import com.cebesius.wifiautoforget.mvp.AddWifiModel; import com.cebesius.wifiautoforget.mvp.AddWifiPresenter; import com.cebesius.wifiautoforget.mvp.AddWifiView; import com.cebesius.wifiautoforget.util.BusPortal; /** * An {@link IntentService} subclass for handling asynchronous task requests in * a service on a separate handler thread. */ public class AddWifiService extends IntentService { public static final String EXTRA_SSID = "ssid"; public static final String EXTRA_AUTOFORGET_BEHAVIOR = "autoForgetBehavior"; private AddWifiPresenter addWifiPresenter; public AddWifiService() { super(AddWifiService.class.getCanonicalName()); } public static final Intent buildIntent(Context context, AutoForgetWifi autoForgetWifi, AutoForgetWifi.Behavior behavior) { return new Intent(context, AddWifiService.class) .putExtra(EXTRA_SSID, autoForgetWifi.getSsid()) .putExtra(EXTRA_AUTOFORGET_BEHAVIOR, behavior); } @Override protected void onHandleIntent(Intent intent) { NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationManager.cancel(NotificationIds.CONNECTED_UNKNOWN_WIFI); AutoForgetWifi autoForgetWifi = new AutoForgetWifi( intent.getStringExtra(EXTRA_SSID), (AutoForgetWifi.Behavior) intent.getSerializableExtra(EXTRA_AUTOFORGET_BEHAVIOR) ); AddWifiModel addWifiModel = new AddWifiModel( new AutoForgetWifiStorage(), new AddWifiNotificationUsageStorage(PreferenceManager.getDefaultSharedPreferences(this))); AddWifiView addWifiView = new AddWifiView(this, BusPortal.getInstance()); addWifiPresenter = new AddWifiPresenter(addWifiModel, addWifiView); addWifiPresenter.addNetwork(autoForgetWifi); } }