Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void sendEmployeeWorkNotification(String ticker, String title, String text, String loc, int employee_id) {
- PendingIntent pendingIntent;
- Intent intent;
- Context currentContext = G.context;
- if (loc.equals("LOC")) {
- intent = new Intent(currentContext, PeopleSingleScene_Activity.class);
- intent.putExtra("people_id", employee_id);
- pendingIntent = PendingIntent.getActivity(currentContext, 0, intent, 0);
- } else {
- //some other actions
- }
- NotificationCompat.Builder builder = new NotificationCompat.Builder(currentContext, CHANNEL_ID)
- .setSmallIcon(R.drawable.vector_notif)
- .setTicker(ticker)
- .setContentTitle(title)
- .setContentText(text)
- .setColor(ContextCompat.getColor(currentContext, R.color.rcOutcome))
- .setStyle(new NotificationCompat.BigTextStyle()
- .bigText(text))
- .setPriority(NotificationCompat.PRIORITY_DEFAULT)
- .setContentIntent(pendingIntent)
- .setAutoCancel(true);
- NotificationManagerCompat notificationManager = NotificationManagerCompat.from(currentContext);
- notificationManager.notify(G.simpleMessageCounter, builder.build());
- simpleSong(R.raw.notificationsimple);
- G.simpleMessageCounter++;
- }
- public class SomeActivityClass extends AppCompatActivity {
- @Override
- protected void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.some_layout);
- G.context = this;
- ....
- }
- ....
- }
- public class App extends Application {
- private static Context mContext;
- @Override
- public void onCreate() {
- super.onCreate();
- mContext = this;
- }
- public static Context getContext(){
- return mContext;
- }
- public static String getStr(int resid) {
- return mContext.getResources().getString(resid);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement