1
我试图在我的应用程序中使用NotificationCompat.Builder类。以下代码在ICS电话上运行得非常好,但不是姜饼。根据我的理解,支持库是否允许从低至API级别4的手机访问Builder?我在做一些根本性错误?NotificationCompat.Builder不工作在姜饼
public class MainActivity extends Activity implements OnClickListener {
NotificationCompat.Builder builder;
NotificationManager nm;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
builder = new NotificationCompat.Builder(this);
nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
builder.setContentTitle("Test Notification")
.setContentText("This is just a test notification")
.setTicker("you have been notified")
.setSmallIcon(R.drawable.ic_stat_example)
.setWhen(System.currentTimeMillis());
findViewById(R.id.btn_notify).setOnClickListener(this);
}
public void onClick(View arg0) {
// TODO Auto-generated method stub
if(arg0.getId() == R.id.btn_notify){
nm.notify(1, builder.build());
}
}
}
请加一些说明 –
当然!解释补充说。 –
我被困了一段时间,为什么我的通知突然停止在较旧的API中工作,事实证明我不仅需要该意图,而且还需要我在转换中丢弃的股票信息。谢谢。 – LoungeKatt