Android Development

Option menu or Popup menu change background

  Ref: https://stackoverflow.com/questions/21231404/how-to-change-background-color-popup-menu-android/30731151 Add Popup-Menu style to your App-Theme: <style name=”AppTheme” parent=”android:Theme.Light”> <item name=”android:popupMenuStyle”>@style/PopupMenu</item> </style> <style name=”PopupMenu” parent=”@android:style/Widget.PopupMenu”> <item name=”android:popupBackground”>@android:color/white</item> </style>  

Android Activity Life-cycle

First opens Activity: onCreate(),OnStart(),onResume() User Clicks backButton(): onPause(),onStop(),onDestroy() Navigating to another screen: First Screen:: onPause(),onStop() Second Screen: onCreate(),OnStart(),onResume() Presses Backbutton in Activity2: Second Screen: onPause(),onStop() ,onDestroy() First Screen: onRestart(), onStart(), onResume() User locks the device: onPause(),onStop() Again Opens lock: onRestart(), onStart(), onResume()

RecycleView steals focus when inside a NestedScrollView

Reference Link: https://stackoverflow.com/questions/36923948/recycleview-steals-focus-when-inside-a-nestedscrollview add this two line of code in parent or root viewgroup: <android.support.v4.widget.NestedScrollView xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”match_parent” android:layout_height=”match_parent””> <LinearLayout android:layout_width=”match_parent” android:layout_height=”match_parent” android:focusableInTouchMode=”true” android:orientation=”vertical”> <View android:id=”@+id/someView” android:layout_width=”wrap_content” android:layout_height=”350dp”/> <android.support.v7.widget.RecyclerView android:id=”@+id/recyclerView” android:layout_width=”match_parent” android:layout_height=”wrap_content”/> </LinearLayout> </android.support.v4.widget.NestedScrollView>

file was loaded in the wrong encoding android studio windows

Reference Link: https://stackoverflow.com/questions/53249677/android-studio-shows-wrong-file-contents/54509482#54509482 Thanks to the Answer of Asim, I found deleting folder caches fixed the problem for my case (all gradle files in Android Studio show contents that have nothing to do with the actual contents of these files): Delete caches folder.then you are good to go. C:\Users\my_user_name\.AndroidStudio3.3\system\caches

Glide With Drawable

Reference Link: https://stackoverflow.com/questions/33594735/is-it-possible-to-use-glide-to-download-image-to-load-into-a-textview Sample Code: Glide.with(myFragmentOrActivity).load(imageUrl) .into(new CustomTarget(100,100) { @Override public void onResourceReady(@NonNull Drawable resource, @Nullable Transition

Admob Native advanced (Example)

All Admob Example : https://github.com/googleads/googleads-mobile-android-examples Admob Official Doc: https://developers.google.com/admob/android/native/ Github Link: https://github.com/googleads/googleads-mobile-android-examples/tree/master/java/admob/NativeAdvancedExample/   you tube video: https://youtu.be/wENWbEKRfaM   FEED LAYOUT ADD======================================== <?xml version=”1.0″ encoding=”utf-8″?> <com.google.android.gms.ads.formats.UnifiedNativeAdView xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”match_parent” android:layout_height=”match_parent” xmlns:app=”http://schemas.android.com/apk/res-auto” > <androidx.cardview.widget.CardView android:layout_width=”match_parent” android:layout_height=”wrap_content” android:layout_gravity=”center” android:background=”@drawable/bg_white_border_no” app:cardBackgroundColor=”@color/whiteBgcolor” app:cardCornerRadius=”10dp” app:cardElevation=”2dp” app:cardUseCompatPadding=”true” android:minHeight=”50dp”> <LinearLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” android:orientation=”vertical” android:padding=”10dp”> <LinearLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” android:orientation=”horizontal”> <ImageView android:id=”@+id/ad_app_icon” android:layout_width=”40dp” android:layout_height=”40dp” android:src=”@drawable/logo_xml” android:adjustViewBounds=”true” …

Admob Native advanced (Example) Read More »

কোডক্যানিয়নের জন্য এন্ড্রয়েড অ্যাপ ডেভেলপমেন্ট

কোডক্যানিয়নের জন্য এন্ড্রয়েড অ্যাপ ডেভেলপমেন্ট এন্ড্রয়েড জগতে আমি নতুন, বেশ কিছু বছর থেকে পিএইচপি নিয়ে কাজ করি। মাত্র ২ বছর আগে গুরু “হাসান আবদুল্লাহ” ভাইয়ার হাত ধরে এই সেক্টরে পথচলার শুরু। যেহেতু লেখালেখির মোটেও অভ্যাস নাই সেহেতু লেখাতে অনেক ভুলভ্রান্তি থাকাটাই স্বাভাবিক। ভুলভ্রান্তিগুলা ক্ষমাসুলভ দৃষ্টিতে দেখার অনুরোধ রইল। কারও কোন প্রশ্ন থাকলে ইনবক্স না করে …

কোডক্যানিয়নের জন্য এন্ড্রয়েড অ্যাপ ডেভেলপমেন্ট Read More »

Firebase Cloud Messaging (notifications)

library link: https://github.com/karanatwal/FirePush Reference link: https://stackoverflow.com/questions/37576705/firebase-java-server-to-send-push-notification-to-all-devices/42455788 official link: https://firebase.google.com/docs/cloud-messaging/send-message App Level Build.Gradle : implementation ‘com.google.firebase:firebase-analytics:17.2.0’ implementation ‘com.google.firebase:firebase-messaging:20.0.0’ step 1: create a service class that extends firebaseMessagingService class: public class FirebaseMessagingService extends com.google.firebase.messaging.FirebaseMessagingService { @Override public void onMessageReceived(RemoteMessage remoteMessage) { //get default notificaion data String mesgeTitle=remoteMessage.getNotification().getTitle(); //get extra data String msgType=remoteMessage.getData().get(“msg_type”); } } step 2: enable …

Firebase Cloud Messaging (notifications) Read More »

send data using Interface(bottom sheet to activity)

reference link: best: https://stackoverflow.com/questions/46106607/pass-or-listen-data-from-bottomsheetdialogfragment-to-fragment?rq=1 reference link:https://androidwave.com/bottom-sheet-dialog-fragment-in-android/         1.First create an interface public static class ShowBottomSheetDialog extends BottomSheetDialogFragment { //stp 1 public interface BottomSheetListener{//step 1 void onUpdateClick(Object updatedInfo,String CallBackTag); } //stp 2 2.create a member variable or that interface private BottomSheetListener mBListener;//step 2 3.onattach init the member variable try { mBListener=(BottomSheetListener) context;//step 3 …

send data using Interface(bottom sheet to activity) Read More »

ViewPager with FragmentPagerAdapter (single fragment multiple content)

full Reference link: https://github.com/codepath/android_guides/wiki/ViewPager-with-FragmentPagerAdapter Define Fragments public class FirstFragment extends Fragment { // Store instance variables private String title; private int page; // newInstance constructor for creating fragment with arguments public static FirstFragment newInstance(int page, String title) { FirstFragment fragmentFirst = new FirstFragment(); Bundle args = new Bundle(); args.putInt(“someInt”, page); args.putString(“someTitle”, title); fragmentFirst.setArguments(args); return fragmentFirst; …

ViewPager with FragmentPagerAdapter (single fragment multiple content) Read More »