How to create a chronometer in a notification Android?

后端 未结 2 795
礼貌的吻别
礼貌的吻别 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
    

提交回复
热议问题