Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The moveToForeground function doesn't work on Android 8 #414

Open
jjvillavicencio opened this issue Nov 28, 2018 · 2 comments
Open

The moveToForeground function doesn't work on Android 8 #414

jjvillavicencio opened this issue Nov 28, 2018 · 2 comments

Comments

@jjvillavicencio
Copy link

In android 8 when the application goes to the background (My ionic app) and then another application is opened (Example Whatsapp), and the function is called to move to the foreground, the application that opens is WhatsApp and not my app ionic

@EriveltonMS
Copy link

I make changes on ForegroundService.java to fix this:
After line 38 "import java.lang.reflect.Method;" add:
import android.app.NotificationChannel; import android.graphics.Color;
After line 168 " .setSmallIcon(getIconResId(settings));" add:
if (android.os.Build.VERSION.SDK_INT >= 26) { //Set the channel’s ID// String CHANNEL_ONE_ID = "com.klam.furnasconnet.ONE"; //Set the channel’s user-visible name// String CHANNEL_ONE_NAME = "Channel One"; //This only needs to be run on Devices on Android O and above NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); NotificationChannel mChannel = new NotificationChannel(CHANNEL_ONE_ID, CHANNEL_ONE_NAME, NotificationManager.IMPORTANCE_DEFAULT); mChannel.enableLights(true); mChannel.setLightColor(Color.MAGENTA); if (notificationManager != null) { notificationManager.createNotificationChannel(mChannel); } notification.setChannelId(CHANNEL_ONE_ID); }
Now is working for me.

@jamesteng2010
Copy link

I make changes on ForegroundService.java to fix this:
After line 38 "import java.lang.reflect.Method;" add:
import android.app.NotificationChannel; import android.graphics.Color;
After line 168 " .setSmallIcon(getIconResId(settings));" add:
if (android.os.Build.VERSION.SDK_INT >= 26) { //Set the channel’s ID// String CHANNEL_ONE_ID = "com.klam.furnasconnet.ONE"; //Set the channel’s user-visible name// String CHANNEL_ONE_NAME = "Channel One"; //This only needs to be run on Devices on Android O and above NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); NotificationChannel mChannel = new NotificationChannel(CHANNEL_ONE_ID, CHANNEL_ONE_NAME, NotificationManager.IMPORTANCE_DEFAULT); mChannel.enableLights(true); mChannel.setLightColor(Color.MAGENTA); if (notificationManager != null) { notificationManager.createNotificationChannel(mChannel); } notification.setChannelId(CHANNEL_ONE_ID); }
Now is working for me.

Tried this solution , but not working on my case. but anyways, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants