I fail to find out how to getAssets in a service.
for example the receiver:
public class BroadcastReceiverOnBootComplete extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equalsIgnoreCase(Intent.ACTION_BOOT_COMPLETED)) {
Intent serviceIntent = new Intent(context, AndroidServiceStartOnBoot.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
context.startForegroundService(serviceIntent);
} else {
context.startService(serviceIntent);
}
}
}
}
In the AndroidServiceStartOnBoot class, how to get getContext().getAssets().open("server.crt"); ?
Thanks a lot.
Edited:
The question is not how to call getAssets in BroadcastReceiverOnBootComplete class, instead, the question is how to getAssets in the service AndroidServiceStartOnBoot class.
The reason why I posted BroadcastReceiverOnBootComplete class is because that is how I call AndroidServiceStartOnBoot class. Sorry that it's kinda misleading. Thanks.
