Code example for Intent

Methods: getBroadcastsetClass

0
        "android.bluetooth.intent.DISCOVERABLE_TIMEOUT"; 
 
    static void setDiscoverableAlarm(Context context, long alarmTime) {
        Log.d(TAG, "setDiscoverableAlarm(): alarmTime = " + alarmTime);
 
        Intent intent = new Intent(INTENT_DISCOVERABLE_TIMEOUT);
        intent.setClass(context, BluetoothDiscoverableTimeoutReceiver.class);
        PendingIntent pending = PendingIntent.getBroadcast(
            context, 0, intent, 0);
        AlarmManager alarmManager =
              (AlarmManager) context.getSystemService (Context.ALARM_SERVICE);
 
        if (pending != null) {
            // Cancel any previous alarms that do the same thing. 
            alarmManager.cancel(pending);
            Log.d(TAG, "setDiscoverableAlarm(): cancel prev alarm");
        } 
        pending = PendingIntent.getBroadcast(
            context, 0, intent, 0);
 
        alarmManager.set(AlarmManager.RTC_WAKEUP, alarmTime, pending);
    }