- package com.saiermeng.notifiy;import android.app.Activity;import android.app.Notification;import android.app.NotificationManager;import android.app.PendingIntent;import android.content.Intent;import android.net.Uri;import android.os.Bundle;import android.view.View;public class MainActivity extends Activity {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);    }    public void click(View view){        @SuppressWarnings("deprecation")        Notification notification = new Notification(R.drawable.ic_launcher, "酷狗音乐正在播放", System.currentTimeMillis());        //点击事件真正想执行的动作        Intent intent = new Intent();        intent.setAction(Intent.ACTION_DIAL);        intent.setData(Uri.parse("tel:110"));        PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);        notification.setLatestEventInfo(this, "正在播放音乐", "音乐名称:月亮之上", contentIntent);        NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);        nm.notify(0, notification);    }}

更多相关文章

  1. 使用异步任务下载--疯狂android讲义实例
  2. 安卓 简易版音乐播放器——初稿
  3. 播放raw中的音乐范例
  4. Android(安卓)应用界面开发笔记 Service
  5. android 静默安装并自启
  6. Adb连接超时错误
  7. android启动蓝牙的过程 (高通方案)
  8. Android(安卓)Service播放音乐
  9. 用命令行使用7z压缩

随机推荐

  1. (美团)巧用数组下标,轻轻松松找出所有元素
  2. 字节一面,面试官告诉我链表掌握的不熟练
  3. 晚上看了轮子哥的知乎想法,我失眠了
  4. 计算机专业的学生怎样练习编程才能把编程
  5. LeetCode 题解:一顿操作猛如虎,一看击败百
  6. 2021 年,程序员技术公众号生死劫
  7. 起个简单枯燥的标题:找出连续差相同的数字
  8. 看了知乎,直呼牛逼 !
  9. 阿里大神的刷题笔记.PDF
  10. 吴师兄领证之前谈了多少个女朋友?