MY_PACKAGE_REPLACED not called if the install was programmatic

175 views Asked by At

I am trying to restart my app after it installation. I made a receiver of MY_PACKAGE_REPLACED action. And i starting the app from there programatically:

Process process = Runtime.getRuntime().exec(new String[]{"su", "-c", "am start io.my.package/io.my.package.MainActivity"});

When i doing the install from the terminal with the following command everything working fine:

adb install -r /Users/ ... /app/build/outputs/apk/debug/app-debug.apk

But when i do it from the code programatically like this:

command = "pm install -r /mnt/sdcard/Download/app-debug.apk"
process = Runtime.getRuntime().exec(new String[] {"su", "-c", command});

The receiver don't get the action... What could be the problem?

1

There are 1 answers

0
Moshe Yamini On

Found the issue. The problem was not the programmatic part of the process. I guess i missed something in my tests.

The real problem is that i don't get the action when i change the version number. When i don't change the version everything works fine. Very strange.