How do I create an extension of the com.dynamo.android.DefoldActivity class? There is a need to process intents in the onCreate method.
Good question. I don’t know. I would try this:
- Create a dummy native extension. It could basically have a bunch of empty lifecycle functions and nothing more. Add to this also your own activity
- Make a copy of the default AndroidManifest.xml
- Add your own activity to the manifest and make it the main activity of the application
- Navigate from your own custom activity to the com.dynamo.android.DefoldActivity immediately in onCreate() after you’ve processed intents.
I have not tested the above myself but it is worth trying.
By the way, what are the intents you’d like to process? Perhaps extension-iac
could be used? The purpose of that extension is to capture additional invocation arguments when launching the application from a link, launcher or similar.
1 Like
Thank you for the answer. You are probably right and this is a good way to solve the problem. I should write something like this:
import com.dynamo.android.DefoldActivity;
public class CustomActivity extends AppCompatActivity{
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
// Processing intents
Intent newIntent = new Intent(this, DefoldActivity.class);
startActivity(newIntent);
finish();
}
}
There is also an import problem here:
package com.dynamo.android does not exist
import com.dynamo.android.DefoldActivity;
This is a working way. Who needs.
import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
public class CustomActivity extends AppCompatActivity{
private final String defoldActivityClassName = "com.dynamo.android.DefoldActivity";
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
// Processing intents
Class<?> gameActivityClass = null;
try {
gameActivityClass = Class.forName(defoldActivityClassName);
} catch(ClassNotFoundException ex) {
}
if (gameActivityClass != null)
{
Intent newIntent = new Intent(this, gameActivityClass);
startActivity(newIntent);
}
finish();
}
}
1 Like