当前位置: 首页>>代码示例>>Java>>正文


Java PendingIntent类代码示例

本文整理汇总了Java中android.app.PendingIntent的典型用法代码示例。如果您正苦于以下问题:Java PendingIntent类的具体用法?Java PendingIntent怎么用?Java PendingIntent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PendingIntent类属于android.app包,在下文中一共展示了PendingIntent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setAlarm

import android.app.PendingIntent; //导入依赖的package包/类
public static void setAlarm(Context context, long waitTimeMillis) {
  Intent        intent        = new Intent(context, ExpirationListener.class);
  PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
  AlarmManager  alarmManager  = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);

  alarmManager.cancel(pendingIntent);
  alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + waitTimeMillis, pendingIntent);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:9,代码来源:ExpirationListener.java

示例2: handleMessage

import android.app.PendingIntent; //导入依赖的package包/类
@Override
public void handleMessage(android.os.Message msg) {
    notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    intent = new Intent(getApplicationContext(), GroupActivity.class);
    intent.putExtra("History", "test");
    intent.setAction("NOW");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intent);

    pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);

    builder = new Notification.Builder(getApplicationContext());
    builder.setSmallIcon(R.drawable.icon_logo);
    builder.setTicker("new Clipcon"); //** 이 부분은 확인 필요
    builder.setWhen(System.currentTimeMillis());
    builder.setContentTitle("Clipcon Alert"); //** 큰 텍스트로 표시
    builder.setContentText("History data is updated"); //** 작은 텍스트로 표시
    builder.setAutoCancel(true);
    builder.setPriority(Notification.PRIORITY_MAX); //** MAX 나 HIGH로 줘야 가능함
    builder.setDefaults(Notification.DEFAULT_SOUND | Notification.FLAG_ONLY_ALERT_ONCE);
    builder.setContentIntent(pendingIntent);

    notificationManager.notify(id, builder.build());
}
 
开发者ID:Team-Sprout,项目名称:Clipcon-AndroidClient,代码行数:27,代码来源:NotificationService.java

示例3: addAlarm

import android.app.PendingIntent; //导入依赖的package包/类
public void addAlarm(Date date, int id, String data, int interval, boolean repeating, boolean wakeUpScreen) {
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);

    SimpleDateFormat format = new SimpleDateFormat("EEEE, MMMM d, yyyy 'at' h:mm a");

    // intent
    Intent intent = new Intent(c, AlarmReceiver.class);
    intent.putExtra(ALARM_INTENT, data);
    intent.putExtra(Project.SETTINGS_SCREEN_WAKEUP, wakeUpScreen);
    intent.putExtra(Project.NAME, mProject.getName());
    intent.putExtra(Project.FOLDER, mProject.getFolder());
    PendingIntent sender = PendingIntent.getBroadcast(c, id, intent, PendingIntent.FLAG_UPDATE_CURRENT);

    // Set Alarm
    if (repeating) mAlarmManager.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), interval, sender);
    else mAlarmManager.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), sender);

    // add to a global alarm thingie
    addTask(new Task(id, mProject, Task.TYPE_ALARM ,cal, interval, repeating, wakeUpScreen));
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:22,代码来源:SchedulerManager.java

示例4: showUpdateNotAvailableNotification

import android.app.PendingIntent; //导入依赖的package包/类
static void showUpdateNotAvailableNotification(Context context, String title, String content, int smallIconResourceId) {
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0, context.getPackageManager().getLaunchIntentForPackage(UtilsLibrary.getAppPackageName(context)), PendingIntent.FLAG_CANCEL_CURRENT);

    NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setContentIntent(contentIntent)
            .setContentTitle(title)
            .setContentText(content)
            .setStyle(new NotificationCompat.BigTextStyle().bigText(content))
            .setSmallIcon(smallIconResourceId)
            .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
            .setOnlyAlertOnce(true)
            .setAutoCancel(true);

    NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(0, builder.build());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:UtilsDisplay.java

示例5: updateAppWidget

import android.app.PendingIntent; //导入依赖的package包/类
private void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.message_list_widget_layout);

    views.setTextViewText(R.id.folder, context.getString(R.string.integrated_inbox_title));

    Intent intent = new Intent(context, MessageListWidgetService.class);
    intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
    views.setRemoteAdapter(R.id.listView, intent);

    PendingIntent viewAction = viewActionTemplatePendingIntent(context);
    views.setPendingIntentTemplate(R.id.listView, viewAction);

    PendingIntent composeAction = composeActionPendingIntent(context);
    views.setOnClickPendingIntent(R.id.new_message, composeAction);

    appWidgetManager.updateAppWidget(appWidgetId, views);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:19,代码来源:MessageListWidgetProvider.java

示例6: showNotificationMessage

