android-8.0-oreo
Android O : PHONE_STATE broadcast limitation
Eventually, the action was added to the “Implicit Broadcast Exceptions” list so you can add ACTION_PHONE_STATE_CHANGED to your manifest and it will work: https://developer.android.com/guide/components/broadcast-exceptions ACTION_CARRIER_CONFIG_CHANGED, TelephonyIntents.ACTION_*_SUBSCRIPTION_CHANGED, “TelephonyIntents.SECRET_CODE_ACTION”, ACTION_PHONE_STATE_CHANGED, ACTION_PHONE_ACCOUNT_REGISTERED, ACTION_PHONE_ACCOUNT_UNREGISTERED OEM telephony apps may need to receive these broadcasts.
Android O – Single line Notification – like the “Android System – USB charging this device”
To display a compact single line notification like the charging notification, you have to create a Notification Channel with priority to IMPORTANCE_MIN. @TargetApi(Build.VERSION_CODES.O) private static void createFgServiceChannel(Context context) { NotificationChannel channel = new NotificationChannel(“channel_id”, “Channel Name”, NotificationManager.IMPORTANCE_MIN); NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.createNotificationChannel(channel); } And then create an ongoing notification like that: public static Notification … Read more
How To Properly Update A Widget In Android 8.0 – Oreo – API 26
You don’t indicate what the update trigger mechanism is. You seem concerned about latency (“Your widget may or may not get updated for a while”), so I am going to assume that your concern is tied to user interaction with the app widget, such as tapping a button. Use JobScheduler to schedule a job as … Read more
Custom JobIntentService onHandleWork not called
I had the same issue after upgrading from IntentService to JobIntentService. Make sure you remove this method from your old implementation: @Override public IBinder onBind(Intent intent) { return null; } For me this solved the problem, and now it works both on pre- and post-Oreo.
How do I check whether a specific notification channel is enabled in Android Oreo?
with backwards compatibility: public boolean isNotificationChannelEnabled(Context context, @Nullable String channelId){ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if(!TextUtils.isEmpty(channelId)) { NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); NotificationChannel channel = manager.getNotificationChannel(channelId); return channel.getImportance() != NotificationManager.IMPORTANCE_NONE; } return false; } else { return NotificationManagerCompat.from(context).areNotificationsEnabled(); } }
SecurityException: Failed to find provider null for user 0; on ActiveAndroid on Android 8.0
As pointed out by @GeigerGeek security changes on Android 26 and above require you to specify the content provider in your manifest. For ActiveAndroid you can add the below to your Manifest and change your package name. <provider android:name=”com.activeandroid.content.ContentProvider” android:authorities=”<your.package.name>” android:enabled=”true” android:exported=”false”> </provider> If using flavours on your build process you can use below instead: … Read more
Detect CONNECTIVITY CHANGE in Android 7 and above when app is killed/in background
Nougat and Above: We have to use JobScheduler and JobService for Connection Changes. All I can divide this into three steps. Register JobScheduler inside activity. Also, Start JobService( Service to handle callbacks from the JobScheduler. Requests scheduled with the JobScheduler ultimately land on this service’s “onStartJob” method.) public class NetworkConnectionActivity extends AppCompatActivity { @Override protected … Read more
On Android 8.1 API 27 notification does not display
If you get this error should be paid attention to 2 items and them order: NotificationChannel mChannel = new NotificationChannel(id, name, importance); builder = new NotificationCompat.Builder(context, id); Also NotificationManager notifManager and NotificationChannel mChannel are created only once. There are required setters for Notification: builder.setContentTitle() // required .setSmallIcon() // required .setContentText() // required See example: private … Read more