Ver Mensaje Individual
  #3 (permalink)  
Antiguo 31/08/2011, 02:36
Avatar de atapuerkasman
atapuerkasman
 
Fecha de Ingreso: febrero-2011
Mensajes: 76
Antigüedad: 13 años, 3 meses
Puntos: 2
Respuesta: ¿Activity o service?

No cocnsigo hacer que funcione os pongo el código por si me podeis ayudar.


Código:
PendingIntent intencion=iniciaralerta();
locationmanager.addProximityAlert((double)datos.getLatitud()/1000000, (double)datos.getLongitud()/1000000, 500, -1, intencion);


Código:
public PendingIntent iniciaralerta(){
		not = Context.NOTIFICATION_SERVICE;
        notificationmanager = (NotificationManager) getSystemService(not);
        
        int icon = R.drawable.icono;
		CharSequence tickerText = "Alerta";
		long when = System.currentTimeMillis();
		
        notificacion = new Notification(icon, tickerText, when);
		//notificacion.defaults |= Notification.DEFAULT_VIBRATE;
		
		
		
		CharSequence contentTitle = "Alerta";
		CharSequence contentText = "¡Enemigo Cercano!";
		
		Intent alertacercania = new Intent(this, localizacionmanual.class);
		alertacercania.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
		
		PendingIntent intent = PendingIntent.getActivity(this, 0, 
				alertacercania, PendingIntent.FLAG_NO_CREATE);

		notificacion.setLatestEventInfo(context, contentTitle, contentText, intent);


		
        notificacion.flags |= Notification.DEFAULT_VIBRATE;

        long[] pattern = {0,100,200,300};

        
        notificacion.vibrate = pattern;
        
        notificationmanager.notify(HELLO_ID, notificacion);
		return intent;
	}