Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public int onStartCommand(Intent intent, int flags, int startId) {
- Log.e("InBackground", "Serviço em background iniciado");
- Intent newIntent = new Intent(getBaseContext(),Service.class);
- newIntent.putExtra("comando","AtualizaInBackground");
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- String CHANNEL_ID = "my_channel_01";
- NotificationChannel channel = new NotificationChannel(CHANNEL_ID, "Atualizações em Background.", NotificationManager.IMPORTANCE_NONE);
- ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).createNotificationChannel(channel);
- Notification notification = new NotificationCompat.Builder(getBaseContext(), CHANNEL_ID)
- .setContentTitle("")
- .setContentText("").build();
- startForeground(1, notification);
- }
- startService(newIntent);
- return START_STICKY;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement