Ezio Ezio - 4 days ago 5
Android Question

Android Remote View not picking up the correct layout based on the language

I am developing an app which supports both English and Arabic languages. The app shows custom notifications to the user for which I am using remote views.I have added layouts for both english and arabic languages is respective layout resource files.

My problem is my app shows correct notifications when the app language is English but when I change the language to Arabic it is not picking up the arabic layout, it still shows the English layout.

FYI :- I am using a Service to show the notifications (because I need to make some network calls).

RemoteViews largeRemoteView = new RemoteViews(context.getPackageName(), R.layout.layout_new_download_notification);
RemoteViews smallRemoteView = new RemoteViews(context.getPackageName(), R.layout.layout_new_download_notification_small);

NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
Notification notification = builder.setSmallIcon(R.drawable.ic_launcher)
.setContentIntent(pendingIntent)
.setAutoCancel(true)
.setPriority(Notification.PRIORITY_MAX)
.build();
notificationManager.notify(mNotificationId, notification);


I have
layout_new_download_notification
and
layout_new_download_notification_small
in both layout and layout-ar files but android is not picking up the arabic layout on language change.

Thanks in advance

Answer

Changing the device language to the specific language did the trick

Comments