Resolve lint warnings in HotspotService.java

This commit is contained in:
Adeel Zafar 2019-08-02 03:04:32 +05:00
parent e45f36d29e
commit 2bdff5aba6

View File

@ -39,14 +39,16 @@ public class HotspotService extends Service {
@Override public void onCreate() { @Override public void onCreate() {
super.onCreate(); super.onCreate();
stopReceiver = new BroadcastReceiver() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
@Override stopReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) { @Override
if (intent != null && intent.getAction().equals(ACTION_STOP)) { public void onReceive(Context context, Intent intent) {
stopHotspot(); if (intent != null && intent.getAction().equals(ACTION_STOP)) {
stopHotspot();
}
} }
} };
}; }
registerReceiver(stopReceiver, new IntentFilter(ACTION_STOP)); registerReceiver(stopReceiver, new IntentFilter(ACTION_STOP));
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
startForeground(HOTSPOT_NOTIFICATION_ID, startForeground(HOTSPOT_NOTIFICATION_ID,
@ -110,7 +112,7 @@ public class HotspotService extends Service {
} }
@RequiresApi(Build.VERSION_CODES.O) @RequiresApi(Build.VERSION_CODES.O)
private void stopHotspot() { void stopHotspot() {
hotspotManager.turnOffHotspot(); hotspotManager.turnOffHotspot();
stopForeground(true); stopForeground(true);
stopSelf(); stopSelf();