android-notifications

Heads-up Notification - Android Lollipop

血红的双手。 提交于 2019-11-26 08:17:31
问题 I\'m trying to show a notification-type heads-up but I could not. What I tried final Notification.Builder notif = new Builder(getApplicationContext()) .setContentTitle(getString(R.string.title)) .setContentText(getString(R.string.text)) // .setTicker(getString(R.string.tick)) removed, seems to not show at all // .setWhen(System.currentTimeMillis()) removed, match default // .setContentIntent(contentIntent) removed, I don\'t neet it .setColor(Color.parseColor(getString(R.color.yellow))) //ok

Any way to link to the Android notification settings for my app?

和自甴很熟 提交于 2019-11-26 07:59:28
问题 Is there any way I can launch an intent to get to Android\'s notification settings screen for my app (pictured below)? Or an easy way I can make a PreferenceScreen item that just leads here on a click? 回答1: The following will work in Android 5.0 (Lollipop) and above: Intent intent = new Intent(); intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS"); //for Android 5-7 intent.putExtra("app_package", getPackageName()); intent.putExtra("app_uid", getApplicationInfo().uid); // for

NotificationCompat with API 26

隐身守侯 提交于 2019-11-26 07:27:15
问题 I dont see any information about how to use NotificationCompat with Android O\'s Notification Channels I do see a new Constructor that takes a channelId but how to take a Compat notification and use it in a NotificationChannel since createNotificationChannel takes a NotificationChannel object 回答1: Create the NotificationChannel only if API >= 26 public void initChannels(Context context) { if (Build.VERSION.SDK_INT < 26) { return; } NotificationManager notificationManager =

Android: Test Push Notification online (Google Cloud Messaging) [closed]

↘锁芯ラ 提交于 2019-11-26 06:55:25
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . Update: GCM is deprecated, use FCM I am implementing Google Cloud Messaging in my application. Server code is not ready yet and in my environment due to some firewall restrictions I can not deploy a test sever for push notification. What I am looking for is a online server which would send some test

Android Notification Sound

我怕爱的太早我们不能终老 提交于 2019-11-26 06:13:55
问题 I\'ve used the newer NotificationCompat builder and I can\'t get the notification to make a sound. It will vibrate and flash the light. The android documentation says to set a style which I\'ve done with: builder.setStyle(new NotificationCompat.InboxStyle()); But no sound? The full code: NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_launcher) .setContentTitle(\"Notifications Example\") .setContentText(\"This is a test notification\");

startForeground fail after upgrade to Android 8.1

大城市里の小女人 提交于 2019-11-26 04:09:19
问题 After upgrading my phone to 8.1 Developer Preview my background service no longer starts up properly. In my long running service I\'ve implemented a startForeground method to start the ongoing notification which is called in on create. @TargetApi(Build.VERSION_CODES.O) private fun startForeground() { // Safe call, handled by compat lib. val notificationBuilder = NotificationCompat.Builder(this, DEFAULT_CHANNEL_ID) val notification = notificationBuilder.setOngoing(true) .setSmallIcon(R

INSTALL_FAILED_DUPLICATE_PERMISSION… C2D_MESSAGE

懵懂的女人 提交于 2019-11-26 04:07:27
问题 I am using Google notifications in my app, and until now I have done below in the manifest: <!-- GCM --> <uses-permission android:name=\"android.permission.GET_ACCOUNTS\" /> <!-- GCM requires a Google account. --> <uses-permission android:name=\"android.permission.WAKE_LOCK\" /> <!-- Keeps the processor from sleeping when a message is received. --> <uses-permission android:name=\"com.google.android.c2dm.permission.RECEIVE\" /> <!-- This app has permission to register and receive data message.

Push notifications on content change

自闭症网瘾萝莉.ら 提交于 2019-11-26 04:00:30
问题 Let\'s say I have an Android application that simply builds a ListView with content got from a random REST API. Imagine now I need to send push notifications when new content is available on the API. What\'s the simplest way to do this ? I\'m a bit confused with the process of push notifications on Android. I took a look at Firebase, but I don\'t know if I mandantory need a database on Firebase that stores the result as new content is available through the API, and then triggers a

Firebase FCM notifications click_action payload

試著忘記壹切 提交于 2019-11-26 03:07:21
问题 I am trying to open a particular activity when the user clicks the notification when the app is in the background. From the Docs, I have got that click_action has to be added in the payload and an intent filter in the App to handle it. But, how to add click_action in the Firebase Notifications via Firebase Console? I am open to any other Work Around too. Thanks in Advance. 回答1: If your app is in background, Firebase will not trigger onMessageReceived(). Why.....? I have no idea. In this

NotificationCompat.Builder deprecated in Android O

匆匆过客 提交于 2019-11-26 02:51:35
问题 After upgrading my project to Android O buildToolsVersion \"26.0.1\" Lint in Android Studio is showing a deprecated warning for the follow notification builder method: new NotificationCompat.Builder(context) The problem is: Android Developers update their Documentation describing NotificationChannel to support notifications in Android O, and provide us with a snippet, yet with the same deprecated warning: Notification notification = new Notification.Builder(MainActivity.this) .setContentTitle