This is error 1:
error: cannot find symbol method
setLatestEventInfo(MySimpleNotification,CharSequence,
CharSequence,PendingIntent)
Part of the code of that error
public class MySimpleNotification extends Activity{
DatabaseConnection connection;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
//setContentView(R.layout.my_simple_notification);
connection=new DatabaseConnection(this);
int notifID = getIntent().getExtras().getInt("NotifID");
//int res=(int)connection.saveToTransaction(notifID);
//---PendingIntent to launch activity if the user selects
// the notification---
Intent i = new Intent(MySimpleNotification.this,TransactionNotification.class);
i.putExtra("NotifID", notifID);
//i.putExtra("rowID", res);
PendingIntent detailsIntent =
PendingIntent.getActivity(MySimpleNotification.this, 0, i, 0);
NotificationManager nm = (NotificationManager)
getSystemService(NOTIFICATION_SERVICE);
Notification notif = new Notification(
R.drawable.icon,
"New Transaction",
System.currentTimeMillis());
CharSequence from = "Daily expense :: Transaction";
CharSequence message = "New Transaction is saved";
***AQUÍ ME MARCA EL ERROR--> notif.setLatestEventInfo(this, from, message,
detailsIntent);
//---100ms delay, vibrate for 250ms, pause for 100 ms and
// then vibrate for 500ms---
notif.vibrate = new long[] { 100, 250, 100, 500};
nm.notify(notifID, notif);
finish();
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
}
Error 2:
error: cannot find symbol method
setLatestEventInfo(Context,String,String,PendingIntent)
Bit of second error code
public class NotifyService extends Service{
final static String ACTION = "NotifyServiceAction";
final static String STOP_SERVICE = "";
final static int RQS_STOP_SERVICE = 1;
static int count=0;
NotifyServiceReceiver notifyServiceReceiver;
private static final int MY_NOTIFICATION_ID=1;
private NotificationManager notificationManager;
private Notification myNotification;
@Override
public void onCreate() {
// TODO Auto-generated method stub
//notifyServiceReceiver = new NotifyServiceReceiver();
super.onCreate();
}
@SuppressWarnings("deprecation")
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// TODO Auto-generated method stub
//IntentFilter intentFilter = new IntentFilter();
//intentFilter.addAction(ACTION);
//registerReceiver(notifyServiceReceiver, intentFilter);
// Send Notification
notificationManager =
(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
myNotification = new Notification(R.drawable.icon,
"Notification!",
System.currentTimeMillis());
Context context = getApplicationContext();
String notificationTitle = "New Transaction";
String notificationText = "new transaction occurs";
Intent myIntent = new Intent(this, MySimpleNotification.class);
PendingIntent pendingIntent
= PendingIntent.getActivity(getBaseContext(),
0, myIntent,PendingIntent.FLAG_CANCEL_CURRENT);
myNotification.defaults |= Notification.DEFAULT_SOUND;
myNotification.flags |= Notification.FLAG_AUTO_CANCEL;
AQUÍ ME MARCA EL ERROR->myNotification.setLatestEventInfo(context,
notificationTitle,
notificationText,
pendingIntent);
//myNotification.number++;
notificationManager.notify((int)System.currentTimeMillis(),
myNotification);
return super.onStartCommand(intent, flags, startId);
}
@Override
public void onDestroy() {
// TODO Auto-generated method stub
this.unregisterReceiver(notifyServiceReceiver);
super.onDestroy();
}
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
public class NotifyServiceReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context arg0, Intent arg1) {
// TODO Auto-generated method stub
int rqs = arg1.getIntExtra("RQS", 0);
if (rqs == RQS_STOP_SERVICE){
stopSelf();
}
}
}