Get Notification Icon Using An Accessibility Service
Is there any way to get icons of system notifications? I can get a notification parcel with Accessibility service. I can even get the id of the icon from it, but I am stuck there.
Solution 1:
So I managed to accomplish this by searching for the first ImageView in the RemoteViews
extractImage(notification.contentView);
...
privatevoidextractImage(RemoteViews views) {
LinearLayoutll=newLinearLayout(getApplicationContext());
Viewview= views.apply(getApplicationContext(), ll);
drawable = searchForBitmap(view);
Log.d("Drawable: " + drawable);
}
private Drawable searchForBitmap(View view) {
if (view instanceof ImageView) {
return ((ImageView) view).getDrawable();
}
if (view instanceof ViewGroup) {
ViewGroupviewGroup= (ViewGroup) view;
for (inti=0; i < viewGroup.getChildCount(); i++) {
Drawableresult= searchForBitmap(viewGroup.getChildAt(i));
if (result != null) {
return result;
}
}
}
returnnull;
}
Post a Comment for "Get Notification Icon Using An Accessibility Service"