I have problem with my app for Android. When I run my app using Android studio, I start a servis (foreground) and it works. But When I disconnect my device from computer, and run service, he doesnt work.
I run NotificationListenerService. Someone knows what could be the cause of this ? Please help
public int onStartCommand(Intent intent, int flags, int startId) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel notificationChannel = new NotificationChannel(
"abc.eu", "xyzabc", NotificationManager.IMPORTANCE_HIGH
);
NotificationManager manager = getSystemService(NotificationManager.class);
manager.createNotificationChannel(notificationChannel);
}
Intent intent1 = new Intent(this, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent1, PendingIntent.FLAG_UPDATE_CURRENT);
Notification notification = new NotificationCompat.Builder(this, "abc.eu")
.setContentTitle("title")
.setContentText("Content")
.setContentIntent(pendingIntent).build();
startForeground(1, notification);
packageManager = getPackageManager();
apps = loadData(apps);
Log.d("MainService", "onStartCommand");
return START_STICKY;
}