I am trying to implement app Update Manager for an immediate type. I referred to the 3rd answer of this question How to work with Android's in-app update API? but I don't think I understood how exactly the code should be used. This is how I did my coding
private AppUpdateManager appUpdateManager;
int REQUEST_APP_UPDATE;
setContentView(R.layout.activity_starternew);
appUpdateManager =AppUpdateManagerFactory.create(Starternew.this);
appUpdateManager
.getAppUpdateInfo()
.addOnSuccessListener(
appUpdateInfo -> {
if ((appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE) && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)) {
try {
appUpdateManager.startUpdateFlowForResult(
appUpdateInfo,
AppUpdateType.IMMEDIATE,
this,
REQUEST_APP_UPDATE);
} catch (IntentSender.SendIntentException e) {
e.printStackTrace();
}
}
//}
});
Below is the onresume method
@Override
protected onResume(){
super.onResume();
appUpdateManager
.getAppUpdateInfo()
.addOnSuccessListener(
appUpdateInfo ->{
if (appUpdateInfo.updateAvailability()==UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS){
try {
appUpdateManager.startUpdateFlowForResult(
appUpdateInfo,
AppUpdateType.IMMEDIATE,
this,
REQUEST_APP_UPDATE
);
}catch (IntentSender.SendIntentException e){
e.printStackTrace();
}
}
});
// )
}}
When I use the above I get error message, onresume is supposed to have a return, and method does not override method from its superclass. This is the first time I am using this api, I read the documentation but am not quite sure if my code asides from the onresume method is correct, and how do I handle the current errors in the onresume method? Or could someone please direct me to a full example in java of how to test it Please help. The on resume method comes at the very end of the code for main activity.