This repository has been archived by the owner on Jun 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
esalessandrxx
committed
Dec 1, 2023
1 parent
1d1a337
commit c5f463a
Showing
36 changed files
with
1,529 additions
and
475 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
app/src/main/java/com/arr/simple/broadcast/NotificationNewYear.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.arr.simple.broadcast; | ||
|
||
import android.app.NotificationChannel; | ||
import android.app.NotificationManager; | ||
import android.content.BroadcastReceiver; | ||
import android.content.Intent; | ||
import android.content.Context; | ||
import android.os.Build; | ||
import androidx.core.app.NotificationManagerCompat; | ||
import com.arr.simple.R; | ||
import androidx.core.app.NotificationCompat; | ||
import java.util.Calendar; | ||
|
||
public class NotificationNewYear extends BroadcastReceiver { | ||
|
||
private String CHANNEL_ID = "SIMple"; | ||
private String CHANNEL_NAME = "New Year"; | ||
private String CHANNEL_DESCRIPTION = "Notificación por nuevo año"; | ||
|
||
@Override | ||
public void onReceive(Context context, Intent intent) { | ||
Calendar calendar = Calendar.getInstance(); | ||
int currentDay = calendar.get(Calendar.DAY_OF_MONTH); | ||
int currentMonth = calendar.get(Calendar.MONTH); | ||
if (currentDay == 1 && currentMonth == Calendar.JANUARY) { | ||
|
||
if (intent.getAction().equals("com.arr.simple.NOTIFICATION")) { | ||
|
||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
NotificationChannel channel = | ||
new NotificationChannel( | ||
CHANNEL_ID, | ||
CHANNEL_NAME, | ||
NotificationManager.IMPORTANCE_DEFAULT); | ||
channel.setDescription(CHANNEL_DESCRIPTION); | ||
channel.enableVibration(true); | ||
channel.setShowBadge(true); | ||
channel.setSound(null, null); | ||
NotificationManager notiManager = | ||
context.getSystemService(NotificationManager.class); | ||
notiManager.createNotificationChannel(channel); | ||
} | ||
|
||
NotificationCompat.Builder builder = | ||
new NotificationCompat.Builder(context, CHANNEL_ID) | ||
.setSmallIcon(R.drawable.ic_logo_simple) | ||
.setContentTitle("¡Feliz año nuevo!") | ||
.setStyle( | ||
new NotificationCompat.BigTextStyle() | ||
.bigText( | ||
context.getString(R.string.happy_new_year))) | ||
.setContentText(context.getString(R.string.happy_new_year)) | ||
.setShowWhen(false) | ||
.setSound(null) | ||
.setPriority(NotificationCompat.PRIORITY_DEFAULT); | ||
|
||
NotificationManagerCompat notificationManager = | ||
NotificationManagerCompat.from(context); | ||
notificationManager.notify(23, builder.build()); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.