1 android
我有一个Android设备,其默认设置是关闭通知栏,因此您无法将其向下拖动.我想编写一个简单的程序,重新打开通知栏,以便您可以将其向下拖动以查看通知.如果有人能告诉我这样做的代码,我将非常感激.
首先,您必须查看Android SDK - 创建状态栏通知 页面.
NotificationManager manger = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.icon,
"Notification text that will be shown on status bar.", System
.currentTimeMillis());
// The PendingIntent will launch activity if the user selects this
// notification
PendingIntent contentIntent = PendingIntent.getActivity(context,
REQUEST_CODE, new Intent(this, MyActivity.class), 0);
notification.setLatestEventInfo(this, "Content Title", "Content text",
contentIntent);
manger.notify(NOTIFICATION_ID, notification);
Run Code Online (Sandbox Code Playgroud)
有关示例,请参阅此andvv.org页面 .
另外看看这个例子.
| 归档时间: |
|
| 查看次数: |
3581 次 |
| 最近记录: |