public class NotificationActivity extends Activity {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_notification);    }    public void notifyNew(View view){        NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);        Notification.Builder builder = new Builder(this);        builder.setContentTitle("通知标题");        builder.setContentText("帖子内容");        builder.setSmallIcon(R.drawable.ic_launcher);        builder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));        Notification notification = builder.build();        nm.notify(0, notification);    }    @SuppressWarnings("deprecation")    public void notifyOld(View view){        NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);        Notification notification = new Notification(R.drawable.ic_launcher, "通知来了", System.currentTimeMillis());        Intent intent = new Intent();        intent.setAction(Intent.ACTION_CALL);        intent.setData(Uri.parse("tel:123456"));        PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);        notification.setLatestEventInfo(this, "标题", "内容", contentIntent);        nm.notify(0, notification);    }}

更多相关文章

  1. Android点击通知栏,不启动新的activity
  2. android 通知 Notification
  3. Android自定义Toast 解决关闭通知 Toast无法弹出
  4. Android APP 版本更新通知代码
  5. Android 记录gitignore文件内容
  6. Android的系统通知栏小例子
  7. Android UI控件详解-Notification(通知)
  8. 【notification】Android 中创建状态栏通知
  9. Android - 自定义标题栏(TitleBar)

随机推荐

  1. style和theme小用法
  2. android 进程自杀再重启的方法
  3. 转:Android世界的15款开源的游戏开发引擎
  4. Android(安卓)OpenGL ES2.0编程教程系列
  5. Android之Shared Preferences
  6. Android(安卓)day_11 (四种对话框)
  7. 2.Retrofit上传list数组给后端
  8. Android(安卓)布局
  9. android handler正确写法
  10. Android实现手写板和涂鸦功能