Android 安卓推送通知(印地语);古吉拉提语
我想展示印地语和古吉拉特语。我的应用程序支持2.2及更高版本。我使用下面的方法来显示通知Android 安卓推送通知(印地语);古吉拉提语,android,notifications,Android,Notifications,我想展示印地语和古吉拉特语。我的应用程序支持2.2及更高版本。我使用下面的方法来显示通知 public void sendnotification(String title, String message, String newsID, String photoURL, String language) { String ns = Context.NOTIFICATION_SERVICE; PendingIntent contentIntent; Notificati
public void sendnotification(String title, String message, String newsID, String photoURL, String language) {
String ns = Context.NOTIFICATION_SERVICE;
PendingIntent contentIntent;
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns);
int icon = R.drawable.icon;
RemoteViews contentView = new RemoteViews(context.getPackageName(), R.layout.custom_notification_layout);
if (photoURL != null && !photoURL.equalsIgnoreCase(""))
contentView.setImageViewBitmap(R.id.image, Utility.getInstance().downloadBitmap(photoURL));
else
contentView.setImageViewResource(R.id.image, icon);
contentView.setTextViewText(R.id.text, message);
CharSequence tickerText = message;
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);
notification.contentView = contentView;
if (newsID == null) {
Intent notificationIntent = new Intent(context, SplashActivity.class);
contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_ONE_SHOT);
notification.flags = Notification.FLAG_AUTO_CANCEL;
notification.contentIntent = contentIntent;
} else {
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List<RunningTaskInfo> services = activityManager.getRunningTasks(Integer.MAX_VALUE);
boolean isActivityFound = false;
if (services.get(0).topActivity.getPackageName().toString().equalsIgnoreCase(context.getPackageName().toString())) {
isActivityFound = true;
}
// if (isActivityFound) {
// Intent notificationIntent = new Intent(context,
// NewsDetailActivity.class);
// notificationIntent.putExtra(context.getResources().getString(R.string.news_storyId),
// newsID);
// contentIntent = PendingIntent.getActivity(context, 0,
// notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
// } else {
Intent notificationIntent = new Intent(context, SplashActivity.class);
notificationIntent.putExtra(context.getResources().getString(R.string.storyId), newsID);
notificationIntent.putExtra(context.getResources().getString(R.string.storylanguage), language);
contentIntent = PendingIntent.getActivity(context, notificationId++, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
// }
notification.flags = Notification.FLAG_AUTO_CANCEL;
notification.contentIntent = contentIntent;
}
Random randInt = new Random();
int id = randInt.nextInt(100) - 1;
mNotificationManager.notify(id, notification);
}
public void sendnotification(字符串标题、字符串消息、字符串新闻ID、字符串照片URL、字符串语言){
字符串ns=Context.NOTIFICATION\u服务;
悬而未决的意图;
NotificationManager mNotificationManager=(NotificationManager)context.getSystemService(ns);
int icon=R.drawable.icon;
RemoteViews contentView=新的RemoteView(context.getPackageName(),R.layout.custom\u notification\u layout);
if(photoURL!=null&!photoURL.equalsIgnoreCase(“”)
setImageViewBitmap(R.id.image,Utility.getInstance().downloadBitmap(photoURL));
其他的
setImageViewResource(R.id.image,图标);
setTextViewText(R.id.text,消息);
CharSequence tickerText=消息;
长时间=System.currentTimeMillis();
通知通知=新通知(图标,tickerText,何时);
notification.contentView=contentView;
if(newsID==null){
Intent notificationIntent=新的意图(上下文,SplashActivity.class);
contentIntent=pendingent.getActivity(上下文,0,notificationIntent,pendingent.FLAG_ONE_SHOT);
notification.flags=notification.FLAG\u AUTO\u CANCEL;
notification.contentIntent=contentIntent;
}否则{
ActivityManager ActivityManager=(ActivityManager)context.getSystemService(context.ACTIVITY_服务);
列表服务=activityManager.getRunningTasks(整数.MAX_值);
布尔值isActivityFound=false;
if(services.get(0).topActivity.getPackageName().toString().equalsIgnoreCase(context.getPackageName().toString())){
isActivityFound=true;
}
//如果(isActivityFound){
//意向通知意向=新意向(上下文,
//NewsDetailActivity.class);
//notificationIntent.putExtra(context.getResources().getString(R.string.news\u storyId),
//新闻ID);
//contentIntent=PendingEvent.getActivity(上下文,0,
//notificationIntent,PendingEvent.FLAG_UPDATE_CURRENT);
//}其他{
Intent notificationIntent=新的意图(上下文,SplashActivity.class);
notificationIntent.putExtra(context.getResources().getString(R.string.storyId)、newsID);
notificationIntent.putExtra(context.getResources().getString(R.string.storylanguage),language);
contentIntent=pendingent.getActivity(上下文、notificationId++、notificationIntent、pendingent.FLAG_UPDATE_CURRENT);
// }
notification.flags=notification.FLAG\u AUTO\u CANCEL;
notification.contentIntent=contentIntent;
}
Random randInt=新的Random();
int id=randInt.nextInt(100)-1;
mNotificationManager.notify(id,通知);
}
您对此有什么解决方案吗