怎么没有android数据库的书籍,如何通知没有数据库添加在Android

它不是推送通知是通知

这里是显示通知的代码。

package org.anddev.android.statusbarnotificator;

import android.app.Activity;

import android.app.Notification;

import android.app.NotificationManager;

import android.content.Intent;

import android.net.Uri;

import android.os.Bundle;

import android.view.View;

import android.view.View.OnClickListener;

public class StatusbarNotificator extends Activity {

private NotificationManager mNotificationManager;

private int YOURAPP_NOTIFICATION_ID;

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle icicle) {

super.onCreate(icicle);

setContentView(R.layout.main);

// Get the notification manager service.

mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

/* Show a sample notification when the first button was clicked. */

findViewById(R.id.btn_showsample).setOnClickListener(new OnClickListener(){

@Override

public void onClick(View v) {

StatusbarNotificator.this.showNotification(

R.drawable.tinyandroid,

R.string.notif_short,

R.string.notif_detailed,

false);

}

});

/* Clear the notification. */

findViewById(R.id.btn_clear).setOnClickListener(new OnClickListener(){

@Override

public void onClick(View v) {

StatusbarNotificator.this.mNotificationManager.cancel(YOURAPP_NOTIFICATION_ID);

}

});

}

private void showNotification(int statusBarIconID, int statusBarTextID, int detailedTextID, boolean showIconOnly) {

// This is who should be launched if the user selects our notification.

Intent contentIntent = new Intent(this, StatusbarNotificator.class);

// This is who should be launched if the user selects the app icon in the notification.

Intent appIntent = new Intent(android.content.Intent.VIEW_ACTION,

Uri.parse("http://www.anddev.org"));

// choose the ticker text

String tickerText = showIconOnly ? null : this.getString(statusBarTextID);

mNotificationManager.notify(

YOURAPP_NOTIFICATION_ID, // we use a string id because it is a unique

// number. we use it later to cancel the

// notification

new Notification(

this, // our context

statusBarIconID, // the icon for the status bar

tickerText, // the text to display in the ticker

System.currentTimeMillis(), // the timestamp for the notification

"anddev.org - Notification", // the title for the notification

getText(detailedTextID), // the details to display in the notification

contentIntent, // the contentIntent (see above)

R.drawable.icon, // the app icon

"anddev", // the name of the app

appIntent)); // the appIntent (see above)

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值