I've defined an android activity and it just fails to start regardless of how I try to start it. It's supposed to be launched as the main activity, but the app just hangs if I declare it as the default activity like this:
<activity
android:name=".activity.StartupActivity"
android:screenOrientation="portrait"
android:theme="@style/NoActionAppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="url"
android:pathPrefix="/prefix"
android:scheme="https" />
<data
android:host="url"
android:scheme="https" />
</intent-filter>
</activity>
I've tried putting a breakpoint at the first line of onCreate
and Log
lines in this activity, but this activity just doesn't start. I think the source code of the activity is irrelevent since it doesn't ever start. Please let me know if it's needed. I tried setting another activity as the default one and start StartupActivity
from it like this:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (! AppRuntime.b) {
AppRuntime.b = true;
startActivity(new Intent(this, StartupActivity.class));
finish();
return;
}
// other stuff
}
But the result is similar to what I see when StartupActivity
is the default activity. The breakpoints in this activity work as expected. The problem arises when the StartupActivity
is started. What's causing this problem?
Note: StartupActivity
extends AppCompatActivity
and overrides only onCreate
and onActivityResult
.
Edit: here's the activity code:
public class StartupActivity extends AppCompatActivity {
SharedPreferences sp;
String deepLink = "";
final int SIGNUP_REQUEST_CODE = 0;
final int TUTORIAL_REQUEST_CODE = 1;
@Override
public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
super.onCreate(savedInstanceState);
addressInvitation();
sp = App.getSharedPreferences();
MobileAds.initialize(this, Utils.getAdmobID());
setContentView(R.layout.activity_splash_screen);
//load the ad
// mAdView = findViewById(R.id.adView);
// AdRequest adRequest = new AdRequest.Builder().build();
// mAdView.loadAd(adRequest);
Log.d("DEBUGGING", "calling bootstrap");
bootstrapApp();
}
private void bootstrapApp() {
if (! sp.contains("signed_in")) {
sp.edit().clear().apply();
Log.d("DEBUGGING", "starting signup activity");
startActivityForResult(new Intent(this, SignUp.class), SIGNUP_REQUEST_CODE);
} else if (! sp.contains("isFirstTime")) {
Log.d("DEBUGGING", "starting tutorial");
startActivityForResult(new Intent(this, TutorialsActivity.class), TUTORIAL_REQUEST_CODE);
} else {
Log.d("DEBUGGING", "going to splash screen");
startActivity(new Intent(this, SplashScreen.class));
finish();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case SIGNUP_REQUEST_CODE:
Log.d("DEBUGGING", "signup returned");
if (resultCode == RESULT_OK) {
sp.edit()
.putBoolean("signed_in", true)
.apply();
} else {
finish();
}
break;
case TUTORIAL_REQUEST_CODE:
Log.d("DEBUGGING", "tutorial returned");
if (resultCode == RESULT_OK) {
sp.edit()
.putBoolean("isFirstTime", true)
.apply();
} else {
finish();
}
break;
}
bootstrapApp();
}
private void addressInvitation() {
FirebaseDynamicLinks.getInstance().getDynamicLink(getIntent())
.addOnSuccessListener(this, new OnSuccessListener<PendingDynamicLinkData>() {
@Override
public void onSuccess(PendingDynamicLinkData data) {
if (data == null) {
return;
}
// Get the deep link
deepLink = data.getLink().toString();
// Extract invite
FirebaseAppInvite invite = FirebaseAppInvite.getInvitation(data);
if (invite != null) {
String invitationId = invite.getInvitationId();
}
}
})
.addOnFailureListener(this, new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.e("HandleInvitaiton", "COULD NOT HANDLE");
}
});
}
}
I see the problem. You're using
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState)
instead of
protected void onCreate(@Nullable Bundle savedInstanceState)
You're overriding the wrong method.