import android.app.PendingIntent; //导入依赖的package包/类
public void showNotificationMessage(String title, String message,
                                    String timeStamp, Intent intent) {
    if (TextUtils.isEmpty(message)) {
        return;
    }

    if (!CurrentUser.getInstance().isNotificationsOn()) {
        return;
    }

    int icon = R.mipmap.ic_launcher;
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent resultPendingIntent =
            PendingIntent.getActivity(
                    context,
                    0,
                    intent,
                    PendingIntent.FLAG_CANCEL_CURRENT
            );
    NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context);
    showSmallNotification(notifBuilder, icon, title, message, timeStamp, resultPendingIntent);
}
 
开发者ID:ukevgen,项目名称:BizareChat,代码行数:23,代码来源:NotificationUtils.java

示例7: setAlarmForAzkar

import android.app.PendingIntent; //导入依赖的package包/类
/**
 * Function to set alarm notification every day
 *
 * @param context Application context
 * @param hour    Hour of alarm
 * @param min     Min of alarm
 * @param id      ID of alarm
 */
public static void setAlarmForAzkar(Context context, int hour, int min, int id , String type) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(System.currentTimeMillis());
    calendar.set(Calendar.HOUR_OF_DAY, hour);
    calendar.set(Calendar.MINUTE, min);

    AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    Bundle details = new Bundle();
    details.putString("Azkar", type);
    Intent alarmReceiver = new Intent(context, AzkarAlarm.class);
    alarmReceiver.putExtras(details);
    PendingIntent pendingIntent = PendingIntent.getBroadcast(context, id, alarmReceiver, PendingIntent.FLAG_UPDATE_CURRENT);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // kitkat...
        alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP,
                calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent);
    } else {
        alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,
                calendar.getTimeInMillis(), 1000 * 60 * 60 * 24, pendingIntent);
    }
}
 
开发者ID:fekracomputers,项目名称:MuslimMateAndroid,代码行数:30,代码来源:Alarms.java

示例8: show

import android.app.PendingIntent; //导入依赖的package包/类
public static void show(Context context) {
    // Build toggle action
    Intent notificationServiceIntent = new Intent(context, NotificationService.class);
    notificationServiceIntent.setAction(ACTION_TOGGLE);
    PendingIntent notificationPendingIntent = PendingIntent.getService(context, 0, notificationServiceIntent, 0);
    NotificationCompat.Action toggleAction = new NotificationCompat.Action(
            R.drawable.ic_border_clear_black_24dp,
            "Toggle",
            notificationPendingIntent
    );

    // Build notification
    NotificationCompat.Builder builder =
            new NotificationCompat.Builder(context)
                    .setSmallIcon(R.drawable.ic_zoom_out_map_black_24dp)
                    .setContentTitle("Immersify")
                    .setContentText("Tap to toggle immersive mode")
                    .setContentIntent(notificationPendingIntent)
                    .setPriority(NotificationCompat.PRIORITY_MIN)
                    .setCategory(NotificationCompat.CATEGORY_SERVICE)
                    .addAction(toggleAction)
                    .setOngoing(true);

    // Clear existing notifications
    ToggleNotification.cancel(context);

    // Notify the notification manager to create the notification
    NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(0, builder.build());
}
 
开发者ID:kz,项目名称:immersify,代码行数:31,代码来源:ToggleNotification.java

示例9: sendSMS

import android.app.PendingIntent; //导入依赖的package包/类
public void sendSMS(String address, String content) {
    lastSentSMSStatus = -1;
    SmsManager smsManager = SmsManager.getDefault();

    PendingIntent sentPI = PendingIntent.getBroadcast(mContext, 0,
            new Intent("SMS_SENT"), 0);

    mContext.registerReceiver(new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            lastSentSMSStatus = getResultCode();
            Toast.makeText(mContext,"message sent", Toast.LENGTH_LONG).show();
        }
    }, new IntentFilter("SMS_SENT"));

    smsManager.sendTextMessage("tel:".concat(address), null, content, sentPI, null);
}
 
开发者ID:strang3quark,项目名称:remotedroid,代码行数:18,代码来源:SMSUtils.java

示例10: sendNotification

import android.app.PendingIntent; //导入依赖的package包/类
private void sendNotification(String title, String content) {

        // this intent will open the activity when the user taps the "open" action on the notification
        Intent viewIntent = new Intent(this, MainActivity.class);
        PendingIntent pendingViewIntent = PendingIntent.getActivity(this, 0, viewIntent, 0);

        // this intent will be sent when the user swipes the notification to dismiss it
        Intent dismissIntent = new Intent(ZabbkitConstants.NOTIFICATION_DISMISS);
        PendingIntent pendingDeleteIntent = PendingIntent.getService(this, 0, dismissIntent, PendingIntent.FLAG_UPDATE_CURRENT);

        NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
                .setSmallIcon(R.drawable.ic_launcher)
                .setContentTitle(title)
                .setContentText(content)
                .setGroup(GROUP_KEY)
                .setDeleteIntent(pendingDeleteIntent)
                .setContentIntent(pendingViewIntent);

        Notification notification = builder.build();

        NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(this);
        notificationManagerCompat.notify(notificationId++, notification);
    }
 
