Skip to main content

Posts

Android Close Application Programmatically Tutorial

While designing an app you may have a login screen and after the user logs in the app and is on the Main member activity, you may also want the app to exit after the user presses the back button and isn't directed towards the Login screen again.

Android Close Application Programmatically
To prevent your Android app user to be redirected towards the login screen again here is a simple Java code that you can use in Android Studio in the Member Activity Java file to close application programmatically:

@Overridepublic void onBackPressed() { Intent start = new Intent(Intent.ACTION_MAIN); start.addCategory(Intent.CATEGORY_HOME); start.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); start.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(start); }
The code shown above kills the activity and user is directed to Home Screen of his Android.

Recent posts

How to Make A Website An App on Android

In this blog you’ll learn How to Make A Website An App on Android. For this, you must have Android Studio installed on your PC or Mac.
How to Make A Website An App on Android We'll use our website https://www.faultinmycode.com. To make an Android App of your website follow the steps given below:

1.Open Android Studio and create an Android Project

2. Create Empty Activity.

3. Open activity_main (search in the Project Panel on the left) and enter XML code for WebView inside layout tags. Code for this is as follows:

activity_main.xml <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical&quo…

Top 5 best programming language for Mobile Apps

More than 3,000+ Android Apps are published everyday on Google Play store and the best thing about these apps are that they aren’t only developed by professionals but are also made by some armatures who are school kids, college students or some retired old man.

Its not only Android smartphones that have reached almost every hand on this planet but also it’s development that has become dream of almost every Android geek to have their app on the Play Store. But however before you begin your journey with Android, its important to have some basic knowledge about Programming.

To help you get started with your Android App Development here is a list of best programming language for Mobile Apps Development:

1. Java | Android App Development for Beginners Released back in 1995 by Sun Microsystems, Java is a key component in Android OS. The Android SDK uses the Java language as the basis for Android applications. It’s fairly easy to use Java programming language especially in Android Studio ID…

Handler with runnable in Android Example Tutorial | FaultInMyCode

In this blog about threading in Android, you’ll learn about how to set up a thread in android other than the main thread to continue a different process.

I do believe you’re on Facebook and have downloaded a video directly from the Facebook app itself which you can view in offline mode later. Have you noticed how while the video is downloading, you’re still able to look at your news feed or tag your friends on a status and etc. and when the video is downloaded a Toast message appears that video has been downloaded successfully, This is known as multithreading.

Multithreading is the ability of a central processing unit (CPU) or a single core in a multi-core processor to execute multiple processes or threads.

To explain how threading works in even more detail and how you can thread your app too and make it multifunctional and smarter, in this tutorial we will build an Android app in which you’ll be clicking on a button to change a TextView that’ll change after 10 seconds and meanwhi…

Things to know about Android findViewByID before you start coding!

When you open Android studio and start building up your User Interface (UI) in activity_main.xml file and later code stuff in Java file, findViewByID is one most common method that you would’ve called in onCreate() method of MainActivity.Java File. In this blog, I’ll teach you everything that you should know about findViewByID and how to code it!
What is findViewByID? findViewByID is a commonly used method for Android App development in Android Studio programmed in Java or Kotlin Programming Language.

It’s an Android viewobject used to get a reference to the UI components specified in the XML layout file. So how does it references a variable in Java file to a component in the XML file?
The simple answer to this is the R file. R is an automatically generated file by Android Studio (even after you delete it, its automatically generated!).

findViewByID finds the ID of a particular component in the R file and then looks for the related view. It must be done in the onCreate method when t…

6 Android Development Tips for Beginners from Experienced Developers

If you’re someone looking ahead to spend your summer or winter break learning Android Development and planning to launch an app soon then here we have got some 6 top most Android Development tips from experienced developers to help you launch your app and make it a success.
Keep your IDE updated An Integrated Development Environment (IDE) is a software application that provides comprehensive facilities to computer programmers for App development. Android Studio or Eclipse whatever IDE you use for Android development, make sure to keep it updated to (stable) latest version. Develop for all Being a versatile OS, Android is available for many different screen sizes, so if you’re targeting mobile or tablet, make sure you develop it for all gadget screen sizes that fall under mobile or tablet category. Optimize for Speed Unlike desktops, many mobile gadgets don’t come with good processing speeds also RAM is limited. Limit Permissions Limit permissions required by your app, information lik…

