How do you get the hardware back button on VideoCastControllerActivity to work? - google-cast

Once my app starts playing and VideoCastControllerActivity shows up, the hardware back button won't take it back to my activity. The actionbar back button works just fine. I don't see any errors on the logs or anything and looking at the VideoCastControllerActivity I didn't see anything obvious trying to capture the back button behaviour or anything. To start it I am calling startCastControllerActivity.
Here is the chunk of my manifest declaring it:
<activity
android:name="com.google.sample.castcompanionlibrary.cast.player.VideoCastControllerActivity"
android:label="#string/app_name"
android:launchMode="singleTask"
android:parentActivityName="com.mypackage.myactivity"
android:screenOrientation="portrait"
android:theme="#style/Theme.AppCompat" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.mypackage.myactivity" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
Thanks.

The CastCompanionLibrary doesn't try to capture the back button at all, so it should work just fine. Please try the CastVideos-andrid (which uses that library) to confirm that.

Related

Android studio - Complete operation with "app" (Open .txt file with the app)

the thing I want to do is to share a txt file through whatsapp and open it with my app, converting datas written in it, to be able to use them in the application.
I've read something about the "BroadcastReceiver", but what I found didn't work as well.
I attach a pic to let you understand better,
thank you for help!
picture
I resolved, in manifest, inside the activity:
<intent-filter tools:ignore="AppLinkUrlError">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>

How to animate default splash screen in nativescript angular

I was wondering how to animate the default splash screen which comes with nativescript, possibly the logo?
Is there a way of adding some css animation to the splash_screen.xml file found in the drawable folder? Thanks
You can use nativescript-splashscreen plugin to add animation in your splash screen. You need to update your AndroidManifest.xml e.g.
<activity
android:name="com.tns.NativeScriptActivity"
android:label="#string/title_activity_kimera"
android:configChanges="keyboardHidden|orientation|screenSize">
</activity>
<activity
android:name="co.fitcom.SplashScreen" android:noHistory="true">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>

Android Studio Not Applying My Design Changes

I'm trying to change the theme of some activities by removing the action bar or changing the title of it. At first i was doing it using the AppTheme option in the design tab. However, after searching online i knew that i was doing it the wrong way, so i proceeded to the AndroidManifest file to do my changes manually. Unfortunately, it's not working either. Here's the code of my manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.wonderheart">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity"
android:label="Sign Up"/>
<activity
android:name=".Login"
android:label="Log In"/>
<activity android:name=".drawable.welcome">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".UserProfile"
android:theme="#style/AppTheme.NoActionBar"/>
<activity android:name=".HomePage" >
</activity>
</application>
</manifest>
Here are some of my activities that I'm trying to change:
Action Bar Title Changed Successfully
Action Bar Title Didn't Change
I'm using Android Studio 3.0 Preview and Kotlin. I hope you can help because i can't progress on my work without fixing this design issue!
You can fix problem two way.
1. Use common one theme for all activities and use code for hiding and showing action bar in onCreate method
// Set up the toolbar
val toolbar = findViewById(R.id.toolbar) as Toolbar
setSupportActionBar(toolbar)
var actionBar = supportActionBar
//For hiding android actionbar
actionBar.hide();
//For showing android actionbar
//actionBar.show();
Use custom style for activity where you don’t want to show action bar in example below I did it for application level but you can use it your way with your any other activities
style.xml
<resources>
<style name = "AppTheme" parent = "android:Theme.Holo.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
<style name = "NoActionBar" parent = "#android:style/Theme.Holo.Light">
<item name = "android:windowActionBar">false</item>
<item name = "android:windowNoTitle">true</item>
</style>
</resources>
AndroidManifest.xml
<application
android:allowBackup = "true"
android:icon = "#drawable/ic_launcher"
android:label = "#string/app_name"
android:theme = "#style/NoActionBar" <!--This is the important line-->
>
<activity

I want gradle to build only single class instead of the whole project

In Android Studio project I have a separate class where I experiment with java code. The class has method public static void main(String[] args){}
Right click on this class in project tree -> Run (Ctrl+Shift+F10)
And I noticed that gradle starts building the whole project. And it takes certain time but I want it to build and run only this one class. So it is as fast as possible.
How can I achieve this?
You can try modifying your AndroidManifest file to run only the class you want as a main-launcher class:
<application
android:name=".MyApplication"
android:allowBackup="true"
android:icon="#drawable/my_icon"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:replace="android:icon,android:theme">
<activity
android:name=".RUN_YOUR_ACTIVITY"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

actionbarsherlock getSupportActionBar() return null in android4.0,but in 2.3.3 is ok

application use actionbarsherlock,but main activity get getsupportactionbar returns null.
AndroidManifest.xml:
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Light1Theme" >
<activity
android:name=".activity.LogonActivity"
android:configChanges="orientation|keyboardHidden"
android:windowSoftInputMode="adjustUnspecified|stateHidden" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
...
themes.xml:
<style name="Light1Theme" parent="Theme.Sherlock.Light">
LogonActivity.ava
extends SherlockActivity implements OnSharedPreferenceChangeListener {
...
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//requestWindowFeature(Window.FEATURE_NO_TITLE);
//getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.logon);
try{
final ActionBar ab = getSupportActionBar();
//return null
ab.setBackgroundDrawable(getResources().getDrawable(R.drawable.ab_bg_black));
getSupportActionBar().setIcon(R.drawable.hospital);
}catch(Exception e){
Log.e("", e.getMessage());
}
I was facing this same issue a few hours ago, and it turned out, the root of the problem was that I used a theme with no title bar.
This reply from Jake Wharton, the developer of actionbarsherlock will help you sort it out.
In short: on android versions ICS and newer, setting the attribute android:windowNoTitle will affect the action bar's display (as it is a core feature in those versions).
The ABS has wrapped it into windowNoTitle (with no namespace / default abs namespace), so depending on the android version your application is installed on, you will get the proper display.
If you have the line
<item name="android:windowNoTitle">true</item>
in your style definition, just change it to
<item name="windowNoTitle">true</item>
or completely leave it out / remove it from your theme (abs will handle it correctly!)
I was facing this same issue now , and I found that use android:theme="#style/Theme.Sherlock" is enough.
if you use
<item name="windowNoTitle">true</item>
or
<item name="android:windowNoTitle">true</item>
It will crash application , may be Jake fix this in Theme.Sherlock.
So Here is my solution now:
<application
android:name="XXXXApplication"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Sherlock" >
And it works well on ICS+ and pre-ICS , test on android 2.3.5,2.3.7,CM7 , android 4.0,4.1
In my case, I face this issue when I set the theme android:theme="#style/Theme.Sherlock.NoActionBar", then call getSupportActionBar() to get the actionbar. If you want to manage the action bar, just turn the them to android:theme="#style/Theme.Sherlock.
I had the same problem. I have simple removed below line of code and its work like a charm.
requestWindowFeature(Window.FEATURE_NO_TITLE);

Resources