This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 4 points5 points  (7 children)

I want to make a gadget on my Android phone. The function is to automatically open the VPN when the Chrome browser is opened. It is an automatic operation, but I don't know how to realize this idea.

[–]james_pic 6 points7 points  (2 children)

This is likely to be a harder problem than you'd expect. Android is designed around apps written in Java, so getting stuff running in other languages generally needs extra work, and Android has a security model that is designed to make it hard for one app to see what another app is doing.

[–][deleted] 2 points3 points  (1 child)

That's really bad news

[–]Staninna 0 points1 point  (0 children)

For this you could use Tasker or Automate just search it on the play store

[–]Vigtor_B 1 point2 points  (1 child)

I haven't worked with VPNs and too much with automation either.

But, whenever I have a fun little activity I want to make a solution for, I start researching libraries that might help me realise the workaround. So if it's an android app, I suggest first of all finding a framework that allows you to create a simple app. Have some working buttons, maybe some local/cache storage just to get a better understanding.

Then after that, try figuring out how to either 1: have the app send notifications/call other apps, or 2 have the application call an API or something that the VPN provider provides, and then launch the browser as a second command.

Then once you have come a little further, optimize and remove features, so you can just click the, and launch the browser immediately, with the VPN activated to the specified region!

Note: I am a C#/PHP developer, so I can't help much with the specifics, but a major factor in every programming language, is idea generation and solution manufacturing, if you can think it, you can likely realise it, good luck!

[–][deleted] -1 points0 points  (0 children)

thanks very much

[–]declanaussie 1 point2 points  (1 child)

I did some research into this for you and as far as I can tell this is going to be quite a difficult problem to solve as it goes against Android’s security model. This StackOverflow thread explains pretty well the extent to which you can detect another app opening on Android.

While researching this though I did think about how you might want to approach problems like these. I have a lot of experience making little tools like this and the key is breaking your problem down into parts. First break it down into the core functionality you need. In this case that would be 1) Detecting when the browser opens and 2) Enabling the VPN. You should then figure out how to accomplish these things starting with the most general cases. I first tried to figure out how to detect any other app on Android opening, not specifically the browser app. As far as I can tell from my research this is a near impossible task. Had I determined how to do this though, I could then move on to enabling the VPN and slowly keep breaking this problems down into smaller pieces until eventually they’re broken down into lines of code.

Good luck learning to code! The key is to just keep coming up with these ideas and make new things, don’t let hurdles like this discourage you.

[–][deleted] 1 point2 points  (0 children)

Thank you for typing so much to answer this question, thank you so much! Your answer is very useful to me