Firebase Showing An Internal Error has occured. [7:] - java

I'm using Firebase as my cloud data in my android app. I'm using it's Firestore and Authentication feature. But when I try to signup it is showing me :
"An internal error has occurred. [7:]"
So, to solve this I came to search for the solution so I found that if I update the google_service.json file everything is going to be right. But When I updated it sometimes it is working and after some time it again shows me the same error.

I get this error while testing my app behavior when deliberately disabling my mobile internet connection and trying to login to my app using firebase Auth.
Try testing your network connectivity on Activity launch and display a toast
public static boolean getConnectivityStatus(Context context) {
ConnectivityManager cm = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
if (null != activeNetwork) {
if (activeNetwork.getType() == ConnectivityManager.TYPE_WIFI)
return true;
if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE)
return true;
}
Toast.makeText(context, "No network connection!", Toast.LENGTH_SHORT).show();
return false;
}

I had same problem with authentication via Firebase in my RN iOS project. After some research I found out that "Email/Password" Sign In/Up option was disabled. So I just turned it on. Hope it will help someone with similar issue.
https://i.stack.imgur.com/zoQ6g.png

Please check the internet connection of your device. I make the same mistake after internet connection enables it working.

Same error happened while I tried with network connection off and firebase authentication with email and password. for example,
FirebaseAuth.getInstance().signInWithEmailAndPassword(email, password)... { ... }
If network connection is on, then it works fine.

make sure you run your emulator like this in vs Code
flutter emulators --launch Nexus_6_API_29 -dns-8.8.8.8
this will solve your problem

Related

How to back second activity to first activity if no internet connection/wifi/mobile data (JAVA_CODE)

I am beginner android developer... Recently I develop an apps. But I want If user device connected with wifi/mobile network and user open my apps automatically FirstActivity go to SecondActivity. In SecondActivity user can read a pdfBook/html/txt file. But when user Reading Pdfbook/html/txt file in SecondActivity and at the same time wifi/mobile network DISCONNECTED then SecondActivity automatically should come_back to FirstActivity. I try many way, but I fail to do that.... there is no resource in GoogleSearch for this problem. Please anybody help me.
public boolean isNetworkConnected(Context context) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
return cm.getActiveNetworkInfo() != null && cm.getActiveNetworkInfo().isConnected();
}
this is the function that will return true if the network is connected
and return false if the network is not connected
if this function return true you go to next activty
if return false then what you want can do

How can I save data when offline in my Android app?

I'm creating an app for Android in Java. I can send info to a webservice but when i'm offline i want to store the info and when the phone gets connected to the internet i want to send it to the webservice.
Can anyone help me?
Thanks
Store your data in SQLite data-base. You can read here.
Check in BroadcastReceiver if connectivity changed and update online DB and delete the content from Sqlite DB.
public void onReceive(Context context, Intent intent) {
String s = intent.getAction();
if (s.equals("android.net.conn.CONNECTIVITY_CHANGE")) {
if (IsNetworkAvailable(context)) {
// update your online data-base and delete all rows from SQlite
}
return;
}
}
Method isNetworkAvailable:
public static boolean isNetworkAvailable(Context mContext) {
Context context = mContext.getApplicationContext();
ConnectivityManager connectivity = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity == null) {
return false;
} else {
NetworkInfo[] info = connectivity.getAllNetworkInfo();
if (info != null) {
for (int i = 0; i < info.length; i++) {
if (info[i].getState() == NetworkInfo.State.CONNECTED){
return true;
}
}
}
}
return false;
}
You also need permissions:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Offline storage and sync seem simple at first sight but you need to be careful and consider the following:
First get familiar with the storage options available in the platform and chose the most convenient for your app scenario.
Second, design your sync mechanism in an efficient way so your app won't drain the battery life.
This is a good resource to check the entire structure of an android app that cares about working offline and properly sync with the server as network becomes available.
Save your info to a SQLite database and use a BroadcastReceiver to listen when network connection is available. When connection is available, start a Service that sends the saved data to your webservice.
In the event, where you upload your data, check if Internet connection is available or not, if not, store the data as textfile or object and name it like needToUpload1, 2, 3.
Then, whenever the device is online, check if the there is any file named like that. If so, upload it via service and delete the file.
That's just my opinion how i'll do it but really depends on data.
You can find how to do every step on this site so i hope it will help.

Failed to load map with markers in android 5.1.1

