Data Sharing between Fragments and Activity in Android

Many ways : 1) Activity -> Fragment In your Activity : create a bundle and use fragment.setArguments(bundle) in your Fragment : use Bundle bundle = getArguments() 2) Activity -> Fragment In your Fragment : create a public method In your Activity : call an active fragment public method : getSupportFragmentManager().findFragmentById(R.id.your_fragment).publicMethod(args) 3) Fragment -> Activity In … Read more

What is the different between Explicit and implicit activity call in android?

For example: implicit activity call In intent filter you create action for you activity, so other app can call your activity via this action as following: <activity android:name=”.BrowserActivitiy” android:label=”@string/app_name”> <intent-filter> <action android:name=”android.intent.action.VIEW” /> <category android:name=”android.intent.category.DEFAULT” /> <data android:scheme=”http”/> </intent-filter> </activity> And the other way to call implicit Intent is below: Intent intent = new Intent(Intent.ACTION_VIEW, … Read more

Android – Making activity full screen with status bar on top of it

I know that the guy asking the question may have found his own solution but for the people who are still looking for a solution this is a very simple solution but one thing it has a limitation till Kitkat so a condition is added if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); }

Android Fragment onCreateView vs. onActivityCreated

If your view is static, then moving any code to the onActivityCreated method is not necessary. But when you – for instance, fill some lists from the adapter, then you should do it in the onActivityCreated method as well as restoring the view state when setRetainInstance used to do so. Also accessing the view hierarchy … Read more

How to close activity and go back to previous activity in android

I think you are calling finish() method in MainActivity before starting SettingsActivity. The scenario which you have described will occur in following two ways: EITHER You have set android:noHistory = “true” for MainActivity inside AndroidManifest.xml which causes MainActivity to finish automatically on pressing the back key. OR Before switching to your ‘SettingsActivity’, you have called … Read more