Posts

Error : One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts

To fix the error: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts As discussed at Google I/O 2023, registering receivers with intention using the RECEIVER_EXPORTED / RECEIVER_NOT_EXPORTED flag was introduced as: Solution Outline: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { registerReceiver (broadcastReceiver, intentFilter, RECEIVER_EXPORTED) }else { registerReceiver (broadcastReceiver, intentFilter) } Exact Code: if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . TIRAMISU ) { registerReceiver( onDownloadComplete , new IntentFilter( DownloadManager . ACTION_DOWNLOAD_COMPLETE ), RECEIVER_EXPORTED ); } else { registerReceiver( onDownloadComplete , new IntentFilter( DownloadManager . ACTION_DOWNLOAD_COMPLETE )); } Ref: StackOverflow

How to Send Crash Report to Email / Mobile Device in Android Java

Thread . setDefaultUncaughtExceptionHandler ( new Thread . UncaughtExceptionHandler () { @Override public void uncaughtException ( Thread thread, Throwable throwable) { // Handle uncaught exception sendCrashReport(throwable); } });   private void sendCrashReport ( Throwable throwable) { // Collect crash information StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter( sw ); throwable.printStackTrace( pw ); String crashReport = sw .toString(); // Compose email Intent emailIntent = new Intent( Intent . ACTION_SEND ); emailIntent .setType( "message/rfc822" ); emailIntent .putExtra( Intent . EXTRA_EMAIL , new String[]{ "sidbehala@gmail.com" }); emailIntent .putExtra( Intent . EXTRA_SUBJECT , "Crash Report" ); emailIntent .putExtra( Intent . EXTRA_TEXT , crashReport ); // Launch email intent startActivity( Intent . createChooser ( emailIntent , "Send crash rep

How to fix error : Task :app:processDebugGoogleServices FAILED Execution failed for task ':app:processDebugGoogleServices'. > No matching client found for package name 'com.example.appname'

PROBLEM: Task :app:processDebugGoogleServices FAILED Execution failed for task ':app:processDebugGoogleServices'. > No matching client found for package name 'com.example.appname'  Solution: In my case: Google Services JSON file : Step: 1 => Go to https://console.firebase.google.com/  Create New Project / Choose existing project. Click on the Android icon to add a new app to your Firebase project. Enter your Android app's package name. Also Enter App Name (Nick Name) Click Register Button. Now, google-services.json file is ready for download. Step: 2 => Download the google-services.json file from the Google Developer Console Step: 3 => Place it in the app directory of your Android project

HOW TO DISCARD UNDER REVIEW APP BUNDLE AND UPLOAD NEW APP BUNDLE

Image
Google PlayConsole: Releases that have not yet been sent for review can now be discarded by managing your release. To discard releases already in review, or ready to be published, first remove changes on Publishing overview. Steps to discard changes 1) Publishing Overview => Remove Changes for Review 2) Publishing overview => Production => Release summary => Discard Release

Code to Update App Automatically From Google PlayStore

  To prompt users to download App automatically from Google PlayStore as soon as an App update is available, use following code: In build.gradle (App Level) file, Add, implementation 'com.google.android.play:app-update:2.1.0' Sync Project Next add in you MainActivity Class( or any Activity that comes after SplashActivity, where I prefer to put this code) Add the following code private static final int REQUEST_CODE_UPDATE = 123; private AppUpdateManager appUpdateManager; Now inside  onCreate() Method, add the following code appUpdateManager = AppUpdateManagerFactory. create (this); appUpdateManager.getAppUpdateInfo().addOnSuccessListener(appUpdateInfo -> {     if (appUpdateInfo.updateAvailability() == UpdateAvailability. UPDATE_AVAILABLE             && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType. FLEXIBLE )) {         try {             appUpdateManager.startUpdateFlowForResult(                     appUpdateInfo,                     AppUpdateType. FLEXIBLE ,      

How to Add Animation to Android App in JAVA

First, define your animation in XML. For example, let's create a fade-in animation named fade_in.xml in the res/anim directory: res/anim/fade_in.xml: FILE CODE < alpha xmlns: android ="http://schemas.android.com/apk/res/android" android :duration ="500" android :fromAlpha ="1.0" android :toAlpha ="0.0" android :repeatMode ="reverse" android :repeatCount ="infinite" /> Create Image VIew < ImageView android :id ="@+id/blinking_image" android :layout_width ="wrap_content" android :layout_height ="wrap_content" android :src ="@drawable/animation" android :animation ="@anim/blink" /> In your activity or fragment, load the animation using AnimationUtils.loadAnimation() and apply it to the desired view: // Animation Code Block Animation fadeInAnimation = AnimationUtils . loadAnimation ( this , R . anim . blink ); // Find the vie

Errors while building APK. You can find the errors in the 'Messages' view.

Go to build.gradle (:app) - App Level Add following repositories   repositories { // jcenter() mavenCentral() maven { url 'https://jitpack.io' } google() } Update all dependencies. Now you should be able to build apk.