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 io.mercury.example | |
import android.os.Bundle | |
import androidx.activity.ComponentActivity | |
import androidx.activity.compose.setContent | |
import androidx.activity.viewModels | |
import androidx.compose.material3.Surface | |
import androidx.compose.material3.Text | |
import androidx.lifecycle.ViewModel | |
import androidx.lifecycle.viewModelScope |
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 io.mercury.android.coroutines.lifecycle | |
import androidx.compose.runtime.Composable | |
import androidx.compose.runtime.DisposableEffect | |
import androidx.compose.runtime.rememberCoroutineScope | |
import androidx.compose.ui.platform.LocalLifecycleOwner | |
import androidx.lifecycle.Lifecycle | |
import androidx.lifecycle.Lifecycle.Event.ON_CREATE | |
import androidx.lifecycle.Lifecycle.Event.ON_DESTROY | |
import androidx.lifecycle.Lifecycle.Event.ON_PAUSE |
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
public class SmsBroadcastReceiver extends BroadcastReceiver { | |
... | |
@Override | |
public void onReceive(Context context, Intent intent) { | |
final Bundle bundle = intent.getExtras(); | |
if (bundle != null) { | |
final Object[] pdusObj = (Object[]) bundle.get("pdus"); |
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
public class SmsBroadcastReceiver extends BroadcastReceiver { | |
private final OnVerificationCodeReceivedListener codeReceivedListener; | |
public SmsBroadcastReceiver(@NonNull OnVerificationCodeReceivedListener codeReceivedListener) { | |
this.codeReceivedListener = codeReceivedListener; | |
} | |
@Override | |
public void onReceive(Context context, Intent intent) { | |
// TODO: See if this message is coming from the expected phone number |
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
public class LaunchActivity extends AppCompatActivity { | |
private static final int REQUEST_CODE_READ_SMS = 101;private static final int REQUEST_CODE_READ_SMS = 101; | |
... | |
} |
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
public class LaunchActivity extends AppCompatActivity { | |
... | |
@Override | |
public void onRequestPermissionsResult(int requestCode, | |
@NonNull String permissions[], | |
@NonNull int[] grantResults) { | |
switch (requestCode) { | |
case REQUEST_CODE_READ_SMS: { |
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
public class LaunchActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
... | |
findViewById(R.id.next_btn).setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
ActivityCompat.requestPermissions(LaunchActivity.this, |
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
public class MovieDetailActivity extends AppCompatActivity { | |
private static final String EXTRA_MOVIE_ID = "extra:movieId"; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_movie_detail); | |
String movieId = savedInstanceState.getString(EXTRA_MOVIE_ID); |
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
public class NullObject { | |
private static class NullInvocationHandler implements InvocationHandler { | |
@Override | |
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { | |
Class<?> returnType = method.getReturnType(); | |
if (returnType == Byte.TYPE || returnType == Short.TYPE || returnType == Integer.TYPE || | |
returnType == Long.TYPE || returnType == Float.TYPE || returnType == Double.TYPE || | |
returnType == Character.TYPE) { |
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
public class MovieDetailActivity extends AppCompatActivity { | |
private static final String EXTRA_INSTANCE_STATE = "extra:instanceState"; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_movie_detail); | |
InstanceState is = InstanceState.from(getIntent().getExtras()); |
NewerOlder