Cannot cast to app
I have run into an interesting problem where I cannot cast to the DeviceSetupActivityFragment from android.support.v4.app.Fragment.
I followed the Android Starter App tutorial so I can build my app from there. However, this error is holding up progress. Any tips on how to deal with it? I have all the same packages imported as the Starter App.
metawear.connectAsync().continueWithTask(task -> task.isCancelled() || !task.isFaulted() ? task : MainActivity.reconnect(metawear))
.continueWith((Continuation<Void, Void>) task -> {
if (!task.isCancelled()) {
runOnUiThread(() -> {
((DialogFragment) Objects.requireNonNull(getSupportFragmentManager().findFragmentByTag(RECONNECT_DIALOG_TAG))).dismiss();
//This is the offending line here
((DeviceSetupActivityFragment) getSupportFragmentManager().findFragmentById(R.id.device_setup_fragment)).reconnected();
});
} else {
finish();
}
Comments
This isn't a metawear related questions. This is a UI question.
Here the App is looking for a Fragment by ID which is some kind of UI (probably an Activity wheel or similar).
What is happening? What is the offense? This is not very helpful at all for me, I know absolutely nothing to comment further.
On the line of code:
it's underlined red and the error says: Inconvertible types; cannot cast android.support.v4.app.Fragment to com.example.packagename.DeviceSetupActivityFragment
the same imports as the Starter App are in my app
Never mind - it was Android Studio not liking the v4 import.
I ran:
File > Invalidate Caches/Restart
Once I compiled it was fine. *In case anyone else has this issue.
Thanks @jjm345 for the update.