2018.11.28

private fun getNotifyExpand(ctx: Context, event: String, song: String, isPlay: Boolean, progress: Int, time: Long):RemoteViews{
        val notify_expand = RemoteViews(ctx.packageName, R.layout.activity_main)
        if(isPlay){
            notify_expand.setTextViewText(R.id.gone, "pause")
            notify_expand.setTextViewText(R.id.packed, song+" playing")
            notify_expand.setChronometer(R.id.percent, time, "%s", true)
        }else{
            notify_expand.setTextViewText(R.id.spread, "continue")
            notify_expand.setTextViewText(R.id.wrap, song+ "continue")
            notify_expand.setChronometer(R.id.percent, time, "%s", false)
        }
        notify_expand.setProgressBar(R.id.gone, 100, progress, false)
        val pIntent = Intent(event)
        val piPause = PendingIntent.getBroadcast(ctx, R.string.app_name, pIntent, PendingIntent.FLAG_UPDATE_CURRENT)

        notify_expand.setOnClickPendingIntent(R.id.gone, piPause)
        val bIntent = Intent(ctx, MainActivity::class.java)
        val piBack = PendingIntent.getActivity(ctx, R.string.app_name, bIntent, PendingIntent.FLAG_UPDATE_CURRENT)

        notify_expand.setOnClickPendingIntent(R.id.packed, piBack)
        return notify_expand
    }

在这里插入图片描述

Logo

开源鸿蒙跨平台开发社区汇聚开发者与厂商,共建“一次开发,多端部署”的开源生态,致力于降低跨端开发门槛,推动万物智联创新。

更多推荐