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

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
A.R.Patil
  • 3
  • 1

2 Answers2

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:

Eselfar
  • 3,759
  • 3
  • 23
  • 43
0

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?