بنام خدا
سلام
جدیدا که کدهای نو تیف رو میزنم میگه این کدها منسوخ شده . میشه بگین کدهای جدید چیه؟
package com.botskool.StatusBarNotification;
////نام پکیج شما
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class StatusBarNotificationActivity extends Activity {
private static final int NOTIFICATION_ID = 1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
int icon = R.drawable.icon;
CharSequence tickerText = "This is a sample notification";
long when = System.currentTimeMillis();
Context context = getApplicationContext();
CharSequence contentTitle = "Sample notification";
CharSequence contentText = "This notification has been generated as a result of button click.";
Intent notificationIntent = new Intent(this, StatusBarNotificationActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
final Notification notification = new Notification(icon, tickerText, when);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
String ns = Context.NOTIFICATION_SERVICE;
final NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
Button statusbarnotify = (Button) findViewById(R.id.statusbarbutton);
statusbarnotify.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
mNotificationManager.notify(NOTIFICATION_ID, notification);
}
});
}
}