Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.app.AlarmManager;

import android.app.PendingIntent;

import android.content.Context;
import android.content.Intent;

import android.util.Log;

public class Main {
    public static final String TAG = "SamcodesNotifications";

    public static PendingIntent scheduleLocalNotification(Context context, int slot, Long alertTime,
            String titleText, String subtitleText, String messageBodyText, String tickerText) {
        Log.i(TAG, "Scheduling local notification");
        Intent alertIntent = new Intent(getNotificationName(slot));
        PendingIntent pendingIntent = PendingIntent.getBroadcast(context, slot, alertIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
        if (alarmManager != null) {
            alarmManager.set(AlarmManager.RTC_WAKEUP, alertTime, pendingIntent);
        }
        return pendingIntent;
    }

    public static String getNotificationName(int slot) {
        return getPackageName() + ".Notification" + slot;
    }

    public static String getPackageName() {
        return "::APP_PACKAGE::";
    }
}