Rename package in Android Studio

Rename package in Android Studio In Android Studio, you can do this:   For example, if you want to change com.example.app to my.awesome.game, then: In your Project pane, click on the little gear icon (  ) Uncheck / De-select the Compact Empty Middle Packages option   Your package directory will now be broken up in individual directories Individually select each directory you want to rename, and: Right-click it Select Refactor Click on Rename In the Pop-up dialog, click on Rename Package instead of Rename Directory Enter the new name and hit Refactor Click Do Refactor in the bottom Allow a minute to let Android…

Read More

Could not find com.android.tools.build:aapt2:3.2.0-4818971 Android Studio

Could not find com.android.tools.build:aapt2:3.2.0-4818971 Android Studio Most likely you do not have the Google repository in your project’s build.gradle file. Add google() in BOTH locations as shown below: buildscript {     repositories {         google()         jcenter()     }     dependencies {         classpath ‘com.android.tools.build:gradle:3.2.0’     } } allprojects {     repositories {         google()         jcenter()     } }

Read More

Communication Within an Android App With EventBus

Communication Within an Android App With EventBus A typical Android app tends to be composed of many layers, modules or structures such as Fragments, Activities, Presenters, and Services. Effective communication between these components can become difficult if they are tightly coupled together.  In the lower level of your app architecture, such as the database, when an action happens, you might want to send data to a higher level such as the view. To do this, you might want to create a listener interface, async tasks or callbacks. All of these…

Read More

Registration form in Android (Check if email is valid and if EditText is empty)

Registration form in Android (Check if email is valid and if EditText is empty) On Click method:  bt_register.setOnClickListener(new View.OnClickListener() {             @Override             public void onClick(View v) {                 boolean isConnected = ConnectivityReceiver.isConnected();                 if (isConnected) {                     chekdata();                 } else {              …

Read More

Set container layout above BottomNavigationView

Set container layout above BottomNavigationView I have used a FrameLayout to prevent the BottomNavigationView from overlapping with layouts above it. <?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:id=”@+id/container”     android:layout_width=”match_parent”     android:layout_height=”match_parent”     tools:context=”com.xxx.xxx.xxxx”>     <FrameLayout         android:id=”@+id/fragment_container”         android:layout_width=”0dp”         android:layout_height=”0dp”         app:layout_constraintTop_toTopOf=”parent”         app:layout_constraintBottom_toTopOf=”@+id/navigation”         app:layout_constraintLeft_toLeftOf=”parent”         app:layout_constraintRight_toRightOf=”parent”>         <include        …

Read More

Difference between Service and Broadcast receivers in android

Difference between Service and Broadcast receivers in android Service is used when you want to do something in background, any long running process can be done using Service in Background. For example, you want to play music when your application gets close. In that case service will be running in background with music. BroadcastReceiver is used when you want to fire some stuff or code during some event. For example, event can be on Boot of Device. If you want to perform something when device Boots, date and time changed…

Read More

Enabling Device Administration APIs in Android

Enabling Device Administration APIs in Android In android, Admin level features are like accessing the device password, enabling/disabling the device camera, erasing all the device data, limiting the maximum number of password attempt etc. But these admin features cannot be accessed directly in an android app. In order to use these features, we have to enable the Device Admin APIs. For using Device Administration APIs in android app, firstly we have to register these APIs and then we can access the admin level functionality. Steps for Registering the APIs:- 1.…

Read More

How to use MultiDex with a custom Application class?

How to use MultiDex with a custom Application class? public class BaseApplication extends Application {         @Override         public void onCreate() {             super.onCreate();             // your custom code here         }     // Add multidex Code or other Application Class here         @Override         protected void attachBaseContext(Context base) {             super.attachBaseContext(base);             MultiDex.install(this);…

Read More

How to send app crash reports in Android

How to send app crash reports in Android Code: import android.app.Application; import android.content.Context; import android.content.Intent; import android.util.Log; /**  * Created by amit on 22/4/16.  */ public class BaseApplication extends Application {     @Override     public void onCreate() {         super.onCreate();         Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {             @Override             public void uncaughtException(Thread thread, Throwable ex) {                 handleUncaughtException(thread, ex);             }  …

Read More