|
@@ -27,6 +27,7 @@ import android.content.Context;
|
27
|
27
|
import android.content.Intent;
|
28
|
28
|
import android.database.Cursor;
|
29
|
29
|
import android.net.Uri;
|
|
30
|
+import android.os.Bundle;
|
30
|
31
|
|
31
|
32
|
/**
|
32
|
33
|
* Receives broadcast intents from Locale and the Context Analyser.
|
|
@@ -37,15 +38,29 @@ public class Receiver extends BroadcastReceiver {
|
37
|
38
|
|
38
|
39
|
@Override
|
39
|
40
|
public void onReceive(Context context, Intent intent) {
|
40
|
|
- final Cursor cursor = context.getContentResolver().query(
|
41
|
|
- Uri.parse("content://uk.co.md87.android.contextanalyser."
|
42
|
|
- + "activitiescontentprovider/current"),
|
43
|
|
- new String[] { "activity" }, null, null, null);
|
44
|
|
-
|
45
|
|
- if (cursor.moveToFirst()) {
|
46
|
|
- cursor.getString(cursor.getColumnIndex("activity"));
|
47
|
|
- } else {
|
48
|
|
- setResultCode(com.twofortyfouram.Intent.RESULT_CONDITION_UNKNOWN);
|
|
41
|
+ if (com.twofortyfouram.Intent.ACTION_QUERY_CONDITION.equals(intent.getAction())) {
|
|
42
|
+ final Bundle bundle = intent.getBundleExtra(com.twofortyfouram.Intent.EXTRA_BUNDLE);
|
|
43
|
+
|
|
44
|
+ if (bundle == null || !bundle.containsKey("activity")) {
|
|
45
|
+ return;
|
|
46
|
+ }
|
|
47
|
+
|
|
48
|
+ final Cursor cursor = context.getContentResolver().query(
|
|
49
|
+ Uri.parse("content://uk.co.md87.android.contextanalyser."
|
|
50
|
+ + "activitiescontentprovider/current"),
|
|
51
|
+ new String[] { "activity" }, null, null, null);
|
|
52
|
+
|
|
53
|
+ if (cursor.moveToFirst()) {
|
|
54
|
+ final String activity = cursor.getString(cursor.getColumnIndex("activity"));
|
|
55
|
+
|
|
56
|
+ if (activity.equals(bundle.getString("activity"))) {
|
|
57
|
+ setResultCode(com.twofortyfouram.Intent.RESULT_CONDITION_SATISFIED);
|
|
58
|
+ } else {
|
|
59
|
+ setResultCode(com.twofortyfouram.Intent.RESULT_CONDITION_UNSATISFIED);
|
|
60
|
+ }
|
|
61
|
+ } else {
|
|
62
|
+ setResultCode(com.twofortyfouram.Intent.RESULT_CONDITION_UNKNOWN);
|
|
63
|
+ }
|
49
|
64
|
}
|
50
|
65
|
}
|
51
|
66
|
|