2
A
回答
1
这是一个示例参照这一个
public class SimpleNotification extends Activity {
private NotificationManager mNotificationManager;
private int SIMPLE_NOTFICATION_ID;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mNotificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
final Notification notifyDetails = new Notification(R.drawable.android,"New Alert, Click Me!",System.currentTimeMillis());
Button start = (Button)findViewById(R.id.notifyButton);
Button cancel = (Button)findViewById(R.id.cancelButton);
start.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Context context = getApplicationContext();
CharSequence contentTitle = "Notification Details...";
CharSequence contentText = "Browse Android Official Site by clicking me";
Intent notifyIntent = new Intent(android.content.Intent.ACTION_VIEW,Uri.parse("http://www.android.com"));
PendingIntent intent =
PendingIntent.getActivity(SimpleNotification.this, 0,
notifyIntent, android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
notifyDetails.setLatestEventInfo(context, contentTitle, contentText, intent);
mNotificationManager.notify(SIMPLE_NOTFICATION_ID, notifyDetails);
}
});
cancel.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mNotificationManager.cancel(SIMPLE_NOTFICATION_ID);
}
});
}
}
相关问题
- 1. Android:从通知栏中删除通知
- 2. 从android通知栏中删除通知
- 3. Android状态栏通知
- 4. Android WebView与通知栏
- 5. Android通知栏号码
- 6. 从通知栏在Android的
- 7. 禁用android通知栏
- 8. 清除通知栏Android
- 9. Phonegap - Android - 状态栏通知
- 10. jQuery通知栏
- 11. 通知栏
- 12. Android状态栏通知 - 通过任何方式通知状态栏(烤面包)通过状态栏?
- 13. 如何禁用Android通知栏上的短信通知图标?
- 14. Android的 - 保持通知持稳在通知栏
- 15. Android如何在通知栏上撰写通知
- 16. Android的亮度变化通知(或状态栏汇总通知)
- 17. 通知文本在Android的通知栏中不可见?
- 18. GCM通知不会显示在通知栏中。 Android
- 19. 的Android无法隐藏通知栏
- 20. Android - 增量状态栏通知图标
- 21. 开始下载通知栏点击android
- 22. 通知栏上的Android服务
- 23. Phonegap状态栏通知,Android,iOS
- 24. 隐藏实体中的android通知栏
- 25. PhoneGap的Android状态栏通知例如
- 26. Android - 规划用户栏通知
- 27. Android:静态状态栏通知
- 28. Android:将通知栏设置为谷歌+
- 29. 每天更改android状态栏通知
- 30. Android状态栏multiline通知API 14