I have developed an android application with a map displaying markers on it with some information (requires android 4.0.3 and up).
Before releasing it I tested my app in most of the android OSs from 4.0.3 to 5 and I didn't face any issues.Today I tried to install my released app (from play store) in a tablet device with NEXUS 7 google and android verion 5.1.1. The app does not load my map at all message displayed "Application Stopped".
I tried an older private version of my app (in debug mode) in NEXUS 7 tablet and it was success with the only difference that I do not display toast messages. Toast message indicates if connection is available or not in user's device. This message is displayed on user's screen when map is loaded in order to inform user if connected or not to the internet. Please find below the code:
ConnectivityManager conMan = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
//mobile
NetworkInfo.State mobile = conMan.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState();
//wifi
NetworkInfo.State wifi = conMan.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState();
if (mobile == NetworkInfo.State.CONNECTED || wifi == NetworkInfo.State.CONNECTED)
{
Toast.makeText(getApplicationContext(),"Connection available",Toast.LENGTH_LONG).show();
}
else
{
Toast.makeText(getApplicationContext(),"Connection not available",Toast.LENGTH_LONG).show();
}
Is the problem I had really related to the toast? Is the NEXUS 7 device blocking any try of connectivity manager to read the state of wi-fi or 3G from the device? So is the problem related to the security configuration applied on the device? Could you please help me to resolve this?
UPDATE CODE:
ConnectivityManager conMan = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
if (conMan != null) {
//mobile
NetworkInfo.State mobile = conMan.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState();
//wifi
NetworkInfo.State wifi = conMan.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState();
if (mobile == NetworkInfo.State.CONNECTED || wifi == NetworkInfo.State.CONNECTED)
{
Toast.makeText(getApplicationContext(),"Connection available",Toast.LENGTH_LONG).show();
}
else
{
Toast.makeText(getApplicationContext(),"Connection not available",Toast.LENGTH_LONG).show();
}
} // end if
else
{ //do nothing
}
Add null checks for conMan.getNetworkInfo(ConnectivityManager.TYPE_MOBILE) and conMan.getNetworkInfo(ConnectivityManager.TYPE_WIFI), getNetworkInfo return null if connection type is not supported by the device.
From API Doc
a NetworkInfo object for the requested network type or null if the type is not supported by the device.
What I am guessing is Nexus 7 doesn't support sim card due to that it can throw NullPointerException.

Wifi Available , Connected And Required User Authentication

I am working on an application where I need detect if wifi avilable and connected also authenticated in my android device .
I know how to detect this this using ConnectivityManager and NetworkInfo.It working fine but problem facing where wifi available and connected when we type URL for any site it goes 1st on another proxy site for user name and password to access the internet.I search around to detail my question and got a site of GSM provider http://www.du.ae/en/mobile/wifi-1 ,they are providing Wifi also,When I am in train it showing available network (Wifi) ,When i type any site it 1st it ask me user name and password for Authentication to access the internet. can I detect using code that user is connected and authenticated with Wifi ?
Waiting for appreciable answer to solve my this issue .
Thanks . .
NetworkInfo info = ((ConnectivityManager) mContext
.getSystemService(Context.CONNECTIVITY_SERVICE))
.getActiveNetworkInfo();
if (info == null || !info.isConnected()) {
return false;
}
if (info.isRoaming()) {
return true;
}
sem to wifi used
ANDROID: if WiFi is enabled AND active, launch an intent

Is there an Intent to detect network usage regardless of it being 3G or Wifi?

I've been looking into this for a while and have been unable to find a concrete solution.
I'm trying to detect when a user has started using their internet (3G, Wifi). (Or is about to start would be even better).
Does anyone know if there is an Intent that could detect a person is starting to use the network? What I'm trying to do is run some code once the user starts using their internet regardless of whether or not it is 3G or Wifi.
I've been looking into ConnectivityManager, and Trafficstats() but have so far been unable to come up with a solution. I am not simply looking to see if a connection is available.
One solution that I've been thinking would be to create my own intent but I've been unable to find any good documentation on how to create your own intent filter. (most tutorials I've seen say to use/specify your own Intent, but neglect to say how to create the intent) Because of this, I'm assuming it's something simple that people don't feel is worth mentioning.
The idea behind using an intent was so that I could trigger code to execute on the event that the user is using the internet, not just connected to it. This would be preferable to having a continually executing loop that looks for rx/tx bytes sent out.
If anyone has any ideas and sample code that would be really appreciated.
Cheers
I do not know if this helps, but with this code I am trying to find when device goes into no network. I am sure you can modify this to detect if its 3G or WiFi.
no network
Copied from one of my projects http://code.google.com/p/android-menu-navigator/
You can combine it with the connection state changed mentioned by bandaa25 and I think you are done.
public boolean isOnWifi() {
Log.d(TAG, "Checking if we are on wifi");
final ConnectivityManager mgrConn = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
Log.d(TAG, "Retrieved connectivity manager");
final NetworkInfo network = mgrConn.getActiveNetworkInfo();
Log.d(TAG, "Retrieved network info: " + network);
final boolean result = network != null && network.getType() == ConnectivityManager.TYPE_WIFI;
Log.d(TAG, "Result : " + result);
return result;
}

Categories