나는 무슨 일이 생겼을 때 알람을 활성화하는 코드를 작성하려고합니다. 나는 기본 경보를 사용하고 생각할 때 화재를 생각했지만 먼저 경보를 발사하거나 처리하는 방법을 모른다. 둘째 : 소리가 나고 사용자에게 메시지를 보내는 즉각적인 경고를 발사하는 가장 쉬운 방법이 있는지 나는 모른다. 예를 들어안드로이드에서 즉시 알람을 시작하는 방법
: 메시지와 함께 가청 경보는 사용자 다른 일부 다른 코드 도와
감사를 조언 (참) 화재 경우
.
나는 무슨 일이 생겼을 때 알람을 활성화하는 코드를 작성하려고합니다. 나는 기본 경보를 사용하고 생각할 때 화재를 생각했지만 먼저 경보를 발사하거나 처리하는 방법을 모른다. 둘째 : 소리가 나고 사용자에게 메시지를 보내는 즉각적인 경고를 발사하는 가장 쉬운 방법이 있는지 나는 모른다. 예를 들어안드로이드에서 즉시 알람을 시작하는 방법
: 메시지와 함께 가청 경보는 사용자 다른 일부 다른 코드 도와
감사를 조언 (참) 화재 경우
.
코드가 실행 중이고 잘못된 시각을 사용자에게 제공하려는 경우 사운드 만 재생하고 토스트를 표시합니다. 여기 http://developer.android.com/reference/android/app/NotificationManager.html
을 수행 할 수 있습니다 : 당신이 그것으로 갈 알림을 원하는 경우 http://developer.android.com/guide/topics/media/index.html
는 다음을 살펴 : 소리를 들어 http://developer.android.com/guide/topics/ui/notifiers/toasts.html
Toast toast = Toast.makeText(context, myMessage, Toast.LENGTH_LONG).show();
: 텍스트 메시지에 대한
알림 개체를 전달하여 알림을 발생시킵니다.Notification.Builder builder = new Notification.Builder(context);
builder.setSound(Uri.fromFile(yourFile));
builder.setTicker(yourMessage);
NotificationManager.notify(1,builder.getNotification());
알람 관리기 :
public void startAlert() {
Intent intent = new Intent(this, MyBroadcastReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(
this.getApplicationContext(), 234324243, intent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()
+ (i * 1000), pendingIntent);
Toast.makeText(this, "Alarm set in " + i + " seconds",
Toast.LENGTH_LONG).show();
}
브로드 캐스트 리시버 :
이public class MyBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "Don't panik but your time is up!!!!.",
Toast.LENGTH_LONG).show();
// Vibrate the mobile phone
Vibrator vibrator = (Vibrator)
context.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(2000);
}
}
당신이 (소리) 상태 표시 줄에 알림을 의미합니까? –
감사합니다. 그게 내가 찾고 있던거야! :) 그리고 아니, 나는 그것을 상태 표시 줄에 넣고 싶지는 않지만 지금은 괜찮습니다! 감사! – Sonhja