-
-
Save rafaeltoledo/991ec5327b0aa82e8750be7deb8d5081 to your computer and use it in GitHub Desktop.
Android 21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> | |
<ListPreference | |
android:key="listagem" | |
android:title="Modo de Listagem" | |
android:summary="Escolha o modo de listagem a ser utilizado" | |
android:entries="@array/nomes_ordenacao" | |
android:entryValues="@array/opcoes_ordenacao" | |
android:dialogTitle="Escolha o modo de listagem" /> | |
<CheckBoxPreference | |
android:key="alarme" | |
android:title="Tocar Alarme no Almoço" | |
android:summary="Marque se deseja ser informado sobre a hora do almoço" /> | |
<net.rafaeltoledo.restaurante.PreferenciaHorario | |
android:key="horario_alarme" | |
android:title="Horário do Alarme do Almoço" | |
android:defaultValue="12:00" | |
android:summary="Configure seu horário desejado para o alarme" | |
android:dependency="alarme" /> | |
<CheckBoxPreference | |
android:key="usar_notificacao" | |
android:title="Ativar Notifocação" | |
android:defaultValue="true" | |
android:summary="Marque caso deseje um ícone na barra de status, ou desmarque para a notificação em tela cheia" | |
android:dependency="alarme" /> | |
</PreferenceScreen> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onReceive(Context context, Intent intent) { | |
SharedPreferences preferencias = PreferenceManager.getDefaultSharedPreferences(context); | |
boolean usarNotificacao = preferencias.getBoolean("usar_notificacao", true); | |
if (usarNotificacao) { | |
NotificationManager gerenciador = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); | |
Notification nota = new Notification(R.drawable.notificacao, "Hora do Almoço!", System.currentTimeMillis()); | |
PendingIntent i = PendingIntent.getActivity(context, 0, new Intent(context, AlarmeActivity.class), 0); | |
nota.setLatestEventInfo(context, "Lista de Restaurantes", "Hora do Almoço! Está com fome?", i); | |
nota.flags |= Notification.FLAG_AUTO_CANCEL; | |
gerenciador.notify(ID_NOTIFICACAO, nota); | |
} else { | |
Intent i = new Intent(context, AlarmeActivity.class); | |
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |
context.startActivity(i); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment