zoukankan      html  css  js  c++  java
  • 手机交互应用服务(状态栏提示信息Notifications)

        官方的一个简单的例子:

    NotificationCompat.Builder mBuilder =
            new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.notification_icon)
            .setContentTitle("My notification")
            .setContentText("Hello World!");
    // Creates an explicit intent for an Activity in your app
    Intent resultIntent = new Intent(this, ResultActivity.class);
    
    // The stack builder object will contain an artificial back stack for the
    // started Activity.
    // This ensures that navigating backward from the Activity leads out of
    // your application to the Home screen.
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    // Adds the back stack for the Intent (but not the Intent itself)
    stackBuilder.addParentStack(ResultActivity.class);
    // Adds the Intent that starts the Activity to the top of the stack
    stackBuilder.addNextIntent(resultIntent);
    PendingIntent resultPendingIntent =
            stackBuilder.getPendingIntent(
                0,
                PendingIntent.FLAG_UPDATE_CURRENT
            );
    mBuilder.setContentIntent(resultPendingIntent);
    NotificationManager mNotificationManager =
        (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    // mId allows you to update the notification later on.
    mNotificationManager.notify(mId, mBuilder.build());
  • 相关阅读:
    [Project Euler 603]Substring sums of prime concatenations 题解
    [Project Euler 521]Smallest prime factor 题解
    [Project Euler 520]Simbers 题解
    [Project Euler 517]A real recursion 题解
    省选刷题计划
    [十二省联考2019]春节十二响
    导航
    有用的网址
    [ZJOI2019]线段树
    [十二省联考2019]皮配
  • 原文地址:https://www.cnblogs.com/laishenghao/p/5244219.html
Copyright © 2011-2022 走看看