Dealing with Jsonobject Java Tutorial with Example Explained

Dealing with Jsonobject Java language, if you've some data in JSON format and are trying to parse it in some readable format for the user using Java programming, then you're reading the right blog!

In this tutorial we will be using Android Studio in which using Java programming we will parse the JsonObject that we will receive from the server and text will be displayed in TextView.

Jsonobject Java Tutorial 
Here is the sample JSONObject data:


[
 {
   "name": "Afghanistan",
   "alpha": "AFG"
 },
 {
   "name": "Ă…land Islands",
   "alpha": "ALA"
 },
 {
   "name": "Albania",
   "alpha": "ALB"
 },
 {
   "name": "Algeria",
   "alpha": "DZA"
 },
 {
   "name": "American Samoa",
   "alpha": "ASM"
 },
 {
   "name": "Russian Federation",
   "alpha": "RUS"
 },
 {
   "name&q…

Using BeautifulSoup Python Example Web Scraping Stock prices from Bloomberg Website

In this tutorial on Python, we will use BeautifulSoup Python Example for web scraping current S&P 500 index prices available at Bloomberg website.
What is Web Scraping? As a developer, most of us work on various projects that require data for which we are dependent on some websites like in this tutorial where are would need latest Stock prices in the market and for this, we are going to be dependent on Bloomberg website.
Extracting information from some website is known as Web Scraping and doing web scraping is somewhat illegal. Why so? well by doing web scraping though you are leveraging other developers work and at the same time, you are also utilizing their server and that too without their consent. Developing an app for stock market prices that uses a web scraping and publishing that on App store can actually get you a lifetime ban.

But don’t worry as this is just a tutorial and it won’t stress their servers. But if you are planning to develop some app that would need to str…

Using Android SoundPool Build your Own Android Piano App

Playing any musical instrument on our Android device is the best thing that most of us like to do, be it Piano, Violin or Xylophone. Such apps basically use Android media library class known as Android SoundPool that handles short music tones on pressing of a button or object.

Android SoundPool In this given below tutorial we will teach you how to build your own Piano using Android SoundPool class. For this we expect you have prior knowledge about ConstraintLayout in Android, if not please check out our tutorial on how to make your calculator app in Android.
Things NeededWindows 7 or higher / Mac OS (Mavericks or higher) with minimum 4GB RAMAndroid Studio (with SDK and latest API) and JAVA installed on system.MP3 Piano Resource Files for each button. Link is here. What we will build So the app we will build in this tutorial will have around 14 buttons, each having assigned to an onClick() method that’ll play the audio using SoundPool class.
The buttons and their location will be set…

How to Add Ads in Android App Example | Admob Ads

There are millions of Free Apps on the Play Store with plenty of them containing ads on them. If you are planning to build your own Freemium app and integrate it with Google Admob Ads, here is a guide for you on How to Add Ads in Android App Example.

How to Add Ads in Android App Example
To start with How to Add Ads in Android App Example here is your Step to Step guide:

1.Open Google Admob website, link here and create a free account.

2. Once the account is created, Click on ‘Get Started’ button to create your first Google Admob Ad unit.
How to Add Ads in Android App Example 3. Google Admob will now ask if you have your App published in Play or App store, select ‘No’ if not.

4. Enter your App name and Platform, ‘Android’ for Android Studio.

5. Google Admob App ID is now generated which is a unique App ID for your App which will be added later to the source code.

6. Now select what kind of Google Admob Ad you want to integrate into your App. Is it Banner, Interstitial or Rewar…

Top 14 Free Android Download Manager Library for Downloading Files from Internet

If you are planning to build an Android App that would need to send request to server to download some mp3, mp4, pdf or even apk files. Here is a list of 14 Top Free Android Download manager library that you can use in your Android project and enhance the capability of your App to download files much easily.
1. Fetch Android Download Manager Library Made by Developer Tonyo Francis, Fetch is a great Android Download manager library coded in Kotlin Programming Language. It’s simple to use and easily customisable. One can download any file with .mp3, .mp4, .json or .mp4 file format files easily using Fetch Android Download Manager Library.

The developer claims it to have a simple an easy to use API with continuous and concurrent downloading in background support. You can Pause and Resume your downloads and track the progress with speed reporting and ability to retry failed downloads. For complete documentation on ‘Fetch’, Click here.
2. Download-Manager by Novoda Download-Man…