Scenario: I have an android app which captures images and sends over to a server. Till now I had been setting 50% quality. But with high end phones with better sensors and resolutions even with that quality images end up with a size greater than a MB.
If you apply compression of any kind with the constraint being the final file size then you will ALWAYS suffer data loss and hence quality loss. The simple act of choosing to compress the files in this way defines the final level of detail possible, so your choice in compressing in this way guarantees that higher quality images will likely be compromised more.
However, I would personally not worry about the alleged quality loss for higher MP phones. Simply having more MP does not generally produce useful detail. The optics are limited by other factors and the high MP counts are to a large extent just a marketing gimmick.
If i decrease quality lower end cameras will suffer and I can't afford to push 1 MB image.
The obvious solution is to not send it that way, but to save to a card and transfer the card's data using a card reader later, perhaps sending the final files to the mystery server over e.g. you home broadband connection which may have better speeds and costs.
So, I am looking for a way to compress image with a size limit, say 300 KB.
I don't use Android so I've no app to tell you. On a PC I'd use something like ImageMagick ( e.g. this question https://stackoverflow.com/questions/6917219/imagemagick-scale-jpeg-image-with-a-maximum-file-size ).
If you're a developer of an Android app then you need to ask how to save files to specific size constraints on the appropriate StackExchange forum.
In your case if possible save the files to your SD card and then read them to a laptop or desktop computer and batch convert them with ImageMagick. Sounds long winded but if you do it regularly then it will become quite trivial with practice.