android-notifications

How to make android unit test for notifications?

浪子不回头ぞ 提交于 2019-12-05 18:09:53
I have the class handleFirebaseMessages . It contains the function onMessageReceived() . This function is in charge of receiving data and creating notifications. onMessageReceived() receives data in a RemoteMessages object. I am trying to write a test for this function. But I've not got it completely. HandleFirebaseMessages public class HandleFirebaseMessages extends FirebaseMessagingService { @Override public void onMessageReceived(final RemoteMessage remoteMessage) { final Map<String, String> data = remoteMessage.getData(); //create notifications using NotificationCompat.Builder } } I've

Android Notification: add typeface for title and content

纵饮孤独 提交于 2019-12-05 16:02:23
I'm trying to add a Typeface in my NotificationCompat.Builder -> setContentTitle() and setContentText() . I initialized Typeface by Typeface banglaFont = Typeface.createFromAsset(this.getAssets(), "kalpurush.ttf"); in IntentService . To create Notification i used following code. NotificationCompat.Builder mBuilder = new NotificationCompat.Builder( this) .setLargeIcon(bitmap) .setSmallIcon(R.drawable.ic_launcher) .setContentTitle(userName) .setAutoCancel(true) // .setStyle( // new NotificationCompat.BigTextStyle().bigText(msg)) .setStyle(new NotificationCompat.InboxStyle()) .setVibrate(pattern)

Android opening specific tab fragment on notification click

[亡魂溺海] 提交于 2019-12-05 14:55:33
I have an android application which uses Action Bar Tabs. There is also a notification system. I want to open a specific tab directly, on clicking the notification. How to do this(because notification pending intents can only open activities, and my main activity contains 3 fragments for 3 tabs) ? Following is the code for the mainactivity for tabs. public class MaintabActivity extends Activity { public static Context appContext; public static MapView mMapView; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate

Get text from expanded notification in status bar?

允我心安 提交于 2019-12-05 13:53:21
Is it possible to get the text within an expanded notification in the statusbar ? This means text set my Notification.BitTextStyle.bigText() , such as in an email notification from Gmail. I would like to get it using Notification.extras but there seems to be no constant, such as Notification.EXTRA_BIG_TEXT for example, that allows this to work. Is there another way of getting this text? Furthermore when I use String bigTitle = mExtras.getString(Notification.EXTRA_TITLE_BIG; it returns null , any idea why? I use this to get the subject of the email ( Testing the new Gmail notification shortcuts

Programmatically ending an ongoing notification - Android

情到浓时终转凉″ 提交于 2019-12-05 11:34:54
I am developing a GPS-based app and have just started adding in my UX features such as notifications and progress bars but I'm stuck on using an ongoing notification. As it is a GPS app, when user tracking is started, I set up an ongoing notification to show that they are being tracked but how do I stop this notification when they tap "stop tracking" in my app? Do I have to tell the NotifyManager something? I'm basically trying to get the functionality that music players have, as in the "playing" notification appears when the user presses play, but when they pause, that ongoing "playing"

Why NotificationManager works so slow during the update progress?

笑着哭i 提交于 2019-12-05 11:32:59
I publish file upload progress via NotificationManager, but while updating its progress UI freezes. I use NotificationCompat.Builder, which cached in the class field. So progress publishing is a very simple: manager.notify(id, uploader. setProgress(MAX_PROGRESS, (int) (progress * 100), false). build() ); Update progress is guaranteed to execute from the main thread(wrapped in Handler decorator). this.request.setCallback(new UploaderDecorator(this.request.getCallback())); The very publication of progress is as follows: long total = file.length(); long uploaded = 0; int bytesRead = input.read

Background image for android wear notification

依然范特西╮ 提交于 2019-12-05 08:23:36
I want to set background image for Android Wear notification. What should be the size of the image? jacob.zimmerman The resolution for square watch faces as of right now is 280x280, whereas the circular watch face has a resolution of 320x320 (although some of this will be cut off, obviously). However, Android Wear implements a sort of parallax scrolling by default for larger images, so it can handle larger images with great ease, and it is even recommended that you do so ( see this previous answer ). So you really shouldn't worry about the size of the image, unless you were trying to create a

android 7.0 Notification icon appearing white square

假如想象 提交于 2019-12-05 07:59:54
I am using the below snippet to generate notifications in my android app. private void sendNotification(String contentText, String message) { Intent resultIntent = new Intent(this, MainActivity.class); resultIntent.putExtra("clear","clear"); resultIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); PendingIntent piResult = PendingIntent.getActivity(this, 0, resultIntent,0); NotificationCompat.Builder builder=new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.icon) .setColor(ContextCompat.getColor(getApplicationContext(),R.color.red)) .setContentTitle(

Oreo Notification Bar Round Icon

柔情痞子 提交于 2019-12-05 06:52:19
I want to know that how can I change the notification bar small icon in android Oreo (API 26). It has round white icon showing in the notification bar. How can I change it? Manifest file default notification icon set as below. <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/ic_status" /> See the image below Remove <meta-data> tag from AndroidManifest.xml . Notification Builder has .setSmallIcon(int icon, int level) which accepts icon as a compulsory argument & level parameter as an optional argument. NOTE: .setSmallIcon accepts

Android: How to save an instance of parcelable object?

為{幸葍}努か 提交于 2019-12-05 06:42:42
问题 I am trying to save an instance of StatusBarNotification , so that i could show the notification later to the user. I noticed that StatusBarNotifcation is not Serializable but Parcelable . Is there any way to store the exact instance state in the database so that even if user turns of his phone, the instance object is stored. I know its not the best practice to store the Parcelable object in database. But I need to do it. If there is any way i could get the byte array of the instance, I am