Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Some more changes in JellyBeanNotification

  • Loading branch information...
commit 9520d5e58e7351485a3122d60630a23e67c679b7 1 parent 5826169
@rakeshcusat authored
View
10 AndroidProjects/JellyBeanNotificationExample/AndroidManifest.xml
@@ -5,7 +5,7 @@
<uses-sdk
android:minSdkVersion="16"
- android:targetSdkVersion="15" />
+ android:targetSdkVersion="16" />
<application
android:icon="@drawable/ic_launcher"
@@ -15,7 +15,13 @@
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
-
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity
+ android:name=".HandleNotificationActivity"
+ android:label="@string/title_activity_main" >
+ <intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
View
10 AndroidProjects/JellyBeanNotificationExample/bin/AndroidManifest.xml
@@ -5,7 +5,7 @@
<uses-sdk
android:minSdkVersion="16"
- android:targetSdkVersion="15" />
+ android:targetSdkVersion="16" />
<application
android:icon="@drawable/ic_launcher"
@@ -15,7 +15,13 @@
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
-
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity
+ android:name=".HandleNotificationActivity"
+ android:label="@string/title_activity_main" >
+ <intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
View
BIN  AndroidProjects/JellyBeanNotificationExample/bin/JellyBeanNotificationExample.apk
Binary file not shown
View
25 ...Projects/JellyBeanNotificationExample/gen/com/example/jellybeannotificationexample/R.java
@@ -16,26 +16,39 @@
public static final int padding_small=0x7f040000;
}
public static final class drawable {
- public static final int android_jelly_bean=0x7f020000;
- public static final int ic_action_search=0x7f020001;
- public static final int ic_launcher=0x7f020002;
+ public static final int big_picture=0x7f020000;
+ public static final int button_background=0x7f020001;
+ public static final int ic_action_search=0x7f020002;
+ public static final int ic_launcher=0x7f020003;
+ public static final int ic_launcher_share=0x7f020004;
+ public static final int ic_launcher_web=0x7f020005;
}
public static final class id {
- public static final int btNotification=0x7f080000;
- public static final int menu_settings=0x7f080001;
+ public static final int bgButton=0x7f080005;
+ public static final int btBasicNotification=0x7f080000;
+ public static final int btBigPictureNotification=0x7f080002;
+ public static final int btBigTextNotification=0x7f080001;
+ public static final int btInboxStyleNotification=0x7f080003;
+ public static final int menu_settings=0x7f080006;
+ public static final int textView1=0x7f080004;
}
public static final class layout {
public static final int activity_main=0x7f030000;
+ public static final int handle_notification_activity=0x7f030001;
}
public static final class menu {
public static final int activity_main=0x7f070000;
}
public static final class string {
public static final int app_name=0x7f050000;
- public static final int btBigTextNotification=0x7f050004;
+ public static final int btBasicNotification=0x7f050004;
+ public static final int btBigPictureNotification=0x7f050006;
+ public static final int btBigTextNotification=0x7f050005;
+ public static final int btInboxStyleNotification=0x7f050007;
public static final int hello_world=0x7f050001;
public static final int menu_settings=0x7f050002;
public static final int title_activity_main=0x7f050003;
+ public static final int tvHandleNotification=0x7f050008;
}
public static final class style {
public static final int AppTheme=0x7f060000;
View
BIN  AndroidProjects/JellyBeanNotificationExample/res/drawable-hdpi/android_jelly_bean.jpg
Deleted file not rendered
View
BIN  AndroidProjects/JellyBeanNotificationExample/res/drawable-hdpi/ic_action_search.png
Deleted file not rendered
View
47 AndroidProjects/JellyBeanNotificationExample/res/layout/activity_main.xml
@@ -2,12 +2,45 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:orientation="vertical">
- <Button
- android:id="@+id/btNotification"
- android:text="@string/btBigTextNotification"
- android:onClick="sendNotification"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"/>
+ android:orientation="vertical"
+ android:gravity="center_horizontal">
+ <Button
+ android:id="@+id/btBasicNotification"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_horizontal|center_vertical"
+ android:onClick="sendBasicNotification"
+ android:text="@string/btBasicNotification"
+ android:background="@drawable/button_background"
+ android:textColor="#000000"
+ />
+ <Button
+ android:id="@+id/btBigTextNotification"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_horizontal|center_vertical"
+ android:onClick="sendBigTextNotification"
+ android:text="@string/btBigTextNotification"
+ android:background="@drawable/button_background"
+ android:textColor="#000000"
+ />
+ <Button
+ android:id="@+id/btBigPictureNotification"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_horizontal|center_vertical"
+ android:onClick="sendBigPictureNotification"
+ android:text="@string/btBigPictureNotification"
+ android:background="@drawable/button_background"
+ android:textColor="#000000" />
+ <Button
+ android:id="@+id/btInboxStyleNotification"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_horizontal|center_vertical"
+ android:onClick="sendInboxStyleNotification"
+ android:text="@string/btInboxStyleNotification"
+ android:background="@drawable/button_background"
+ android:textColor="#000000"/>
</LinearLayout>
View
8 AndroidProjects/JellyBeanNotificationExample/res/values/strings.xml
@@ -3,6 +3,10 @@
<string name="app_name">JellyBeanNotificationExample</string>
<string name="hello_world">Hello world!</string>
<string name="menu_settings">Settings</string>
- <string name="title_activity_main">MainActivity</string>
- <string name="btBigTextNotification">Send Big text Notification</string>
+ <string name="title_activity_main">JB Notification</string>
+ <string name="btBasicNotification">Send Basic Notification</string>
+ <string name="btBigTextNotification">Send Big Text Notification</string>
+ <string name="btBigPictureNotification">Send Big Picture Notification</string>
+ <string name="btInboxStyleNotification">Send Inbox Style Notification</string>
+ <string name="tvHandleNotification">You can handle notification intent here.</string>
</resources>
View
68 ...icationExample/src/com/example/jellybeannotificationexample/NotificationMainActivity.java
@@ -1,6 +1,5 @@
package com.example.jellybeannotificationexample;
-import android.R;
import android.os.Bundle;
import android.app.Activity;
import android.app.Notification;
@@ -29,14 +28,16 @@ public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
-
- public void sendNotification(View view){
- Context context = getApplicationContext();
- Toast.makeText(context, "Just a test", Toast.LENGTH_SHORT).show();
- createNotificationforBigText();
+ public void sendBasicNotification(View view){
+ Notification notification = new Notification.Builder(this)
+ .setContentTitle("Basic Notification")
+ .setContentText("Basic Notification, used earlier")
+ .setSmallIcon(R.drawable.ic_launcher_share).build();
+ notification.flags |= Notification.FLAG_AUTO_CANCEL;
+ NotificationManager notificationManager = getNotificationManager();
+ notificationManager.notify(0, notification);
}
-
- public void createNotificationforBigText(){
+ public void sendBigTextNotification(View view){
String msgText = "Jeally Bean Notification example!! "+
"where you will see three different kind of notification. " +
"you can even put the very long string here.";
@@ -44,44 +45,57 @@ public void createNotificationforBigText(){
NotificationManager notificationManager = getNotificationManager();
PendingIntent pi = getPendingIntent();
Builder builder = new Notification.Builder(this);
- builder.setContentTitle("JB Notofication")
- .setContentText("Jelly Bean Notification")
- .setSmallIcon(R.drawable.ic_launcher)
- .addAction(R.drawable.ic_action_search, "show activity", pi);
- Notification noti = new Notification.BigTextStyle(builder).bigText(msgText).build();
- noti.flags |= Notification.FLAG_AUTO_CANCEL; //Put the auto cancel notification.
- //noti.contentIntent = pi; //Associate the intent here.
- notificationManager.notify(0, noti);
+ builder.setContentTitle("Big text Notofication")
+ .setContentText("Big text Notification")
+ .setSmallIcon(R.drawable.ic_launcher);
+ //.addAction(R.drawable.ic_launcher_web, "show activity", pi);
+ Notification notification = new Notification.BigTextStyle(builder).bigText(msgText).build();
+ notification.flags |= Notification.FLAG_AUTO_CANCEL; //Put the auto cancel notification.
+ notification.contentIntent = pi; //Associate the intent here.
+ notificationManager.notify(0, notification);
}
- public void createBigpictureNotification(){
+ public void sendBigPictureNotification(View view){
PendingIntent pi = getPendingIntent();
Builder builder = new Notification.Builder(this);
builder.setContentTitle("BP notification") //Notification title
.setContentText("BigPicutre notification") //you can put subject line.
.setSmallIcon(R.drawable.ic_launcher) //Set your notification icon here.
- .addAction(R.drawable.ic_action_search, "show activity", pi);
+ .addAction(R.drawable.ic_launcher_web, "show activity", pi)
+ .addAction(R.drawable.ic_launcher_share,
+ "Share",
+ PendingIntent.getActivity(getApplicationContext(), 0,
+ getIntent(), 0, null));
//Now create the Big picture notification.
Notification notification = new Notification.BigPictureStyle(builder)
- .bigPicture(BitmapFactory.decodeResource(getResources(), R.drawable.android_jelly_bean)).build();
+ .bigPicture(BitmapFactory.decodeResource(getResources(), R.drawable.big_picture)).build();
+ notification.flags |= Notification.FLAG_AUTO_CANCEL; //Put the auto cancel notification.
NotificationManager notificationManager = getNotificationManager();
notificationManager.notify(0, notification);
}
- public void createInboxStyleNotification(){
- Builder builder = new Notification.Builder()
+ public void sendInboxStyleNotification(View view){
+ PendingIntent pi = getPendingIntent();
+ Builder builder = new Notification.Builder(this)
.setContentTitle("IS Notification")
.setContentText("Inbox Style notification!!")
- .setSmallIcon(R.drawable.ic_launcher);
- Notification noti = new Notification.InboxStyle(builder)
- .addLine("IS notification 1st message")
- .addLine("IS notification 2st message")
- .setContentTitle("")
+ .setSmallIcon(R.drawable.ic_launcher)
+ .addAction(R.drawable.ic_launcher_web, "show activity", pi);
+
+ Notification notification = new Notification.InboxStyle(builder)
+ .addLine("First message")
+ .addLine("Second message")
+ .addLine("Thrid message")
+ .addLine("Fourth Message")
.setSummaryText("+2 more")
.build();
+
+ notification.flags |= Notification.FLAG_AUTO_CANCEL; //Put the auto cancel notification.
+ NotificationManager notificationManager = getNotificationManager();
+ notificationManager.notify(0, notification);
}
public PendingIntent getPendingIntent(){
- return PendingIntent.getActivity(this, 0, new Intent(this, NotificationMainActivity.class), 0);
+ return PendingIntent.getActivity(this, 0, new Intent(this, HandleNotificationActivity.class), 0);
}
public NotificationManager getNotificationManager(){
return (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Please sign in to comment.
Something went wrong with that request. Please try again.