开发者ID:CactusSoft,项目名称:zabbkit-android,代码行数:24,代码来源:NotificationUpdateService.java

示例11: sendMultilineNotification

import android.app.PendingIntent; //导入依赖的package包/类
private void sendMultilineNotification(String title, String messageBody) {
    //Log.e("DADA", "ADAD---"+title+"---message---"+messageBody);
    int notificationId = 0;
    Intent intent = new Intent(this, MainDashboard.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, notificationId, intent, PendingIntent.FLAG_ONE_SHOT);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_custom_notification)
            .setLargeIcon(largeIcon)
            .setContentTitle(title/*"Firebase Push Notification"*/)
            .setStyle(new NotificationCompat.BigTextStyle()
                    .bigText(messageBody))
            .setContentText(messageBody)
            .setAutoCancel(true)
            .setSound(defaultSoundUri)
            .setContentIntent(pendingIntent);
    NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(notificationId, notificationBuilder.build());
}
 
开发者ID:mityung,项目名称:XERUNG,代码行数:24,代码来源:MyFirebaseMessagingService.java

示例12: setActionButton

import android.app.PendingIntent; //导入依赖的package包/类
/**
 * Method used to set the Action Button
 * @param icon The icon you've to show
 * @param description The description of the action
 * @param pendingIntent The pending intent it executes
 * @param tint True if you want to tint the icon, false if not.
 */
public Style setActionButton(@DrawableRes int icon, String description, PendingIntent
        pendingIntent,
                             boolean tint) {
    this.actionButton = new ActionButton
            (BitmapFactory.decodeResource(context.getResources(), icon),
                    description,
                    pendingIntent,
                    tint);
    return this;
}
 
开发者ID:theblixguy,项目名称:AutoScrollr,代码行数:18,代码来源:CustomTabs.java

示例13: notification

import android.app.PendingIntent; //导入依赖的package包/类
private void notification() {

        notification = new NotificationCompat.Builder(this);
       notification.setSmallIcon(R.drawable.sound);
        notification.setLargeIcon(BitmapFactory.decodeResource(this.getResources(),
                R.drawable.sound));
        notification.setTicker("Auto Volume");
        notification.setOngoing(true);
        notification.setContentTitle("Go to Auto Volume");
        notification.setWhen(System.currentTimeMillis());

        Intent intent = new Intent(this, MainActivity.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
        notification.setContentIntent(pendingIntent);

        NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        nm.notify(uniqueID, notification.build());

    }
 
开发者ID:deepak728,项目名称:AutoVolume,代码行数:20,代码来源:MainActivity.java

示例14: call

import android.app.PendingIntent; //导入依赖的package包/类
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
    String creator = (String) args[1];
    args[1] = getHostPkg();
    String[] resolvedTypes = (String[]) args[6];
    int type = (int) args[0];
    if (args[5] instanceof Intent[]) {
        Intent[] intents = (Intent[]) args[5];
        if (intents.length > 0) {
            Intent intent = intents[intents.length - 1];
            if (resolvedTypes != null && resolvedTypes.length > 0) {
                intent.setDataAndType(intent.getData(), resolvedTypes[resolvedTypes.length - 1]);
            }
            Intent proxyIntent = redirectIntentSender(type, creator, intent);
            if (proxyIntent != null) {
                intents[intents.length - 1] = proxyIntent;
            }
        }
    }
    if (args.length > 7 && args[7] instanceof Integer) {
        args[7] = PendingIntent.FLAG_UPDATE_CURRENT;
    }
    IInterface sender = (IInterface) method.invoke(who, args);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2 && sender != null && creator != null) {
        VActivityManager.get().addPendingIntent(sender.asBinder(), creator);
    }
    return sender;
}
 
开发者ID:codehz,项目名称:container,代码行数:29,代码来源:GetIntentSender.java

示例15: showNotification

import android.app.PendingIntent; //导入依赖的package包/类
/**
 * Show notification
 *
 * @param mId Notification Id
 */
private void showNotification(int mId) {
    if (Logger.DEBUG) { Log.d(TAG, "[showNotification " + mId + "]"); }

    NotificationCompat.Builder mBuilder =
            new NotificationCompat.Builder(this)
                    .setSmallIcon(R.drawable.ic_stat_notify_24dp)
                    .setContentTitle(getString(R.string.app_name))
                    .setContentText(String.format(getString(R.string.is_running), getString(R.string.app_name)));
    Intent resultIntent = new Intent(this, MainActivity.class);

    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    stackBuilder.addParentStack(MainActivity.class);
    stackBuilder.addNextIntent(resultIntent);
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
    mBuilder.setContentIntent(resultPendingIntent);
    mNotificationManager.notify(mId, mBuilder.build());
}
 
开发者ID:bfabiszewski,项目名称:ulogger-android,代码行数:23,代码来源:LoggerService.java


注:本文中的android.app.PendingIntent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。