印地语中的Android推送通知& Gujrati

时间:2014-03-06 06:08:12

标签: android notifications

我想显示通知印地文和古吉拉特语。我的应用支持2.2及更高版本。我使用下面的方法来显示通知。

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);
}

0 个答案:

没有答案
相关问题