I am new to android development , i want to show push notification every day when application is closed in android. I know that i need to create service and broadcast receiver for it but i don't to do it practically. Here is my code for simple push notification please help me to make the push notification in every day.
public class MainActivity extends Activity {
EditText ed1,ed2,ed3;
Notification notification;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button b1=(Button)findViewById(R.id.button);
final NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
b1.setOnClickListener(new View.OnClickListener() {
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public void onClick(View v) {
Notification.Builder builder = new Notification.Builder(MainActivity.this);
Intent resultIntent = new Intent(MainActivity.this,Splash.class);
resultIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0,
resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setSmallIcon(R.drawable.icon)
.setContentIntent(pendingIntent)
.setContentTitle("title");
notification = builder.build();
manager.notify(0, notification);
}
});
}}
Please help me to achieve the functionality i need with alarm manager or services.