2011-09-16 78 views

回答

2

謝謝,這是示例代碼通知用戶,當用戶點擊該按鈕

Button button=(Button)findViewById(R.id.button); 
button.setOnClickListener(new OnclickListener(){ 
    @Override 
    public void onClick(View v){ 

     NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 
     Notification notification = new Notification(R.drawable.image,"Notification",System.currentTimeMillis()); 
    Intent notificationIntent = new Intent(Currentclass.this,TargetActivity.class); 
    PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, 0); 
    notification.setLatestEventInfo(getApplicationContext(), "Title", "Sub Title",contentIntent); 
    notification.flags=Notification.FLAG_AUTO_CANCEL; 
    mNotificationManager.notify(143, notification); 

    } 

}); 

此代碼可以幫助你

+0

這應該有所幫助。謝謝 –

+0

非常歡迎親愛的.. –