0

Is there anything else to be done to access the Internet on Android version 12, because the program works on versions below Android 11, but it has a problem on version 12 and does not connect. The service is run by the Retrofit Library, and that part is correct because it connects to the Internet in Android version 11.

When I call the desired API, it returns HTTP Status Code=307, while it is done correctly in Android 11 and returns the response correctly, but in Android 12, it has a problem and returns HTTP Status Code=307 and does not return me any response.

The desired api uses Cookie challenge in CDN

in manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="*****">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.CAMERA"/>

<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-feature android:name="android.hardware.camera.flash" />

<application
    android:name="****.Application.Utility.AppController"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:networkSecurityConfig="@xml/network_security_config"
    android:roundIcon="@mipmap/ic_launcher"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

    <activity
        android:name=".Application.Activities.ActSplash"
        android:launchMode="singleTask"
        android:screenOrientation="unspecified"
        android:theme="@style/AppTheme"
        android:windowSoftInputMode="stateAlwaysVisible">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity
        android:name=".Application.Activities.ActLogin"
        android:launchMode="singleTask"
        android:screenOrientation="unspecified"
        android:windowSoftInputMode="stateAlwaysHidden" />
</application>

</manifest>

in network_security_config:

<?xml version="1.0" encoding="utf-8"?>
<network-security-config xmlns:tools="http://schemas.android.com/tools">
    <base-config cleartextTrafficPermitted="true">
        <trust-anchors>
            <certificates src="system" />
            <certificates src="user"
                tools:ignore="AcceptsUserCertificates" />
        </trust-anchors>
    </base-config>
</network-security-config>

Retrofit Init:

public class Retrofit {
private static OkHttpClient okHttpClient = new OkHttpClient.Builder()
        .readTimeout(60, TimeUnit.SECONDS)
        .connectTimeout(60, TimeUnit.SECONDS)
        .writeTimeout(60 , TimeUnit.SECONDS)
        .build();

public static retrofit2.Retrofit retrofit = new retrofit2.Retrofit.Builder()
        .addConverterFactory(GsonConverterFactory.create())
        .baseUrl(AppController.ConvertDigitsToLatin(Variable.BASE_URL))
        .client(okHttpClient)
        .build();
public static ISvcMethod Service = retrofit.create(ISvcMethod.class);
}

0 Answers0