我有一台三星 Galaxy y Duo 和一台 Google Nexus 5。我的应用程序在两部手机上运行。我必须以两种语言(卡纳达语和英语)提供此应用程序。我通过切换区域设置来选择语言(按照惯例)。
Nexus 5 的区域设置列表中有区域设置“kn”,而 Y Duos 中没有“kn”。但是当我尝试在values-kn文件夹中使用String.xml时,卡纳达语文本在Y Duos中正确呈现,即使它没有“kn”区域设置。
我有一段代码,用于查找“kn”区域设置并启用/禁用卡纳达语言功能。下面给出。
public boolean isLocalePresent(Locale newLocale) {
Locale[] locales = Locale.getAvailableLocales();
for (Locale locale : locales) {
if (locale.getLanguage().equals(newLocale.getLanguage()) {
return true;
}
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
我这样称呼它;
if (isLocalePresent(new Locale("kn"))) {
// change default locale to "kn"
}
Run Code Online (Sandbox Code Playgroud)
谁能告诉我如何让我的应用程序在所有可以呈现卡纳达文本的手机中使用卡纳达文本。?即使区域设置列表中不存在“kn”区域设置,我如何知道手机是否支持卡纳达语文本渲染?
我在锁定屏幕中显示了一个自定义通知。单击通知后,我正在使用广播待处理意图向我的应用程序发送消息。稍后在广播接收器中启动一个活动。
问题是,一旦我点击通知,它就会从锁屏中消失,并且活动在锁屏后面启动。它不会要求用户解锁屏幕。
我的要求是要求用户在通知的点击事件发送广播后立即解锁屏幕。我怎么做?
我可以找到这个看起来像我的问题的问题。但不幸的是,没有答案。
这是一些解释我所做的通知创建的代码。
/**
* Method to render Notification
*/
private void showNotification() {
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
/* set mandatory stuff on builder */
Notification notification = builder.build();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
notification.bigContentView = createCustomView(context);
}
NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify(getNotificationId(), notification);
}
/**
* Method to return notification click's PendingIntent
*/
private PendingIntent getNotificationClickIntent() {
Intent bcIntent = new Intent(OPEN_APP);
bcIntent.putExtra(EXTRA_DEEP_LINK_URL, getDeepLinkUrl());
return PendingIntent.getBroadcast(
context, getReqCode(), bcIntent, PendingIntent.FLAG_ONE_SHOT);
}
/**
* …Run Code Online (Sandbox Code Playgroud)