, http://www.codeproject.com/Questions/567126/AndroidplusNotificationplusinplusotherpluslanguage
EDIT:
custom_notification.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/custom_notification"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" >
<ImageView
android:id="@+id/notification_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_margin="5dip"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/notification_text"
style="@style/NotificationText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_toRightOf="@+id/notification_image"
android:maxLines="3"
android:layout_centerVertical="true"
android:ellipsize="end"
android:text="@string/app_name" />
</RelativeLayout>
android
private static void generateNotification(Context context,
SpannableStringBuilder message) {
int icon = R.drawable.ic_launcher;
Date date = new Date();
int notificationid = (int) date.getTime();
long when = System.currentTimeMillis();
NotificationManager notificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(icon, message, when);
String title = context.getString(R.string.app_name);
Intent notificationIntent = new Intent(context, MainActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent = PendingIntent.getActivity(context,
notificationid, notificationIntent, 0);
RemoteViews contentView = new RemoteViews(context
.getApplicationContext().getPackageName(),
R.layout.custom_notification);
contentView.setImageViewResource(R.id.notification_image,
R.drawable.ic_launcher);
contentView.setTextViewText(R.id.notification_text, message);
notification.contentView = contentView;
notification.contentIntent = intent;
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(notificationid, notification);
}
:
SpannableStringBuilder sb = new SpannableStringBuilder("āĻŽā§āĻā§āϝāĻŽāύā§āϤā§āϰ⧠āĻšāĻā§āĻžāϰ āĻĒāϰ āĻĨā§āĻā§āĻ āϰāĻžāĻā§āϝā§āϰ āĻšāĻžāϤ⧠āĻāϰāĻ āĻŦā§āĻļāĻŋ āĻā§āώāĻŽāϤāĻž 4āĻĻā§āĻā§āĻžāϰ āĻĻāĻžāĻŦāĻŋāϤ⧠āĻŦāĻžāϰā§āĻŦāĻžāϰ⧠āϏāϰāĻŦ āĻšā§ā§āĻā§āύ āϤāĻŋāύāĻŋ");
Typeface font = Typeface.createFromAsset(getAssets(), "kalpurush.ttf");
sb.setSpan(new CustomTypefaceSpan("", font), 0, sb.length() - 1,
Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
generateNotification(context, sb);
UPDATE:
public class CustomTypefaceSpan extends TypefaceSpan {
private final Typeface newType;
public CustomTypefaceSpan(String family, Typeface type) {
super(family);
newType = type;
}
@Override
public void updateDrawState(TextPaint ds) {
applyCustomTypeFace(ds, newType);
}
@Override
public void updateMeasureState(TextPaint paint) {
applyCustomTypeFace(paint, newType);
}
private static void applyCustomTypeFace(Paint paint, Typeface tf) {
int oldStyle;
Typeface old = paint.getTypeface();
if (old == null) {
oldStyle = 0;
} else {
oldStyle = old.getStyle();
}
int fake = oldStyle & ~tf.getStyle();
if ((fake & Typeface.BOLD) != 0) {
paint.setFakeBoldText(true);
}
if ((fake & Typeface.ITALIC) != 0) {
paint.setTextSkewX(-0.25f);
}
paint.setTypeface(tf);
}
}
,