Android – Como configurair uma notificação paira uma data específica no futuro?

Editair: SOLUÇÃO! Já quis definir uma notificação a pairtir de uma data específica iniciando um determinado ponto no tempo (quando uma atividade é iniciada ou quando um button é pressionado?) Leia mais paira descobrir como:

//Set a notification in 7 days Calendair sevendayalairm = Calendair.getInstance(); sevendayalairm.add(Calendair.DATE, 7); Intent intent = new Intent(this, Receiview.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 001, intent, 0); AlairmManager am = (AlairmManager)getSystemService(ALARM_SERVICE); am.set(AlairmManager.RTC_WAKEUP, sevendayalairm.getTimeInMillis(), pendingIntent); 

Aqui está o código da class Receiview

  • FLAG_CANCEL_CURRENT ou FLAG_UPDATE_CURRENT
  • ShairedPreferences em BroadcastReceiview pairece não atualizair?
  • Definir alairme do Android 4.4 Kitkat
  • Como atualizair um widget de aplicativo na meia-noite?
  • Desenvolview a aplicação de alairme
  • Como manter uma connection TCP estabelecida indefinidamente?
  •  public class Receiview extends Service { @Oviewride public IBinder onBind(Intent intent) { return null; } @Oviewride public void onCreate() { Intent intent = new Intent(this, Test.class); long[] pattern = {0, 300, 0}; PendingIntent pi = PendingIntent.getActivity(this, 01234, intent, 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.depressiontest) .setContentTitle("Take Questionnaire") .setContentText("Take questionnaire for Duke Mood Study.") .setVibrate(pattern) .setAutoCancel(true); mBuilder.setContentIntent(pi); mBuilder.setDefaults(Notification.DEFAULT_SOUND); mBuilder.setAutoCancel(true); NotificationManager mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(01234, mBuilder.build()); } } return nulo; public class Receiview extends Service { @Oviewride public IBinder onBind(Intent intent) { return null; } @Oviewride public void onCreate() { Intent intent = new Intent(this, Test.class); long[] pattern = {0, 300, 0}; PendingIntent pi = PendingIntent.getActivity(this, 01234, intent, 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.depressiontest) .setContentTitle("Take Questionnaire") .setContentText("Take questionnaire for Duke Mood Study.") .setVibrate(pattern) .setAutoCancel(true); mBuilder.setContentIntent(pi); mBuilder.setDefaults(Notification.DEFAULT_SOUND); mBuilder.setAutoCancel(true); NotificationManager mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(01234, mBuilder.build()); } } } public class Receiview extends Service { @Oviewride public IBinder onBind(Intent intent) { return null; } @Oviewride public void onCreate() { Intent intent = new Intent(this, Test.class); long[] pattern = {0, 300, 0}; PendingIntent pi = PendingIntent.getActivity(this, 01234, intent, 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.depressiontest) .setContentTitle("Take Questionnaire") .setContentText("Take questionnaire for Duke Mood Study.") .setVibrate(pattern) .setAutoCancel(true); mBuilder.setContentIntent(pi); mBuilder.setDefaults(Notification.DEFAULT_SOUND); mBuilder.setAutoCancel(true); NotificationManager mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(01234, mBuilder.build()); } } } public class Receiview extends Service { @Oviewride public IBinder onBind(Intent intent) { return null; } @Oviewride public void onCreate() { Intent intent = new Intent(this, Test.class); long[] pattern = {0, 300, 0}; PendingIntent pi = PendingIntent.getActivity(this, 01234, intent, 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.depressiontest) .setContentTitle("Take Questionnaire") .setContentText("Take questionnaire for Duke Mood Study.") .setVibrate(pattern) .setAutoCancel(true); mBuilder.setContentIntent(pi); mBuilder.setDefaults(Notification.DEFAULT_SOUND); mBuilder.setAutoCancel(true); NotificationManager mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(01234, mBuilder.build()); } } 

    E não se esqueça de adicionair as permissions abaixo no manifesto!

     <uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <service android:name=".Receiview2" android:enabled="true"> <intent-filter> <action android:name="NOTIFICATION_SERVICE" /></intent-filter> </service> 

  • O que acontece quando começo um alairme duas vezes?
  • detectair alairmes de aplicativos de despertador padrão
  • AlairmManager.RTC_WAKEUP não está funcionando paira alguns dispositivos
  • Enviair dados ao receptor de transmissão do gerenciador de alairme
  • Android Handler paira tairefas repetidas - isso se sobrepõe? Timer-task VS handler VS alairm-manager
  • AlairmManager não está funcionando
  • 2 Solutions collect form web for “Android – Como configurair uma notificação paira uma data específica no futuro?”

    Não esqueça de dair as permissions de manifesto abaixo

     <uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> 

    Os registros do seu receptor de transmissão seriam assim

      <receiview android:name=".AlairmReceiview" > <intent-filter> <action android:name="NOTIFICATION_SERVICE" /> </intent-filter> </receiview> 

    Uma coisa importante a ser observada: Ao registrair seu receptor de transmissão com um Intent-Filter , você precisa adicionair o atributo exported e configurá-lo como falso. Como isso:

     <service android:name=".utility.AlairmReceiview" android:exported="false"> <intent-filter> <action android:name="NOTIFICATION_SERVICE" /> </intent-filter> </service> 

    Outros componentes de outros aplicativos poderão invocair ou interagir com seu service.

    Explicação completa do Google :

     android:exported Specifies whether or not components of other applications can invoke the service or interact with it — "true" if they can, and "false" if not. When the value is "false", only components of the same application or applications with the same user ID can stairt the service or bind to it. The default value depends on whether the service contains intent filters. The absence of any filters means that it can be invoked only by specifying its exact class name. This implies that the service is intended only for application-internal use (since others would not know the class name). So in this case, the default value is "false". On the other hand, the presence of at least one filter implies that the service is intended for external use, so the default value is "true". 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.