Welcome! Log In Create A New Profile

Advanced

WM23 - Android generation error - use of deprecated API

Posted by ArieM 
WM23 - Android generation error - use of deprecated API
July 04, 2019 10:43PM
HI,

I'm trying to use a piece of jave code in my Android app.
But it gives me a compilation error on "List<ResolveInfo>"


This happens after including the following import
import android.util.List;

Can't get rid of it, can someone shine a light?
BTW I want to start an APK file (updating my own app) which my app downloads from one of my servers instead of the Appstore. It worked for a long time, but not on Android 8 Oreo anymore.

Failure creating the Android application named <C:\Dev\Allinq\Src\Wm\Fbox\Exe\F-Box\FBox.apk>.


Command Line: "C:\Program Files\Java\jdk1.8.0_131\bin\java.exe" "-Dorg.gradle.appname=C:\Dev\Allinq\Src\Wm\Fbox\Android\Gen" -classpath "C:\WINDEV Mobile 23\Personal\Android\Gradle\lib\gradle-launcher-2.14.1.jar" org.gradle.launcher.GradleMain assembleRelease -b "C:\Dev\Allinq\Src\Wm\Fbox\Android\Gen\build.gradle"


Error returned:

:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
C:\Dev\Allinq\Src\Wm\Fbox\Android\Gen\src\nl\ariezona\fbox\wdgen\GWDCPGLB_Android.java:94: error: cannot find symbol
import android.util.List;
                   ^
  symbol:   class List
  location: package android.util
C:\Dev\Allinq\Src\Wm\Fbox\Android\Gen\src\nl\ariezona\fbox\wdgen\GWDCPGLB_Android.java:168: error: cannot find symbol
		List<ResolveInfo> resInfoList = context.getPackageManager().queryIntentActivities(downloadIntent, PackageManager.MATCH_DEFAULT_ONLY);
		^
  symbol:   class List
  location: class GWDCPGLB_Android
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors
:compileReleaseJavaWithJavac FAILED

This is my code
import java.io.File;
import android.util.List;
import android.content.Intent;
import android.net.Uri;
import android.content.Context;
import android.os.Build;
import android.support.v4.content.FileProvider;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;

public static void Installer(String sCheminAPK){

	Intent downloadIntent;
	Context context = getApplicationContext();
	File fileLocation = new File(context.getExternalFilesDir(null), sCheminAPK);
	Intent i = new Intent();

	if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
		Uri apkUri = FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".fileProvider", fileLocation);
		downloadIntent = new Intent(Intent.ACTION_VIEW);
		downloadIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
		downloadIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		downloadIntent.setDataAndType(apkUri, "application/vnd.android.package-archive");
		List<ResolveInfo> resInfoList = context.getPackageManager().queryIntentActivities(downloadIntent, PackageManager.MATCH_DEFAULT_ONLY);
		for (ResolveInfo resolveInfo : resInfoList) {
			String packageName = resolveInfo.activityInfo.packageName;
			context.grantUriPermission(packageName, apkUri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
		}
	} else  {
		i.setAction(android.content.Intent.ACTION_VIEW);
		i.setDataAndType(Uri.fromFile(new File(sCheminAPK)), "application/vnd.android.package-archive");
		i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
	}
	getActiviteEnCours().startActivity(i); 
}

Arie



Edited 1 time(s). Last edit at 07/04/2019 10:45PM by ArieM.
Re: WM23 - Android generation error - use of deprecated API
July 12, 2019 12:25PM
Hi. Are you sure it's "import android.util.List;"?

I think the right thing to do is "import java.util.List;"

Greetings

Ruben
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: