for more information: http://dj-android.blogspot.in/2013/04/android-notifications-3-applying-big.html
using AsynTask:
class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
@Override
protected Bitmap doInBackground(String... params) {
String urldisplay = params[0];
Bitmap mIcon11 = null;
try {
InputStream in = new java.net.URL(urldisplay).openStream();
mIcon11 = BitmapFactory.decodeStream(in);
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return mIcon11;
}
@Override
protected void onPostExecute(Bitmap result) {
super.onPostExecute(result);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
context).setAutoCancel(true).setContentTitle(message)
.setSmallIcon(R.drawable.icon);
NotificationCompat.BigPictureStyle bigPicStyle = new NotificationCompat.BigPictureStyle();
bigPicStyle.bigPicture(result);
// bigPicStyle.setBigContentTitle("TEST BIG NOTIGICATION");
mBuilder.setStyle(bigPicStyle);
// implement click in notification bar.
// end implement click.
NotificationManager mNotificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
// mId allows you to update the notification later on.
mNotificationManager.notify(100, mBuilder.build());
}
}
or this way:
Bitmap icon1 = BitmapFactory.decodeResource(getResources(),
R.drawable.dhaval1);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
this).setAutoCancel(true)
.setContentTitle("DJ-Android notification")
.setSmallIcon(R.drawable.ic_launcher).setLargeIcon(icon1)
.setContentText("Hello World!");
NotificationCompat.BigPictureStyle bigPicStyle = new NotificationCompat.BigPictureStyle();
bigPicStyle.bigPicture(icon1);
bigPicStyle.setBigContentTitle("Dhaval Sodha Parmar");
mBuilder.setStyle(bigPicStyle);
// Creates an explicit intent for an Activity in your app
Intent resultIntent = new Intent(this, testActivity.class);
// The stack builder object will contain an artificial back stack for
// the
// started Activity.
// This ensures that navigating backward from the Activity leads out of
// your application to the Home screen.
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
// Adds the back stack for the Intent (but not the Intent itself)
stackBuilder.addParentStack(testActivity.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);
mBuilder.setContentIntent(resultPendingIntent);
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// mId allows you to update the notification later on.
mNotificationManager.notify(100, mBuilder.build());
0 comments:
Post a Comment