I am implementing notification my app just example.
Service class file:
public class Services
{
public void myNotify(Context context,String message)
{
Log.v("my notification method","from GetNotification class");
NotificationManager notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(0,"A new notification", System.currentTimeMillis());
// Hide the notification after its selected
notification.flags |= Notification.FLAG_AUTO_CANCEL;
Log.v("services","11");
//Intent intent = new Intent(android.content.Intent.ACTION_VIEW,Uri.parse(""));
Log.v("services","22");
PendingIntent activity = PendingIntent.getActivity(context,0,new Intent(android.content.Intent.ACTION_VIEW,Uri.parse("")), 0);
Log.v("services","33");
notification.setLatestEventInfo(context,"Notification for you",message,activity);
Log.v("services","44");
notification.number += 1;
Log.v("services","55");
notificationManager.notify(0, notification);
Log.v("services","66");
}
}
AppActivity main class:
public class AndroidPlatformservices extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Services str= new Services();
str.myNotify(this,"wrwtrerwetwttwretwrterwterw");
}
}
In log cat total file method executing:
06-16 22:09:11.472: VERBOSE/my notification method(5128): from GetNotification class
06-16 22:09:11.472: VERBOSE/services(5128): 11
06-16 22:09:11.472: VERBOSE/services(5128): 22
06-16 22:09:11.483: VERBOSE/services(5128): 33
06-16 22:09:11.493: VERBOSE/services(5128): 44
06-16 22:09:11.503: VERBOSE/services(5128): 55
06-16 22:09:11.513: VERBOSE/services(5128): 66
What is the problem?
You have to use a proper ressource id for the icon in the Notification constructor, 0 won't work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With