Disabling Android O auto-fill service for an application

Currently there is no direct way to disable the autofill for an entire application, since the autofill feature is View specific. You can still try this way and call BaseActivity everywhere. public class BaseActivity extends AppCompatActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); disableAutofill(); } @TargetApi(Build.VERSION_CODES.O) private void disableAutofill() { getWindow().getDecorView().setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS); } } You … Read more

Android O – Old start foreground service still working?

This worked for me. In Activity class, start service using startForegroundService() instead of startService() Intent myService = new Intent(this, MyService.class); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { startForegroundService(myService); } else { startService(myService); } Now in Service class in onStartCommand() do as following @Override public int onStartCommand(Intent intent, int flags, int startId) { …… if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) … Read more

How to turn on/off wifi hotspot programmatically in Android 8.0 (Oreo)

I thought the LocalOnlyHotspot route was the way to, but as @edsappfactory.com said in the comments – it only gives closed network, no internet access. In Oreo hot-spotting/tethering moved to ConnectionManager, and its annotated @SystemApi, so (nominally) inaccessible. As part of something else I was doing, I made an app and put it on github … Read more

Background service for android oreo

If you would have read the Android Oreo 8.0 Documentation properly somewhere in here, you might not have posted this question here. Step 1: Make sure you start a service as a foreground Service as given in below code ContextCompat.startForegroundService(mainActivity, new Intent(getContext(), GpsServices.class)); ContextCompat.startForegroundService(mainActivity, new Intent(getContext(), BluetoothService.class)); ContextCompat.startForegroundService(mainActivity, new Intent(getContext(), BackgroundApiService.class)); Step 2: Use notification … Read more

Context.startForegroundService() did not then call Service.startForeground()

From Google’s docs on Android 8.0 behavior changes: The system allows apps to call Context.startForegroundService() even while the app is in the background. However, the app must call that service’s startForeground() method within five seconds after the service is created. Solution: Call startForeground() in onCreate() for the Service which you use Context.startForegroundService() See also: Background … Read more

Android 8.0: java.lang.IllegalStateException: Not allowed to start service Intent

I got solution. For pre-8.0 devices, you have to just use startService(), but for post-7.0 devices, you have to use startForgroundService(). Here is sample for code to start service. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { context.startForegroundService(new Intent(context, ServedService.class)); } else { context.startService(new Intent(context, ServedService.class)); } And in service class, please add the code below for notification: … Read more