Fix content intent of stopwatch notification to scroll to stopwatch page when clicked

This commit is contained in:
Phillip Hsu 2016-09-28 18:44:41 -07:00
parent 2a0ace162a
commit 2f82316b48

View File

@ -15,6 +15,7 @@ import com.philliphsu.clock2.R;
import com.philliphsu.clock2.chronometer.ChronometerDelegate; import com.philliphsu.clock2.chronometer.ChronometerDelegate;
import com.philliphsu.clock2.stopwatch.data.AsyncLapsTableUpdateHandler; import com.philliphsu.clock2.stopwatch.data.AsyncLapsTableUpdateHandler;
import com.philliphsu.clock2.stopwatch.ui.StopwatchFragment; import com.philliphsu.clock2.stopwatch.ui.StopwatchFragment;
import com.philliphsu.clock2.util.ContentIntentUtils;
public class StopwatchNotificationService extends ChronometerNotificationService { public class StopwatchNotificationService extends ChronometerNotificationService {
private static final String TAG = "StopwatchNotifService"; private static final String TAG = "StopwatchNotifService";
@ -82,13 +83,7 @@ public class StopwatchNotificationService extends ChronometerNotificationService
@Nullable @Nullable
@Override @Override
protected PendingIntent getContentIntent() { protected PendingIntent getContentIntent() {
Intent intent = new Intent(this, MainActivity.class); return ContentIntentUtils.create(this, MainActivity.PAGE_STOPWATCH, -1);
// http://stackoverflow.com/a/3128418/5055032
// "For some unspecified reason, extras will be delivered only if you've set some action"
// This ONLY applies to PendingIntents...
intent.setAction("foo"/*dummy action*/);
intent.putExtra(MainActivity.EXTRA_SHOW_PAGE, MainActivity.PAGE_STOPWATCH);
return PendingIntent.getActivity(this, 0, intent, 0);
} }
@Override @Override