Friday, 27 March 2015

Implementing Different Notifications in Android

Hey Guys,

I'm just providing a demo code for the newest notification going now a days in our android phones.

Try these methods and Enjoy new phase of notifications in development.


1. Set Normal Notification 


private Notification setNormalNotification() {
Bitmap mNotificationPicture = null;

try {
mNotificationPicture = BitmapFactory
.decodeStream((InputStream) new URL(sample_url)
.getContent());
} catch (IOException e) {
e.printStackTrace();
}

// Setup an explicit intent for an ResultActivity to receive.
Intent resultIntent = new Intent(this, ResultActivity.class);

// TaskStackBuilder ensures that the back button follows the recommended
// convention for the back key.
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);

// Adds the back stack for the Intent (but not the Intent itself).
stackBuilder.addParentStack(ResultActivity.class);

// Adds the Intent that starts the Activity to the top of the stack.
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,
PendingIntent.FLAG_UPDATE_CURRENT);

return new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setAutoCancel(true)
.setLargeIcon(mNotificationPicture)
.setContentIntent(resultPendingIntent)
.addAction(R.drawable.ic_launcher, "One", resultPendingIntent)
.addAction(R.drawable.ic_launcher, "Two", resultPendingIntent)
.addAction(R.drawable.ic_launcher, "Three", resultPendingIntent)
.setContentTitle("Normal Notification")
.setContentText("This is an example of a Normal Style.")
.build();
}

Result :



2. Big Text Style Notification


private Notification setBigTextStyleNotification() {
Bitmap mNotificationPicture = null;

// Create the style object with BigTextStyle subclass.
NotificationCompat.BigTextStyle notiStyle = new NotificationCompat.BigTextStyle();
notiStyle.setBigContentTitle("Big Text Expanded");
notiStyle.setSummaryText("Nice big text.");

try {
mNotificationPicture = BitmapFactory
.decodeStream((InputStream) new URL(sample_url)
.getContent());
} catch (IOException e) {
e.printStackTrace();
}

CharSequence bigText = "This is a demo Big Text Style notification.This is a demo Big Text Style notification.This is a demo Big Text Style notification.This is a demo Big Text Style notification.This is a demo Big Text Style notification.This is a demo Big Text Style notification.This is a demo Big Text Style notification.";
notiStyle.bigText(bigText);

// Creates an explicit intent for an ResultActivity to receive.
Intent resultIntent = new Intent(this, ResultActivity.class);

// This ensures that the back button follows the recommended convention
// for the back key.
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);

// Adds the back stack for the Intent (but not the Intent itself).
stackBuilder.addParentStack(ResultActivity.class);

// Adds the Intent that starts the Activity to the top of the stack.
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,
PendingIntent.FLAG_UPDATE_CURRENT);

return new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setAutoCancel(true)
.setLargeIcon(mNotificationPicture)
.setContentIntent(resultPendingIntent)
.addAction(R.drawable.ic_launcher, "One", resultPendingIntent)
.addAction(R.drawable.ic_launcher, "Two", resultPendingIntent)
.addAction(R.drawable.ic_launcher, "Three", resultPendingIntent)
.setContentTitle("Big Text Normal")
.setContentText("This is an example of a Big Text Style.")
.setStyle(notiStyle).build();
}

Result :



3. Big Picture Style Notification

private Notification setBigPictureStyleNotification() {
Bitmap mNotificationPicture = null;

// Create the style object with BigPictureStyle subclass.
NotificationCompat.BigPictureStyle notiStyle = new NotificationCompat.BigPictureStyle();
notiStyle.setBigContentTitle("Big Picture Expanded");
notiStyle.setSummaryText("Nice big picture.");

try {
mNotificationPicture = BitmapFactory
.decodeStream((InputStream) new URL(sample_url)
.getContent());
} catch (IOException e) {
e.printStackTrace();
}

// Add the big picture to the style.
notiStyle.bigPicture(mNotificationPicture);

// Creates an explicit intent for an ResultActivity to receive.
Intent resultIntent = new Intent(this, ResultActivity.class);

// This ensures that the back button follows the recommended convention
// for the back key.
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);

// Adds the back stack for the Intent (but not the Intent itself).
stackBuilder.addParentStack(ResultActivity.class);

// Adds the Intent that starts the Activity to the top of the stack.
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,
PendingIntent.FLAG_UPDATE_CURRENT);

return new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setAutoCancel(true)
.setLargeIcon(mNotificationPicture)
.setContentIntent(resultPendingIntent)
.addAction(R.drawable.ic_launcher, "One", resultPendingIntent)
.addAction(R.drawable.ic_launcher, "Two", resultPendingIntent)
.addAction(R.drawable.ic_launcher, "Three", resultPendingIntent)
.setContentTitle("Big Picture Normal")
.setContentText("This is an example of a Big Picture Style.")
.setStyle(notiStyle).build();
}

Result :



4. Inbox Style Notification

private Notification setInboxStyleNotification() {
Bitmap mNotificationPicture = null;

// Create the style object with InboxStyle subclass.
NotificationCompat.InboxStyle notiStyle = new NotificationCompat.InboxStyle();
notiStyle.setBigContentTitle("Inbox Style Expanded");

// Add the multiple lines to the style.
// This is strictly for providing an example of multiple lines.
for (int i = 1; i <= 5; i++) {
notiStyle.addLine("(" + i + " of 6) Line one here.");
}
notiStyle.setSummaryText("+6 more Line Samples");

try {
mNotificationPicture = BitmapFactory
.decodeStream((InputStream) new URL(sample_url)
.getContent());
} catch (IOException e) {
e.printStackTrace();
}

// Creates an explicit intent for an ResultActivity to receive.
Intent resultIntent = new Intent(this, ResultActivity.class);

// This ensures that the back button follows the recommended convention
// for the back key.
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);

