如何重新打开通知我点击一个机器人活动

问题描述:

我工作的一个应用程序,其中用户可以在登录活动登录。和登录的用户可以看到他们在仪表盘活动的审查。如果有任何新的评论在服务器未来它会推通知。一切都运行完美的除了一件事,即当在通知用户点击,则每次打开一个新的仪表板活动如果仪表板的活动是在前面,然后也。

I am working on a application where user can login in the login activity. And a logged in user can see their review in dashboard activity. And if any new review is coming in server it will push a notification. Everything is running perfect Except one thing i.e. when user click on the notification, it is opening a new dashboard activity every time if the dashboard activity is in front then also.

我所希望的是,应用程序没有运行,只有当如果在通知用户点击它会打开仪表盘的活动。否则,如果仪表板的活动是在前面那么如果用户点击它,它会首先关闭仪表板的活动和将重新打开活动网页。
这里是code我正在写去了仪表盘的活动。

What i am wanting is that if user click on the notification it will open dashboard activity only when application is not running. otherwise if the dashboard activity is in front then if user will click on it , it will first close the dashboard activity and the it will reopen the activity page. Here is the code i am written to go the dashboard activity.

    Intent startActivityIntent = new Intent(this, DashboardActivity.class); 
    startActivityIntent.putExtra("NotificationMessage", service_notification);
    startActivityIntent.putExtra("flag", 1);
    startActivityIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK );
    PendingIntent launchIntent = PendingIntent.getActivity(this, 0,
            startActivityIntent, PendingIntent.FLAG_UPDATE_CURRENT);

    earthquakeNotificationBuilder
                .setContentIntent(launchIntent)
                .setContentTitle(no_of_review + " " + "new review is there")
                .setAutoCancel(true);   

我已经尝试了许多事情,但没有得到解决。谁能帮我?先谢谢了。

I have tried many thing but didn't get a solution. Can anyone help me? Thanks in advance.

的android:launchMode =singleTask在AndroidManifest.xml中这样你就可以ANDD 的android:clearTaskOnLaunch =真

and the android:launchMode="singleTask" in your androidmanifest.xml so you can andd android:clearTaskOnLaunch="true

        <activity
            android:name=".DashboardActivity"
            android:launchMode="singleTask"
            android:clearTaskOnLaunch="true" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>