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
| class Solution: | |
| def twoSum(self, nums: List[int], target: int) -> List[int]: | |
| nums.sort() | |
| start = 0 | |
| end = len(nums) - 1 | |
| while(nums[start] + nums[end] != target): | |
| if nums[start] + nums[end] > target: | |
| end -= 1 | |
| else: |
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
| class Solution: | |
| def twoSum(self, nums: List[int], target: int) -> List[int]: | |
| for i in range(0, len(nums)-1): | |
| for j in range(i + 1, len(nums)): | |
| if nums[i] + nums[j] == target: | |
| return (i, j) | |
| return (-1, -1) |
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
| class LifeCycleCallbacksApplication: Application() { | |
| override fun onCreate() { | |
| // Add this | |
| ProcessLifecycleOwner.get().lifecycle.addObserver( AppLifeCycleListener()) | |
| super.onCreate() | |
| } | |
| } |
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
| class AppLifeCycleListener: DefaultLifecycleObserver { | |
| override fun onCreate(owner: LifecycleOwner) { | |
| Log.i("AppLifeCycleListener", "App Came to Foreground") | |
| // Add custom logic for app open here. | |
| super.onCreate(owner) | |
| } | |
| override fun onStop(owner: LifecycleOwner) { | |
| Log.i("AppLifeCycleListener", "App Went to Background") |
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
| <application | |
| ... | |
| android:name=".LifeCycleCallbacksApplication" | |
| ... | |
| </application> |
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
| class LifeCycleCallbacksApplication: Application() { | |
| override fun onCreate() { | |
| super.onCreate() | |
| } | |
| } |
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
| implementation "androidx.lifecycle:lifecycle-process:2.5.1" | |
| implementation "androidx.lifecycle:lifecycle-common:2.5.1" |
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
| <?xml version="1.0" encoding="utf-8"?> | |
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| package="com.faanghut.detectsimchange"> | |
| <!-- Add this permission in your manifiest --> | |
| <uses-permission android:name="android.permission.READ_PHONE_STATE"/> | |
| <application |
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
| class SimChangeReceivers: BroadcastReceiver() { | |
| private val TAG = "SimChangeReceivers" | |
| // This is where you'll be receiving the SIM_STATE_CHANGE intent. | |
| override fun onReceive(p0: Context?, p1: Intent?) { | |
| var state = "" | |
| if (p1 != null) { | |
| state = p1.extras?.getString("ss").toString() | |
| } | |
| Log.i(TAG, "SIM State Change Detected $state") |
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
| public class VideoFragment extends Fragment { | |
| private StyledPlayerView playerView; | |
| private ExoPlayer player; | |
| private String mediaURI; | |
| @Override | |
| public void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| mediaURI = "https://download.samplelib.com/mp4/sample-30s.mp4"; | |
| } |