I am have interview tomorrow i am need to know the difference between FormsAppCompatActivity vs MainActivity.. I have searched ithe internet but from what i found it seems that MainActivity is the base class and FormsAppCompatActivity derives from MainActivity and the main difference seems to be in the tool bar ?
seen this
Activity, AppCompatActivity, FragmentActivity, and ActionBarActivity: When to Use Which?
Xamarin.Forms - FormsAppCompatActivity or ForsmApplicationActivity
https://forums.xamarin.com/discussion/115952/xamarin-forms-formsapplicationactivity-or-formsappcompatactivity
https://learn.microsoft.com/en-us/xamarin/android/user-interface/material-theme
MainActivity is the main class for a Xamarin Android project
FormsAppCompatActivity is the main class for a Xamarin Forms Android project
Related
I'm trying to create an android plugin for Flutter that depends on using an AppCompatActivity (as it has a method that takes the embedding appcompatactivity as a parameter).
However, since my main activity extends FlutterActivity, I cannot simultaneously extend AppCompatActivity. I tried implementing it instead, but failed because of some redundancies.
Is there any way to hack this?
Thanks
extend AppCompatActivity vs extend flutterActivity
you can find your answer here
I am having an activity that extends appcompatactivity I want to use the methods of activity like getwindow(), setRequestedOrientation() and finish() etc. but not able to do so... It says cannot resolve method. so, is there any way cast AppCompatActivity to Activity.
I am using Android Studio 3.0 Canary 4
For a minimum API level of 15, you'd want to use AppCompatActivity. So for example, your MainActivity would look like this:
public class MainActivity extends AppCompatActivity {
....
....
}
To use the AppCompatActivity, make sure you have the Google Support Library downloaded (you can check this in your Tools -> Android -> SDK manager). Then just include the gradle dependency in your app's gradle.build file:
compile 'com.android.support:appcompat-v7:22:2.0'
You can use this AppCompat as your main Activity, which can then be used to launch Fragments or other Activities (this depends on what kind of app you're building).
The BigNerdRanch book is a good resource, but yeah, it's outdated. Read it for general information on how Android works, but don't expect the specific classes they use to be up to date.
You can cast AppCompatActivity to Activity:
((AppCompatActivity) getActivity()).someAction...
Is there a way I can extend both of these in a single activity? If yes, please share with me the source code.
From another SO answer:
To reduce the complexity and simplify the language, Android does not support multiple inheritance as it's based on Java programming language. Hence you can't extend both ActionBarActivity and YoutubeBaseActivity in a Single Activity.
The solution is pretty simple: use the YouTubePlayerFragment class. This does not pose any requirement on the Activity, leaving you with plenty of options for your theming.
Since the version 22.1.0, the class ActionBarActivity is deprecated. You should use AppCompatActivity.
Note : ActionBarActivity is deprecated, use AppCompatActivity.
Instead of having the Youtube player in the Activity (extending YoutubeBaseActivity), make your Activity extends from AppCompatActivity and use a YoutubePlayerFragment inside the AppCompatActivity. You will be able to use all the features of AppCompat with your Youtube video.
If you REALLY want to use BaseYoutubeActivity, you have to add an AppCompatDelegate in your own Activity extending the BaseYoutubeActivity and use it in every lifecycle method of your activity. Read the documentation of the delegate and read the original source code of AppCompatActivity to understand the delegate.
You cannot do that for now. you can use fragment instead of activity in your Activity that extends AppCompatActivity
Please refer to this answer. https://stackoverflow.com/a/30101931/4321808
I have a parent Activity that ALL other activities in my app extend from, let's call it MainActivity. At first it was extending OrmLiteBaseActivity, like so :
public class MainActivity extends OrmLiteBaseActivity<DatabaseHelper>
Now that I want to use ActionBarSherlock in my app, I have to extend from SherlockActivity... But I can't extend from two classes at once.
Has anybody worked with ORMLite and ActionBarSherlock before ?
As said by PratikButani: I ended up using ORMLite's OpenHelperManager for each time I wanted to used the database.
Link : https://stackoverflow.com/a/7662537/1318946
I'm triying to migrate my app from actionbarsherlock to Google's actionbarcompat, but ActionBarFragmentActivity does not exist. Do I have to use ActionBarActivity or there is another way?
Thanks in advance,
Diego.
Look here. This should help you out.
http://android-developers.blogspot.in/2013/08/actionbarcompat-and-io-2013-app-source.html
An Excerpt:
Extend Activity classes from ActionBarCompat:
ActionBarCompat contains one Activity class which all of your Activity classes should extend: ActionBarActivity.
This class itself extends from FragmentActivity so you can continue to use Fragments in your application. There is not a ActionBarCompat Fragment class that you need to extend, so you should continue using android.support.v4.Fragment as the base class for your Fragments.