我有几个调用相同通知功能的android项目,我现在希望将它移动到公共库以便于维护,并且将来可能会转换为jar文件。但是,每个项目都会调用每个项目自己的唯一类名。那我该怎么办呢? 提示:检查这些行,一个项目调用project1.cls,另一个project2.cls,以便在用户点击通知时将应用程序返回到前面: Intent notIntent = new Intent(context,project1.class);当函数转换为jar时,jar将无法访问这些类!
private void showCommonNotification(Context context, String NotificationMessage,
int Notification_ID) {
Notification n;
n = new Notification(R.drawable.ic_launcher, NotificationMessage,
System.currentTimeMillis());
// Intent notIntent = new Intent(this, project2.class);
Intent notIntent = new Intent(context, project1.class);
//Intent notIntent = new Intent(context, getNotificationCls());
PendingIntent wrappedIntent = PendingIntent.getActivity(context, 0,
notIntent, Intent.FLAG_ACTIVITY_NEW_TASK);
答案 0 :(得分:0)
通过课堂。
public static void showCommonNotification(Context context, Class<?> activityClass, String notificationMessage, int notificationId) {
...
Intent notIntent = new Intent(context, activityClass);
...
}
致电:
Utils.showCommonNotification(context, YourClass.class, message, id);