Default Activity not found in Android Studio

Have you added ACTION_MAIN intent filter to your main activity? If you don’t add this, then android won’t know which activity to launch as the main activity. ex: <intent-filter> <action android:name=”android.intent.action.MAIN”/> <action android:name=”com.package.name.MyActivity”/> <category android:name=”android.intent.category.LAUNCHER” /> </intent-filter>

“Failure Delivering Result ” – onActivityForResult

First of all, you should read my blog post for more information (it talks about why this exception happens and what you can do to prevent it). Calling commitAllowingStateLoss() is more of a hack than a fix. State loss is bad and should be avoided at all costs. At the time that onActivityResult() is called, … Read more

Android – Activity vs FragmentActivity? [duplicate]

ianhanniballake is right. You can get all the functionality of Activity from FragmentActivity. In fact, FragmentActivity has more functionality. Using FragmentActivity you can easily build tab and swap format. For each tab you can use different Fragment (Fragments are reusable). So for any FragmentActivity you can reuse the same Fragment. Still you can use Activity … Read more

startActivityForResult() from a Fragment and finishing child Activity, doesn’t call onActivityResult() in Fragment

You must write onActivityResult() in your FirstActivity.Java as follows @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); } So this will call your fragment’s onActivityResult() Edit: the solution is to replace getActivity().startActivityForResult(i, 1); with startActivityForResult(i, 1);

Difference between Activity and FragmentActivity

A FragmentActivity is a subclass of Activity that was built for the Android Support Package. The FragmentActivity class adds a couple new methods to ensure compatibility with older versions of Android, but other than that, there really isn’t much of a difference between the two. Just make sure you change all calls to getLoaderManager() and … Read more

Android ViewPager with bottom dots

No need for that much code. You can do all this stuff without coding so much by using only viewpager with tablayout. Your main Layout: <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” android:layout_width=”match_parent” android:layout_height=”wrap_content”> <android.support.v4.view.ViewPager android:id=”@+id/pager” android:layout_width=”match_parent” android:layout_height=”match_parent”> </android.support.v4.view.ViewPager> <android.support.design.widget.TabLayout android:id=”@+id/tabDots” android:layout_alignParentBottom=”true” android:layout_width=”match_parent” android:layout_height=”wrap_content” app:tabBackground=”@drawable/tab_selector” app:tabGravity=”center” app:tabIndicatorHeight=”0dp”/> </RelativeLayout> Hook up your UI elements inactivity or fragment as follows: Java … Read more

TabHost with Fragments and FragmentActivity

I would suggest creating a separate fragment file for each tab. I recently did this as well, so I have outlined my code below: Layout Files activity_main.xml <android.support.v4.app.FragmentTabHost xmlns:android=”http://schemas.android.com/apk/res/android” android:id=”@android:id/tabhost” android:layout_width=”match_parent” android:layout_height=”match_parent”> <LinearLayout android:orientation=”vertical” android:layout_width=”match_parent” android:layout_height=”match_parent”> <TabWidget android:id=”@android:id/tabs” android:orientation=”horizontal” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:layout_weight=”0″/> <FrameLayout android:id=”@android:id/tabcontent” android:layout_width=”0dp” android:layout_height=”0dp” android:layout_weight=”0″/> <FrameLayout android:id=”@+id/realtabcontent” android:layout_width=”match_parent” android:layout_height=”0dp” android:layout_weight=”1″/> </LinearLayout> </android.support.v4.app.FragmentTabHost> tab1_view.xml … Read more