0

Is there any specific thing we have to add in code or in manifest to support Android version 12 and 12 (Api level 31 and above).

We have implemented following code

Intent intent = new Intent(Intent.ACTION_SEND);
        intent.addCategory("android.intent.category.ESSLOGIN");
        intent.setComponent(new ComponentName("com.company.Appname", "com.company.Appname"presentation.ui.activities.LoginActivity"));
        intent.putExtra(Intent.EXTRA_TEXT, ssoDetails);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setType("text/plain");
        try {
            startActivity(intent);
        } catch (Exception e) {
            e.printStackTrace();
            intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse("playstore url"));
            try {
                startActivity(intent);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }

for Android version 12 and 13 it always go to store not launching another app

we have added all necessary things in manifest also but still not navigating to another application

In verbose it shows

android.content.ActivityNotFoundException: Unable to find explicit activity class {com.company.Appname/com.company.Appname.presentation.ui.activities.LoginActivity}; have you declared this activity in your AndroidManifest.xml, or does your intent not match its declared ?

I tried all possible solution adding queries in manifest and all other option but still its not launching for Android version 12 and 13 please help for same

2 Answers 2

1

In Manifest

<manifest> 
     <queries>
         <package android:name="package.of.app.you.wanna.open"/>
     </queries>
</manifest>

and use PackageManager and launch app you wann open.

Intent openIntent = context.getPackageManager().getLaunchIntentForPackage("package.of.app.you.wanna.open");
openIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
context.startActivity(openIntent);

From android api 30 for security reasons,they make packages invisible.So, you need to know the package you wanna open and query to accept and open it.

#crd How do I programmatically launch a specific application?

Sign up to request clarification or add additional context in comments.

Comments

0

You need to add an intent-filter into the manifest of the app you try to start.

Documenation

Source:

More on what changes in Android 12:

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.