java - How can I pass view as parameter in android? -
i want create notification daily in android app. purpose made createnotification method. now, want call method @ particular time. mainactivity.java follows:
package com.example.shiza.dailyquranquote; import android.content.intent; import android.content.sharedpreferences; import android.support.v7.app.actionbaractivity; import android.os.bundle; import android.view.menu; import android.view.menuitem; import android.view.view; import android.widget.textview; import android.widget.toast; import android.app.notification; import android.app.notificationmanager; import android.app.pendingintent; import java.util.calendar; import java.util.date; public class mainactivity extends actionbaractivity { date startdate= new date("03/31/2015 12:00:00"); date enddate = new date(); textview textview ; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); textview = (textview)findviewbyid(r.id.verse); long startday = startdate.gettime() / 1000 / 60 / 60 / 24; long endday = enddate.gettime() / 1000 / 60 / 60 / 24; long daysbetween = endday - startday; sharedpreferences sharedpreferences = getsharedpreferences("quranverse",0); string id = ""+ (daysbetween % 365) ; string verse = sharedpreferences.getstring(id, ""); if (verse == null) { verse ="sufficient allah me; there no power except him; , in him put trust."; } calendar rightnow = calendar.getinstance(); textview.settext(verse + "current hour is" + rightnow.hour_of_day); if ( rightnow.hour_of_day == 11 ) { createnotification(); } } public void gotoinsertverse(view v) { intent intent = new intent(this,insertverse.class); startactivity(intent); } public void gotogetverse(view v) { intent intent = new intent(this,getverse.class); startactivity(intent); } public void createnotification(view view) { // prepare intent triggered if // notification selected intent intent = new intent(this, mainactivity.class); pendingintent pintent = pendingintent.getactivity(this, 0, intent, 0); // build notification // actions fake notification noti = new notification.builder(this) .setcontenttitle("new mail " + "test@gmail.com") .setcontenttext("subject").setsmallicon(r.drawable.background) .setcontentintent(pintent) .build(); notificationmanager notificationmanager = (notificationmanager) getsystemservice(notification_service); // hide notification after selected noti.flags |= notification.flag_auto_cancel; notificationmanager.notify(0, noti); } } now need pass view parameter createnotification. unable it. how can achieve it?
user setcontent method wich takes "remoteviews" parameter
Comments
Post a Comment