Can somebody tell me the purpose of the following segment codes in the
method onReceive() in BluetoothPairingRequest.java
Why sometimes a pairing dialog pops up, and sometime just a
notification when the phone receives a pairing request? Thanks.
if (powerManager.isScreenOn()
&&localManager.shouldShowDialogInForeground(deviceAddress)) {
// Since the screen is on and the BT-related activity
is in the foreground,
// just open the dialog
context.startActivity(pairingIntent);
} else {
// Put up a notification that leads to the dialog
Resources res = context.getResources();
Notification notification = new Notification(
android.R.drawable.stat_sys_data_bluetooth,
res.getString(R.string.bluetooth_notif_ticker),
System.currentTimeMillis());
PendingIntent pending =
PendingIntent.getActivity(context, 0,
pairingIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
String name =
intent.getStringExtra(BluetoothDevice.EXTRA_NAME);
if (TextUtils.isEmpty(name)) {
name = device.getName();
}
notification.setLatestEventInfo(context,
res.getString(R.string.bluetooth_notif_title),
res.getString(R.string.bluetooth_notif_message) + name,
pending);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.defaults |= Notification.DEFAULT_SOUND;
NotificationManager manager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify(NOTIFICATION_ID, notification);
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en