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. 短信的自动拦截
  2. android一种较为复杂的布局参考(xml文件)
  3. android 通知 Notification
  4. Android自定义Toast 解决关闭通知 Toast无法弹出
  5. Android(安卓)APP 版本更新通知代码
  6. android 全屏实现
  7. java.lang.NullPointerException: Attempt to invoke virtual me
  8. Android(安卓)自动化测试工具Robotium 之Solo类的详细说明
  9. Android(安卓)记录gitignore文件内容

随机推荐

  1. Android NDK会带来什么,除去你对NDK的一些
  2. Android自动化工具Monkeyrunner使用(五)
  3. Android中Activity的四种启动模式详解
  4. Android Binder
  5. 安卓017ListView & GridView & ScrollView
  6. Android必备:Android Activity的生命周期
  7. Android日志输出单元测试Debug
  8. Android锁定横竖屏、splash,全屏、去除标
  9. Android TextView 中如何使用第三方字体
  10. Windows平台下搭建Android原生C/C++开发