Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
TEACHING-MATERIALS/Week_09_Services_and_wearables/MyWearables copy/app/src/main/java/com/example/jianhuayang/mywearables/CountingReceiver.java
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
29 lines (23 sloc)
913 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.jianhuayang.mywearables; | |
import android.content.BroadcastReceiver; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.util.Log; | |
/** | |
* Created by jianhuayang on 25/11/2016. | |
*/ | |
public class CountingReceiver extends BroadcastReceiver { | |
public CountingReceiver() { | |
} | |
@Override | |
public void onReceive(Context context, Intent intent) { | |
Log.d(MainActivity.DEBUG_KEY, "on receive"); | |
String timeElapsed = intent.getStringExtra(CountingService.REPORT_KEY); | |
Log.d(MainActivity.DEBUG_KEY, "time elapsed: " + timeElapsed); | |
Intent intentNew = new Intent(context, DisplayActivity.class); | |
intentNew.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |
intentNew.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); | |
intentNew.putExtra(CountingService.REPORT_KEY, timeElapsed); | |
context.startActivity(intentNew); | |
} | |
} |