How to create a chronometer in a notification Android?

后端 未结 2 794
礼貌的吻别
礼貌的吻别 2021-01-16 19:43

I have the following method below:

public NotificationCompat.Builder createNotification(Context context) {
    Intent intent = new Intent(this, MapsActivity.         


        
相关标签:
2条回答
  • 2021-01-16 20:13

    So creating the App Widget layout is simple if you know how to work with Layouts. However, you have to be aware that App Widget layouts are based on RemoteViews, which do not support every kind of layout or view widget. Anyway if you need asistance with App Widget layout here is some guaidance: https://developer.android.com/guide/practices/ui_guidelines/widget_design.html

    Luckily for you RemoteViews support Chronometer as you can see from developer webiste: https://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout

    A think you can acces your Chronometer as usually and you could do something like this depends do you want it to pause, resume, whatever:

    remoteView.setChronometer(R.id.myChronometere, SystemClock.elapsedRealtime(),
                          null, false); //pausing
    
    0 讨论(0)
  • 2021-01-16 20:20

    You can use built in chronometer:

    builder = new NotificationCompat.Builder(context)
    builder.setUsesChronometer(true)
    ...
    builder.build()
    
    0 讨论(0)
提交回复
热议问题