This exception is occurs when we call the network calls in Main Thread. 1) Strict mode: 2) AsynkTask
Long Running process never run on Main Thread.
To solve this problem, having following ways
write this code in your onCreate method
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll()
.build();
StrictMode.setThreadPolicy(policy);
write your code inside doInBackground() method
private class DownloadFilesTask extends AsyncTask<Void, Void, Void> {
protected Long doInBackground(URL... urls) {
// write your code here
return ;
}
};
3) Using Thread
Thread thread = new Thread(new Runnable(){
@Override
public void run() {
try {
//Your code goes here
} catch (Exception e) {
e.printStackTrace();
}
}
});
thread.start();
FCM Not Receiving Notifications in Android - RRutors
Fix Error: Use JsonReader.setLenient(true) for Malformed JSON
Decompile APK Files: How to Get Source Code - RRutors Guide
What are the notifications available in android?
How to Exit android app on back pressed?
How do I generate random numbers in Dart?
How to check Android version?
FragmentPagerAdapter deprecated, Since API 27.1.0 FragmentPagerAdapter is deprecated.
How to get a contact image using a phone number in android?
How can i comment inside xml file in android studio?
Set Activity to Fullscreen Mode in Android - RRutors
How to install/ uninstall apk by command line ADB
What is ANR in android?
What is Android?
How to get screen size (width,height) in Android?
Check List for Generate Signed APK Android
How to stop EditText focus at Activity startup in Android?
What is the difference between match_parent and fill_parent?
How to validate email address in Android with Kotlin?
How do I check in SQLite whether a table exists?
How to Get bitmap from drawable: Android
How to reduce APK package size?
Fix Behavior Subclass BottomSheetBehavior Exception - RRutors
What are Android Versions available?
Symmetric vs Asymmetric Encryption in Android Server - RRutors
ERR_ACCESS_DENIED in Android Webview with sdk 30
What is Intent? What is the difference between an implicit intent and an explicit intent?
What is "shared preferences" in Android ?
What is Android Fragments?
How to find Android Device UDID or unique ID?
Extract Date and Time from Long Type Variable - RRutors
Key Points to remember while develop the Android Application.
Fix Android Emulator Kill Error When Running Your App
How to Generate signed apk with android studio
What happens next when the device switches between portrait and landscape?
How to start a new activity on button click
How to avoid multiple button click at same time in android?
How to convert DP to Pixel and Pixel to Dp?
What is Context?
How to save activity State in Android?