How to use firebase library without a VPN app in android - java

I made android app that uses firebase, but as the users live in Syria they should use a VPN to use my app because firebase is blocked in that country.
Is it possible to use a script or a JSON file in my app to workaround this problem?

You should try setting up your own vpn connection inside the app you're developing.
Try using this source to ease out your work.
another solution is that at runtime when your app attempts to connect with internet you can programatically reroute it's root default base connection route to your preferred IP address thus eventually solving your problem without using any external app.
Lastly,You can't try creating a service which will be installed in the backend and when the app is launched the service is automatically triggered with it and hence it will automatically route your connection to preferred vpn IP address.

Related

Host database using Android phone

Here is the current scenario:
I have two(2) Android phones.
Android Phone 1 as the server phone.
Android Phone 2 as the client phone.
Here is what I want to do:
I want to create an Android-based app (E.g. Student Information app) where it will have basically two (2) modes:
Server - for adding, editing and deleting data on a local database.
Client - for viewing data from the database of the server.
The app will be installed to Android Phone 1 and set to Server mode.
The app will be installed to Android Phone 2 and set to Client mode.
I want to ask these questions:
I want to locally host the database of the Server app, so that Client app will be able to view the data. Is this possible?
If yes, how can I do it?
Note:
I am currently a web developer so I know that connected on the same network is a requirement.
I have implemented the same concept on a medium business where the web-based system is locally hosted so that computers on the same network can access it.
Suggest everything that you want to suggest, except the disadvantage of doing this concept. I am aware of some obvious disadvantages based from my research and willing to face the disadvantages provided that I will be able to implement the concept.
Rooting the phones is an option.
I want to accommodate small-sized business that is why I want to use Android phones rather than using Desktop Computers/Laptop.
I have read similar suggested questions here based on my title.
We have done the exact same thing in my company. The way we solved this is that the server exposes a service using the Android NSD API, so the clients (using the same API) can find it on the network. And after a client has connected to the server, the server sends its database file (yes, the .db file in /data/data/...) to the client via OutputStream. When the client receives the entire database and checks for its integrity, it copies it to its own /data/data/... and restarts part of the app.
Android NSD

Android Studio frontend client [running from Device] not connecting to Google AppEngine Backend

I'm running into issues getting my frontend (being built in Android Studio using Java, running through an android device connected via USB) to connect to a locally hosted app-engine backend (running as a local devserver).
Errors are as follows:
Error when attempting to call an API method with:
'apiBld.setRootUrl("http://192.168.0.x:8080/_ah/api/");'
http://pastebin.com/eqHrSLfJ
Error when attempting to call an API method with:
'apiBld.setRootUrl("http://0.0.0.0:8080/_ah/api/");'
http://pastebin.com/s7PMqiyK
-
When its run with '192.168.0.x:8080' the emulated version of the code runs fine, the app connects locally and can call API methods. I've tried suggestions from various other related posts, but nothing has solved my issue. In pom.xml Ive also been sure to enable 0.0.0.0 for the port and we're not yet using authentication.
Any ideas?
It's strange that it connects in the emulator, as the avd network address to tunnel to your computer's loopback is 10.0.2.2.
Make sure the server is running by putting the URL in the browser. You may need to change the port to something else if it is already bound (ie: xbmc web server uses 8080 by default) try 8081. Don't forget the 'httpPort' directive in your build.gradle if using android studio.

TCP connection between Android App and PC

I'm trying to create a TCP connection between my PC and Android smartphone to send text from the PC (Client) to the Android App (Server).
I found a tutorial which helped me with the code for the App which creates the server ( http://pastebin.com/z0xPSAvP ).
Now I'm struggling connecting my client with the server. The client is programmed with "AutoIt"
http://pastebin.com/tCW5bK9V
When I run the client the "could not connect to $socket" msg-box is displayed.
Could someone tell me what I'm doing wrong here?
Both devices are in the same Network (smartphone via WiFi and PC via LAN) and I checked for the smartphones IP in the smartphone settings.
First, try to access something like Google from your Android phone using its mobile browser. Maybe something still wrong with the network.
Then create a version of the server that could deliver simple HTTP response, visible from the Android mobile browser. Doing so with success eliminates firewalls and all client-related issues from the list of possible problems, making sure the server works and is accessible.
If it still does not work after you demonstrate connection between server and mobile browser, I would suggest to write the client in Java first using the this tutorial. You can try AutoIt and other more exotic approaches after you get anything working at all.

How to implement push notifications on my android device

I have a very basic design of my entire application, where several users with my app on there android devices commits data to the server (I have used REST web services(java) + postgresql as my server) through HTTP post request from the android application. I am successful in achieving this and app runs absolutely fine. Now i want to implement a scenario where any change(CRUD operations) on my db on server should create a notification on my users android device. How should i achieve this with my server design unchanged? I have looked into Google Cloud Messaging, but could figure out the server implementation.
For now i have implemented db triggers on postgresql and able to get control back into java code using Notify/Listen feature of postgresql. From here i need to connect to android device. How can this be achieved. Is Google Cloud Messaging the only way? I have not seen any insert/update statements in there server implementation. Could anyone please guide me on this?
either you can use GCM or implement a Socket at server end and open a socket connection from mobile but this approach may add some additional processing overhead because it will create a daemon thread to listen socket port from mobile device.
You should use native library (NotificationManager etc.), here you can find a great tutorial.
My Advice is for you to use GCM. GCM normally takes a maximum of 4kb, so you could have your own defined "commands". You could use them to determine the requests on both ends, ie on android app and the server end. A php script on the server would help you in this.
I am working on an app where by the android app sends messages to the server via POST and the server forwards the message to the appropriate user via GCM. In my case I have very many things to share so in that case I am using commands, for example if it is a new incoming message I send a GCM to the app with one variable as the command and the rest as the data. On the android app I use the command variable to determine what to do with the data.
Kindly avoid that socket advice, it will have your app drain the battery to sustain the open socket , besides you don't have to re-invent the wheel while Google servers already has it

HTTP interface for Android application

Hi: I want to implement a http remote control for an Android application: From a browser on a computer in the local area network the application running on the Android device should be controlled.
Are there any recommendation how to implement this? I heard about i-jetty but it is not uncomplex to integrate it into an existing app.
The problem you're going to run into here are:
Android devices are mobile. They do not have a fixed IP address or DNS address. You'd need to implement some sort of discovery service.
Android devices move between networks, and some networks will have NAT. You won't always be able to contact the device.
My advice here would be to use the new Android C2DM service and push a command down to the device telling your application that there's a request waiting. Once the notification arrives, have your application contact a web server at a known address to see what the request actually is.
In other words, you'd be running an intermediary web server that proxies requests on behalf of your Android device.
More information about C2DM can be found here:
http://code.google.com/android/c2dm/

Categories