2011-08-31 194 views
0

好吧, 我正在使用一项服务来收集&过程GPS数据的Android应用程序。该服务还会在状态栏中创建通知。我无法弄清楚的是,当用户点击它时,如何让通知打开主类。从我在网上找到的信息来看,不应该那么难,但是我无法实现它。有没有人有什么建议在哪里看?服务通知打开主要活动

+0

你有多远? – njzk2

回答

2
Intent notificationIntent = new Intent(this, MyClass.class); 

这行代码是从http://developer.android.com/guide/topics/ui/notifiers/notifications.html

只需将MyClass替换为您的活动类 - 它将在您单击通知时启动。

+0

现在我感到很蠢。我已经在我的服务中的代码,但有一个错误:(我有GPSService.class而不是Main.class。我使用的确切代码是PendingIntent contentIntent = PendingIntent.getActivity(this,0,new Intent(this, Main.class),0); – smccloud