当前位置: 首页 > news >正文

天河门户网站建设公司济南网站优化收费标准

天河门户网站建设公司,济南网站优化收费标准,厦门网页设计培训学校,鲜花网站建设策划方案文章目录 连接到真机使用通知通知的简单使用通知的详细信息 连接到真机 先用USB线将手机与电脑连接。 打开手机的设置,找到关于手机,点开之后,找到开发者选项界面。或者找到软件版本号,连续点击,系统会提示你点击几次能…

文章目录

      • 连接到真机
      • 使用通知
        • 通知的简单使用
        • 通知的详细信息

连接到真机

  先用USB线将手机与电脑连接。

  打开手机的设置,找到关于手机,点开之后,找到开发者选项界面。或者找到软件版本号,连续点击,系统会提示你点击几次能够打开开发者模式。

   然后就可以在Android studio顶部找到自己的真机运行就行了。

在这里插入图片描述

使用通知

通知的简单使用

  每条通知都要属于一个对应的渠道。每个应用程序都可以自由地创建当前应用拥有哪些通知渠道,但是这些通知渠道的控制权是掌握在用户手上的。用户可以自由地选择这些通知渠道的重要程度,是否响铃、是否振动或者是否要关闭这个渠道的通知。

  通知的重要等级主要有IMPORTANCE_HIGH、IMPORTANCE_DEFAULT、IMPORTANCE_LOW、IMPORTANCE_MIN这几种,对应的重要程度依次从高到低。

  修改activity_main.xml文件。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="match_parent"android:layout_height="match_parent"><Buttonandroid:id="@+id/sendNotice"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Send Notice" />
</LinearLayout>

  修改MainActivity.java文件。

public class MainActivity extends AppCompatActivity implements View.OnClickListener{@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);Button sendNotice = (Button) findViewById(R.id.sendNotice);sendNotice.setOnClickListener(this);}@Overridepublic void onClick(View v){NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {NotificationChannel channel = new NotificationChannel("normal", "Normal", NotificationManager.IMPORTANCE_DEFAULT);manager.createNotificationChannel(channel);}NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "normal").setContentTitle("This is content title").setContentText("This is content text").setSmallIcon(R.mipmap.ic_launcher).setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher));Notification notification = builder.build();manager.notify(1, notification);}
}

在这里插入图片描述

通知的详细信息

  实现通知的点击效果需要使用PendingIntent,它主要提供了几个静态方法用于获取PendingIntent的实例,可以根据需求来选择是使用getActivity()方法、getBroadcast()方法,还是getService()方法。这几个方法所接收的参数都是相同的:第一个参数是Context;第二个参数一般用不到,传入0即可;第三个参数是一个Intent对象。第四个参数用于确定PendingIntent的行为,有FLAG_ONE_SHOT、FLAG_NO_CREATE、FLAG_CANCEL_CURRENT和FLAG_UPDATE_CURRENT这4种值可选,通常情况下这个参数传入0就可以了。

  新建一个活动NotificationActivity,修改布局文件。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent" ><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"android:textSize="24sp"android:text="This is notification layout"/>
</RelativeLayout>

  修改MainActivity.java文件。

public class MainActivity extends AppCompatActivity implements View.OnClickListener{@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);Button sendNotice = (Button) findViewById(R.id.sendNotice);sendNotice.setOnClickListener(this);}@Overridepublic void onClick(View v){Intent intent = new Intent(this, NotificationActivity.class);PendingIntent pi = PendingIntent.getActivity(this, 0, intent, 0);NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {NotificationChannel channel = new NotificationChannel("normal", "Normal", NotificationManager.IMPORTANCE_DEFAULT);manager.createNotificationChannel(channel);}NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "normal").setContentTitle("This is content title").setContentText("This is content text").setSmallIcon(R.mipmap.ic_launcher).setContentIntent(pi).setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher));Notification notification = builder.build();manager.notify(1, notification);}
}

在这里插入图片描述

http://www.yayakq.cn/news/576830/

相关文章:

  • 泉州城乡建设网站太原网站建设哪家好
  • 哈尔滨企业网站建设公司免费网站空间 - 百度
  • site之后网站在首页说明说明响应式网站的优点
  • 做市级网站需要什么意思创业平台app有哪些
  • 手机网站设计建设服务广州网站建设 app 小程序
  • 美食网站设计论文怎样通过阿里巴巴网站开发客户
  • 合肥外贸网站建设公司wordpress公告栏插件
  • 广东省城乡建设厅投诉网站首页产品设计学什么内容
  • 蒲城网站建设做问卷哪个网站好
  • 180天做180个网站自己做一个app难吗
  • 阿里云建立网站备案手机开发者模式怎么开
  • 有没有什么网站做兼职巴中做网站 微信开发
  • 网站开发工具的功能自己做一个外贸网站怎么样
  • 知名网站建设定制开一家网站建设公司有前景吗
  • 中国轻工建设公司网站如何自己开发软件挣钱
  • 企业建立网站的好处动漫网站建站
  • 杭州网站设计哪家公司好个人网站可以做电商么
  • 北京单页营销型网站东莞服务好的营销型网站建设
  • 云南网站建设哪家便宜小程序注册拉新
  • 上弦 网站建设山东网站建设开发外包
  • 张云网站建设商业网站 技术
  • seo视频教学网站广西建设工程质量监督网站
  • 电商网站开发价格北京有几个区几个县
  • 广州网站建设信息科技有限公司深圳ppt设计公司
  • wordpress论坛样式江苏seo
  • 百度站长资源平台图片在线制作二维码
  • .net 企业网站源码网站开发公司erp
  • 局网站建设总结免费推广预期效果怎么写
  • 万网续费登录网站哪个网站设计好
  • 在临沂做网站提供wordpress空间