Retrieve text from a RemoteViews Object

前端 未结 4 2204
北荒
北荒 2021-02-09 22:25

I need to retrieve some text from a RemoteViews object. It is possible for me to get the LayoutId, but I have no idea how to retrieve text from a TextView

4条回答
  •  南方客
    南方客 (楼主)
    2021-02-09 23:06

    If you are targeting on Android 19+, you can use the following code for getting title/text from a Notification object without using any private APIs.

    Notification noty = ...;
    Bundle extras = noty.extras;
    if (extras != null) {
      String title = extras.getString(Notification.EXTRA_TITLE);
      String text = extras.getString(Notification.EXTRA_TEXT);
    }
    

提交回复
热议问题