How to extend ActionBarActivity and YoutubeBaseActivity? - android

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

Related

How can I extend and implement two libraries at the same time?

I would like to build an activity that uses the Youtube API, and App compact activity.
How can I merge these two libraries together:
Youtube library:
public class Activity extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener { }
App compact activity library
public class Activity extends AppCompatActivity { }
Thank you.
Multiple inheritence is not supported by Java (for better or for worse), and YouTubeBaseActivity extends Activity, if YoutubeBaseActivity extended AppCompatActivity you would have had your wish !
In my opinion not supporting multiple inheritence was the right way as it can cause the diamond problem of multiple inheritance among inexperienced developers.
To Quote WikiPidea
The "diamond problem" (sometimes referred to as the "deadly diamond of
death") is an ambiguity that arises when two classes B and C
inherit from A, and class D inherits from both B and C. If there is a
method in A that B and C have overridden, and D does not override it,
then which version of the method does D inherit: that of B, or that of
C?
As for your problem
I would like to create an activity that shows an youtube video at the
top, and a pager adapter at the bottom. I need to call a method called
"getSupportFragmentManager()", but I can't do it without extending the
AppCompatActivity, thats why I was trying to use both
Use YouTubePlayerSupportFragment if you are only playing a YouTube video in a single support.v4.app.Fragment. This allows you to use FragmentActivity, rather than YouTubeBaseActivity.

How to call fragment from activity without using fragmentactivity?

In my project i am using fragments and activities. in one of activity i used youtube video api, now i want to call fragment from that activity but they are not allowing without fragmentactivity and i extended youtubebaseactivity in that activity.so please help me
extend yourclass with ActionBarActivity and you can Access both functionality.
Thats it...

Create library that supports native and suppport fragments/activities

Is there a way to this?
I want to create a fragment, that either extends the support fragment or the default fragment... I think this is not possible, so I ask the question in another way: what's the most beautiful workaround you know/use?
I think this is not possible
Correct.
what's the most beautiful workaround you know/use?
Put the business logic in a separate class (I will call it FragmentHelper). Create one fragment class that extends the native Fragment implementation, and have it delegate work to the FragmentHelper. Create another fragment class that extends the support package's Fragment implementation, and have it delegate work to the FragmentHelper.

Is there an onPause in ActionBarActivity?

I was following Android tutorials from mybringback and he was using his created class and it was, by default, extended to use Activity and since that video was made a while ago, I'm guessing that ActionBarActivity wasn't available then.
However in the tutorial he uses super.onPause in his media file video, which is not available in the override methods for ActionBarActivity, so I was wondering, if there was another way for me to do the same thing, if onPause would be called something else in ActionBarActivity, or if I should just change ActionBarActivity to Activity instead.
Thanks!
In eclipse if you want to use Source->Override/Implement Methods, to generate the onPause method, you need to look under the FragmentActivity expansion, since ActionBarActivity is a subclass of FragmentActivity
ActionBarActivity subclasses FragmentActivity
FragmentActivity subclasses Activity
Activity contains method onPause()
Therefore, yes! There is an onPause() method in ActionBarActivity
You should really learn to use documentation and not rely on override implement methods feature in Eclipse https://developer.android.com/reference/android/support/v7/app/ActionBarActivity.html

Action Bar Fragment Activity

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.

Categories

Resources