android-notifications

GCM Push Notification Large Icon size

时光总嘲笑我的痴心妄想 提交于 2019-11-28 09:51:22
Hi Iam implementing Push Notifications in Android using GCM. I am trying to set an image for the notification instead of the default app icon. I am able to achieve this using the following code if(extras.getString("src") != null){ URL url = new URL(extras.getString("src")); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setDoInput(true); connection.connect(); InputStream input = connection.getInputStream(); Bitmap large_icon = BitmapFactory.decodeStream(input); mBuilder.setLargeIcon(large_icon); } Typically the image will be from the web(jpg, png etc) and

Can't cancel Notification using NotificationListenerService

冷暖自知 提交于 2019-11-28 08:47:12
问题 This is my service: public class Listener extends NotificationListenerService { Context context; @Override public void onCreate() { super.onCreate(); context = getApplicationContext(); } @Override public void onNotificationPosted(StatusBarNotification sbn) { String pack = sbn.getPackageName(); String ticker = sbn.getNotification().tickerText.toString(); Bundle extras = sbn.getNotification().extras; String title = extras.getString("android.title"); String text = extras.getCharSequence("android

Android call method on notification click

假如想象 提交于 2019-11-28 08:20:58
This code creates a notification. If you click it, the current application is ran (the intent is created in Entry , which is my only Activity ), a slightly modified version of a Android Developers blog: private void makeIntent() { NotificationManager mgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Notification note = new Notification(R.drawable.prev, "Status message!", System.currentTimeMillis()); Intent intent = new Intent(this, Entry.class); PendingIntent pi = PendingIntent.getActivity(this, 0, intent, 0); note.setLatestEventInfo(this, "New Email", "Unread Conversation",

Output: error: resource style/TextAppearance.Compat.Notification.Info (aka package_name:style/TextAppearance.Compat.Notification.Info) not found

百般思念 提交于 2019-11-28 07:30:12
问题 After switching to Android Studio 3.2 canary I am getting the following build error. I have seen this post where the guy had a similar issue but no solution was mentioned over their. I want to try new material components and jetpack so is there any possibility where I don't have to switch back. com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed Output: error: resource style/TextAppearance.Compat.Notification.Info (aka com.nsnik.nrs.kotlintest.debug:style

Can I detect if Android has killed the application (task process) from a Notification Intent / PendingIntent?

会有一股神秘感。 提交于 2019-11-28 07:06:28
The Android OS kills processes when it's low on memory. Scenario: Android kills the app process and I re-open it through either the Android launcher or the recent-task list (long press home button). I can check if Android killed my app process in the onCreate() method of the most recently viewed activity using: @Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); if (savedInstanceState != null) { // Re-initialise things that killing the app would have destroyed } } However, if Android kills the app process and I re-open it through a Notification

Is possible set Expanded Notification as default in Big Text Notifications?

自作多情 提交于 2019-11-28 06:44:46
I followed this Sample Code In Big Text Notifications section, he said that need expand to see Big text notification form, as image im below : I wonder that we can not set Expanded Notification as default in Big Text Notifications? People who know it is can or not, If can, Please tell me how to do it, Thanks, Emanuel Moecklin The documentation states : A notification's big view appears only when the notification is expanded, which happens when the notification is at the top of the notification drawer, or when the user expands the notification with a gesture. So my answer is no, you can't

Show Badge count on App icon in Android

久未见 提交于 2019-11-28 06:42:30
问题 In my Android app,i want to show a push-notification badge count into application icon like ios. How can I show badge count into application icon ? 回答1: Android doesn't have this particular feature. An alternative might be to have a notification that displays the number but the app icon itself is incapable under normal circumstances. If you REALLY wanted to break design guidelines you could make a widget that looks like your app icon and the widget gets much more control over how it's drawn.

Can NoticationManager.notify() be called from a worker thread?

允我心安 提交于 2019-11-28 06:11:27
My question is more about what is a good practice than what is possible: Is it a good thing to call NoticationManager.notify() from a worker thread? Does the system execute it in the UI thread anyway or not? I always try to keep in mind that stuff concerning the UI should be executed in the UI thread and the rest in worker threads, as suggested by the Android doc about Processes And Threads : Additionally, the Andoid UI toolkit is not thread-safe. So, you must not manipulate your UI from a worker thread—you must do all manipulation to your user interface from the UI thread. Thus, there are

Notification action button not clickable in lock screen

孤者浪人 提交于 2019-11-28 04:58:34
问题 In order to better support Android 5 notifications, I am now setting my app's notification visibilty to "public". After considering the answers on Lollipop Notification setVisibility() Does Not Work?, the notification is now displayed as expected. However, when I want to click the action button of the notification, I first have to unlock the device which should not be required. (The action shows that a password database is unlocked and the action button will lock the database.) This is the

How to open fragment page, when pressed a notification in android

故事扮演 提交于 2019-11-28 04:57:23
I am trying to open a fragment when I press a notification in the notification bar. My app structure is: a base activity with a nav drawer menu some fragment that are opened from menu b.setOnClickListener(new OnClickListener() { @SuppressWarnings({ "deprecation", "static-access" }) public void onClick(View v) { w_nm=(NotificationManager) getActivity().getSystemService(getActivity().NOTIFICATION_SERVICE); Notification notify=new Notification(R.drawable.notnificationlogo,waternoti,System.currentTimeMillis()); Intent notificationIntent = new Intent(getActivity(), Abc.class); PendingIntent pending