Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. public void sendEmployeeWorkNotification(String ticker, String title, String text, String loc, int employee_id) {
  2. PendingIntent pendingIntent;
  3. Intent intent;
  4. Context currentContext = G.context;
  5.  
  6. if (loc.equals("LOC")) {
  7. intent = new Intent(currentContext, PeopleSingleScene_Activity.class);
  8. intent.putExtra("people_id", employee_id);
  9. pendingIntent = PendingIntent.getActivity(currentContext, 0, intent, 0);
  10. } else {
  11. //some other actions
  12. }
  13. NotificationCompat.Builder builder = new NotificationCompat.Builder(currentContext, CHANNEL_ID)
  14. .setSmallIcon(R.drawable.vector_notif)
  15. .setTicker(ticker)
  16. .setContentTitle(title)
  17. .setContentText(text)
  18. .setColor(ContextCompat.getColor(currentContext, R.color.rcOutcome))
  19. .setStyle(new NotificationCompat.BigTextStyle()
  20. .bigText(text))
  21. .setPriority(NotificationCompat.PRIORITY_DEFAULT)
  22. .setContentIntent(pendingIntent)
  23. .setAutoCancel(true);
  24. NotificationManagerCompat notificationManager = NotificationManagerCompat.from(currentContext);
  25.  
  26. notificationManager.notify(G.simpleMessageCounter, builder.build());
  27. simpleSong(R.raw.notificationsimple);
  28. G.simpleMessageCounter++;
  29. }
  30.  
  31. public class SomeActivityClass extends AppCompatActivity {
  32. @Override
  33. protected void onCreate(@Nullable Bundle savedInstanceState) {
  34. super.onCreate(savedInstanceState);
  35. setContentView(R.layout.some_layout);
  36. G.context = this;
  37. ....
  38. }
  39. ....
  40. }
  41.  
  42. public class App extends Application {
  43. private static Context mContext;
  44.  
  45. @Override
  46. public void onCreate() {
  47. super.onCreate();
  48. mContext = this;
  49. }
  50.  
  51. public static Context getContext(){
  52. return mContext;
  53. }
  54.  
  55. public static String getStr(int resid) {
  56. return mContext.getResources().getString(resid);
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement