foregroundnotification

Can we avoid stopForeground to stop Service

送分小仙女□ 提交于 2020-06-29 06:43:23
问题 I have a Service which I use ExoPlayer to play music in it. I am displaying a notification for my app as it is a Foreground Service and I keep updating Notification in onPlayerStateChanged callback method of ExoPlayer : @Override public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { ... showNotification(state, sample); } private void showNotification(PlaybackStateCompat state, Sample sample) { NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "Id

Inject keyboard event into NSRunningApplication immediately after foregrounding it

天大地大妈咪最大 提交于 2020-01-30 10:50:46
问题 I am trying to bring to foreground a NSRunningApplication* instance, and inject a keyboard event. NSRunningApplication* app = ...; [app activateWithOptions: 0]; inject_keystrokes(); ... fails to inject keyboard events, but: NSRunningApplication* app = ...; [app activateWithOptions: 0]; dispatch_time_t _100ms = dispatch_time( DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC) ); dispatch_after( _100ms, dispatch_get_main_queue(), ^{ inject_keystrokes(); } ); ... succeeds. I imagine it takes a

Inject keyboard event into NSRunningApplication immediately after foregrounding it

≯℡__Kan透↙ 提交于 2020-01-30 10:48:06
问题 I am trying to bring to foreground a NSRunningApplication* instance, and inject a keyboard event. NSRunningApplication* app = ...; [app activateWithOptions: 0]; inject_keystrokes(); ... fails to inject keyboard events, but: NSRunningApplication* app = ...; [app activateWithOptions: 0]; dispatch_time_t _100ms = dispatch_time( DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC) ); dispatch_after( _100ms, dispatch_get_main_queue(), ^{ inject_keystrokes(); } ); ... succeeds. I imagine it takes a

Forgeround service stop after a few minutes or locking the phone

核能气质少年 提交于 2019-12-10 18:05:48
问题 I try to create foreground service that toast a message every 20 second but this service stop after a few minutes or locking the phone. I test this service in android 8 (O). my code is : @Override public int onStartCommand(Intent intent, int flags, int startId) { input = intent.getStringExtra("inputExtra"); new Thread(new Runnable() { public void run() { while (progressStatus < 10000000) { progressStatus += 1; handler.post(new Runnable() { @SuppressLint("MissingPermission") public void run()

Foreground notification service not working in one plus devices

余生颓废 提交于 2019-12-10 11:29:46
问题 Below is the code for starting the foreground service. It is working fine for many devices like Samsung, moto, Vivo, Oppo and also with Android version nougat and oreo, but not working on One plus devices. Can anyone let me know if any extra changes or permission is required to run in One plus device or if any emulator supports one plus phones. public class ForegroundService extends Service { private Context ctx; private static final String PRIMARY_NOTIF_CHANNEL = "default"; @Override public

Foreground notification service not working in one plus devices

*爱你&永不变心* 提交于 2019-12-06 09:26:23
Below is the code for starting the foreground service. It is working fine for many devices like Samsung, moto, Vivo, Oppo and also with Android version nougat and oreo, but not working on One plus devices. Can anyone let me know if any extra changes or permission is required to run in One plus device or if any emulator supports one plus phones. public class ForegroundService extends Service { private Context ctx; private static final String PRIMARY_NOTIF_CHANNEL = "default"; @Override public void onCreate() { super.onCreate(); ctx = this; createNotificationService(); } private void

Oreo - Starting a service in the foreground

旧时模样 提交于 2019-11-28 00:24:55
问题 I have created a service that tracks the device's location as it moves. The service is started in by an Activity that binds to it, and in this activity there is a "Start Tracking" button. When this button is pressed, I need the service to start in the foreground, so that it stores the Locations that the device has moved to, even if the Activity that binds to it is closed, or the app is minimised. I understand that for the Service to be in the foreground, a notification must be displayed. I