I'm having requirement where i need to open the class which doesn't extends the activity/class itself is not activity on click of the notification. The code which i have written for the notification forming and also for after clicking on notification.
public class Services {
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public void myNotify(Context context) {
Notification notify = null;
NotificationManager notif = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification.Builder builder = new Notification.Builder(getContext());
// Large icon appears on the left of the notification
builder.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher));
builder.setTicker("this is ticker text");
builder.setContentTitle("REX Alert Notification");
builder.setContentText("You have a new message");
//adding LED lights to notification
builder.setDefaults(Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND | Notification.FLAG_SHOW_LIGHTS);
builder.setLights(0xff00ff00, 300, 100);
// Hide the notification after its selected
builder.setAutoCancel(true);
builder.setOngoing(true);
builder.build();
Intent notificationIntent = new Intent(context, AlertView.class);
PendingIntent pending = PendingIntent.getActivity(getContext(), 0, notificationIntent, 0);
builder.setContentIntent(pending);
notify = builder.getNotification();
notif.notify(0, notify);
}
}
Since the class which im passing as the parameter to pendingintent is not a class, so it is not opening. Could you please let me know how to achieve this.
Adding the alertview class:
public static class GenericCallable implements Callable<List<IData>> {
private final BaseListView view;
public GenericCallable(final BaseListView view) {
this.view = view;
}
@Override
public List<IData> call() throws Exception {
final IData mData =view.getHeaderData();
return view.getDataSource().getAll(mData, view.getMaxLength());
}
}
@Override
public MAUIConfigurationView getSortPopupViewConfig() {
return ConfigurationManager.getInstance().getView("AlertListSort");
}
@Override
public IDataSource<IData> getDataSourceCallable() {
return new ArrayDataSource<IData>(new GenericCallable(this));
}
@Override
public int getIntentCode(IData data) {
return 0xff33;
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
invalidateList();
}
}