please help me to set the text in textview in custom notification
private void startNotification()
{
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager notificationManager = (NotificationManager) getSystemService(ns);
Notification notification = new Notification(R.drawable.ic_launcher, null, System.currentTimeMillis());
RemoteViews notificationView = new RemoteViews(getPackageName(),R.layout.mynotification);
mRemoteViews.setTextViewText(R.id.appName, getResources().getText(0,"gfhf"));
mBuilder.setContent(mRemoteViews);
Intent notificationIntent = new Intent(this, FlashLight.class);
PendingIntent pendingNotificationIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.contentView = notificationView;
notification.contentIntent = pendingNotificationIntent;
notification.flags |= Notification.FLAG_NO_CLEAR;
Intent switchIntent = new Intent(this, switchButtonListener.class);
PendingIntent pendingSwitchIntent = PendingIntent.getBroadcast(this, 0, switchIntent, 0);
notificationView.setOnClickPendingIntent(R.id.closeOnFlash, pendingSwitchIntent);
notificationManager.notify(1, notification);
}
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.RemoteViews.setTextViewText(int, java.lang.CharSequence)' on a null object reference
Please help me how to resolve this . how to set the value on textview in notification in android , Thanks in advance .