// Adds the back stack for the Intent (but not the Intent itself).
stackBuilder.addParentStack(ResultActivity.class);

// Adds the Intent that starts the Activity to the top of the stack.
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,
PendingIntent.FLAG_UPDATE_CURRENT);

return new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setAutoCancel(true)
.setLargeIcon(mNotificationPicture)
.setContentIntent(resultPendingIntent)
.addAction(R.drawable.ic_launcher, "One", resultPendingIntent)
.addAction(R.drawable.ic_launcher, "Two", resultPendingIntent)
.addAction(R.drawable.ic_launcher, "Three", resultPendingIntent)
.setContentTitle("Inbox Style Normal")
.setContentText("This is an example of a Inbox Style.")
.setStyle(notiStyle).build();
}


Result :



5. Custom View Notification

private Notification setCustomViewNotification() {

// Creates an explicit intent for an ResultActivity to receive.
Intent resultIntent = new Intent(this, ResultActivity.class);

// This ensures that the back button follows the recommended convention
// for the back key.
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);

// Adds the back stack for the Intent (but not the Intent itself)
stackBuilder.addParentStack(ResultActivity.class);

// Adds the Intent that starts the Activity to the top of the stack.
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,
PendingIntent.FLAG_UPDATE_CURRENT);

// Create remote view and set bigContentView.
RemoteViews expandedView = new RemoteViews(this.getPackageName(),
R.layout.notification_custom_remote);
expandedView.setTextViewText(R.id.text_view, "Neat logo!");

Notification notification = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher).setAutoCancel(true)
.setContentIntent(resultPendingIntent)
.setContentTitle("Custom View").build();

notification.bigContentView = expandedView;

return notification;
}

Result :






Happy Coding !! Cheers !!





Wednesday, 26 June 2013

Program To Add Two Numbers In Java.

import java.util.Scanner; 

class AddNumbers
{
   public static void main(String args[])
   {
      int no1, no2, result;
      System.out.println("Enter two integers to calculate their sum ");
      Scanner in = new Scanner(System.in);
      no1 = in.nextInt();
      no2 = in.nextInt();
      result = no1 + no2;
      System.out.println("Sum of entered integers = "+result);
   }
}




Tuesday, 10 July 2012

How To use multiview in C# in asp.net

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;


public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {


    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
     
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        MultiView1.ActiveViewIndex = DropDownList1.SelectedIndex;
    }
}


How To Use Multi View In C# in asp.net


using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;


public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {


    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
     
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        MultiView1.ActiveViewIndex = DropDownList1.SelectedIndex;
    }
}

File Upload Code in asp.net


using System;
using System.Web.UI.WebControls;

public partial class Management_FileUpload : System.Web.UI.Page
{

  protected void Button1_Click(object sender, EventArgs e)
  {


  FileUpload FileUpload1 = file_Image;

  string virtualFolder = "~/images/tutorialimages/";

  string physicalFolder = Server.MapPath(virtualFolder);


  FileUpload1.SaveAs(physicalFolder + FileUpload1.FileName);


  lbl_Result.Text = "Your file " + FileUpload1.FileName + " has been uploaded.";

  Image1.Visible = true;
  Image1.ImageUrl = virtualFolder + FileUpload1.FileName;


  }
}

Code To Travel In a Html Page. . . .


<!DOCTYPE html>
<html>
<body>


<p>
<a href="#C4">See also Chapter 4.</a>
</p>


<h2>Chapter 1</h2>
<p>This chapter explains ba bla bla</p>


<h2>Chapter 2</h2>
<p>This chapter explains ba bla bla</p>


<h2>Chapter 3</h2>
<p>This chapter explains ba bla bla</p>


<h2><a name="C4">Chapter 4</a></h2>
<p>This chapter explains ba bla bla</p>


<h2>Chapter 5</h2>
<p>This chapter explains ba bla bla</p>


<h2>Chapter 6</h2>
<p>This chapter explains ba bla bla</p>


<h2>Chapter 7</h2>
<p>This chapter explains ba bla bla</p>


<h2>Chapter 8</h2>
<p>This chapter explains ba bla bla</p>


<h2>Chapter 9</h2>
<p>This chapter explains ba bla bla</p>


<h2>Chapter 10</h2>
<p>This chapter explains ba bla bla</p>


<h2>Chapter 11</h2>
<p>This chapter explains ba bla bla</p>


<h2>Chapter 12</h2>
<p>This chapter explains ba bla bla</p>


<h2>Chapter 13</h2>
<p>This chapter explains ba bla bla</p>


<h2>Chapter 14</h2>
<p>This chapter explains ba bla bla</p>


<h2>Chapter 15</h2>
<p>This chapter explains ba bla bla</p>


<h2>Chapter 16</h2>
<p>This chapter explains ba bla bla</p>


<h2>Chapter 17</h2>
<p>This chapter explains ba bla bla</p>


</body>
</html>

Saturday, 30 June 2012

Simple Javascript


<html>
<head>
   <title>kamal Javascript Code</title>
</head>
<body>
<script type="text/javascript" language="JavaScript">
   document.writeln( "Hi Guys U r Using Kamal Code" );
var j = 10;
for (i=0; i<10; i++)
{
      j=j+1;
}
   document.writeln( "value of j="+j );
</script>
</body>
</html>