Created
June 9, 2020 18:56
-
-
Save Younes-Charfaoui/cb17285338dcfbb2e1111d459769dce4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // creating the pending intent | |
| val intent = Intent(DetectedActivityReceiver.RECEIVER_ACTION) | |
| pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0) | |
| // creating the receiver | |
| receiver = DetectedActivityReceiver() | |
| // registring the receiver | |
| LocalBroadcastManager.getInstance(this).registerReceiver( | |
| receiver, IntentFilter(DetectedActivityReceiverRECEIVER_ACTION) | |
| ) | |
| val task = ActivityRecognition.getClient(this) | |
| .requestActivityTransitionUpdates(finalRequest, pendingIntent) | |
| task.addOnSuccessListener { | |
| Log.d("ActivityRecognition", "Transitions Api registered with success") | |
| } | |
| task.addOnFailureListener { e: Exception -> | |
| Log.d("ActivityRecognition", "Transitions Api could NOT be registered ${e.localizedMessage}") | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment