I tried to create a Notification with this Code:
private void setNotificationAlarm(Context context)
{
Intent intent = new Intent(getApplicationContext()
I think you need to use
PendingIntent.getBroadcast (Context context, int requestCode, Intent intent, int flags)
instead of getService
you can use
Intent switchIntent = new Intent(BROADCAST_ACTION);
instead of using
Intent intent = new Intent(getApplicationContext() , MyNotification.class);
in here BROADCAST_ACTION is action that you are defining in manifest
<receiver android:name=".MyNotification " android:enabled="true" >
<intent-filter>
<action android:name="your package.ANY_NAME" />
</intent-filter>
</receiver>
you can catch it by using that action name
public class MyNotification extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String act = "your package.ANY_NAME";
if(intent.getAction().equals(act)){
//your code here
}
}}
You use Notification.Builder
to build the notification now and the pending intent needs to be PendingIntent.getBroadcast()