Open chatgpt app

i am tring to open chatgpt app using ActivityStarter or using any another extensions but it is not work, anyone have any idea how to do that?

What did you try? See also http://ai2.appinventor.mit.edu/reference/other/activitystarter.html

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

This extension has Launch app method that opens an app with specified package name:

i already trieded it and it is not work for me, in android 14
i am using .LaunchApp set packageName com.openai.chatgpt

i trieded to create my own extension to do that but is not work too

my extension
ActivityLauncher.aix (5.9 KB)

public class ActivityLauncher extends AndroidNonvisibleComponent {

    private Context context;
    private Activity activity;

    public ActivityLauncher(ComponentContainer container) {
        super(container.$form());
        this.activity = container.$context();
        this.context = container.$context();
    }

    @SimpleFunction(description = "open chatgpt application")
    public void openChatGPTApp() {
        try {
            String packageName = "com.openai.chatgpt"; // Package name for ChatGPT app
            startNewActivity(packageName); // Call startNewActivity with the package name
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void startNewActivity(String packageName) {
        // Get the launch intent for the given package
        Intent intent = context.getPackageManager().getLaunchIntentForPackage(packageName);

        // Fix for Android 13 and above (Tiramisu)
        if (Build.VERSION.SDK_INT < 33) {
            intent.addCategory(Intent.CATEGORY_LAUNCHER);
        }

        if (intent == null) {
            // If the app is not installed, open the Play Store page for that app
            intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse("market://details?id=" + packageName));
        }

        // Add flag to start the activity in a new task
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        try {
            context.startActivity(intent);
        } catch (Exception e) {
            e.printStackTrace();
            // If there is an error starting the activity, show a message to the user (optional)
        }
    }
}

You may need to declare the activity exported=true in Android Manifest.xml to work it in Android 14

<activity
    android:name="YourActivityName"
    android:exported="true">  
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>