Main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<Button
android:onClick="show"
android:text="Click here"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:onClick="show"
android:text="Click here"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
MainActivity.java
package com.kc.ExpandableNotification;
MainActivity.java
package com.kc.ExpandableNotification;
import android.app.*;
import android.os.*;
import android.view.*;
import android.content.*;
import android.os.*;
import android.view.*;
import android.content.*;
public class MainActivity extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void show (View v){
Notification.Builder nb=new Notification.Builder(this);
nb.setContentTitle("Notification");
nb.setContentText("Downloaded");
nb.setSmallIcon(R.drawable.ic_launcher);
Notification.InboxStyle nis=new Notification.InboxStyle();
nis.setBigContentTitle("Downloaded part");
nis.addLine("Part 1");
nis.addLine("Part 2");
nis.addLine("Part 3");
nis.addLine("Part 4");
nis.addLine("Part 5");
nis.addLine("Part 6");
nis.addLine("Part 7");
nis.addLine("Part 8");
nb.setStyle(nis);
NotificationManager nm=(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(1,nb.build());
}
}
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void show (View v){
Notification.Builder nb=new Notification.Builder(this);
nb.setContentTitle("Notification");
nb.setContentText("Downloaded");
nb.setSmallIcon(R.drawable.ic_launcher);
Notification.InboxStyle nis=new Notification.InboxStyle();
nis.setBigContentTitle("Downloaded part");
nis.addLine("Part 1");
nis.addLine("Part 2");
nis.addLine("Part 3");
nis.addLine("Part 4");
nis.addLine("Part 5");
nis.addLine("Part 6");
nis.addLine("Part 7");
nis.addLine("Part 8");
nb.setStyle(nis);
NotificationManager nm=(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(1,nb.build());
}
}
0 comments:
Post a Comment