Custom layout for Google Cast 'ExpandedControlsActivity' - android

Is it possible to have a custom layout for 'ExpandedControlsActivity' in an android application? I want to add a button to the standard layout which will allow the user to choose from different video streams (low/high).
At the moment i am using the standard one;
Google codelabs - Cast SDK v3 Android Codelab

No, you do not have control over the layout. You can only use one of the pre-defined actions for the buttons on that screen. You can, however, write your own custom activity and have that act as the Expanded Controller (i.e. be invoked if user, say, taps on the mini controller). Given that it is easy to use UiMediaController to bind ui components of your app to the remote session, writing such activity shouldn't be too much trouble.

For addition of any custom layout you need to modify activity_layout.xml and activity.java in order to add the feature.
But you dont have Access to the ExpandedControlsActivity layout file as it is extended from ExpandedControllerActivity.
So only way is to write your own activity and than use that instead of ExpandedControlsActivity.

Related

Android- Display Global Application Information

I am working on an application that has several states that matter to the user, online vs offline, how far out of date the local application database is, et cetera. I understand that both non-persistent and persistent notifications are available in android, and might be appropriate in this scenario. However, in our organization's iOS application, there is an 'information bar'.
I realize that this is somewhat of a departure from material design. Is this even possible? I'd like to extend the App Bar in some way as opposed to creating a fragment that I add to every activity if possible.
Try any of the following
1) Replace the action bar with toolbar and customize the design on your own and handle it.
2) Create the separate layout file with the above design and then include it in any screen using the tag <include/>
You can do this a custom Toolbar class or with Fragments. For the later option, each activity will have the user information at the top, either as a view or a fragment. The "normal app stuff" will be a FrameLayout which can hold one fragment at a time. See the Fragment tutorials on http://developer.android.com.
There aren't really hooks for extending the toolbar- in fact Google has deprecated a lot of stuff it used to be able to do (such as tabs in the toolbar). Your best bet is to use a custom fragment at the top of every Activity.

Custom switch button using textView

I created custom switch button using two textview components. Is there any easy way to give one element on the another using OnClickListener ?
Example:
Why did you make your own? Android already provides Switches where you don't have to worry about any of this stuff since it is already implemented. Specifically you want the Toggle Button (changes to a switch button in Android 4.0+).
This way you will be providing users controls which are specific to their platform and match other similar applications that they use.

Android - Cards UI framework

I'm using the framework from here - cardsui
How can I add a share button to the top of the cards. I've implemented it in the xml with an on click method, but the app crashes when I press it and says that the method doesn't exist (yes, I added the method to the main java file. also to the card.java file but still the app crashes...).
Has anyone used this framework and encountered this?
Thank you
You might want to check this addon for CardsUI: https://github.com/Androguide/cardsui-for-android
As developer wrote:
The Google Play cards come with more customization parameters than the other regular cards, those parameters include :
Title (String)
Description (String)
Stripe color (String)
Title Color (String)
Enable an overflow menu on the card. It's not finished yet, I still
need to implement the popup menu when clicked (Boolean)
Enable touch feedback on click or disable it (Boolean)
If you replace the overflow menu with buttons, at least you get a boolean and then handle the actions accordingly.
I wonder if you should just use a simple ListView, and apply a custom background to your adapter to give it the card UI. Then you are just using a simple ListView (with no additional framework - ie. just standard Android UI).
I describe how I did this in the following SO answer: How to create Google + cards UI in a list view?
I would guess that you ARE able to add an onClickListener to the component of your card, as this is pretty standard Android (chances are the Framework you are using DOES support this). Don't know your specific issue unless you post more code.

Dynamically change the content/layout/flow controlled via server

I am new to android development, and we have a very specific requirement.
We need to change the content/layout/flow of the app on the fly. For e.g. we have a layout which consists of some images, textarea and textboxes. There might be a request coming to change the textarea to a textbox.
We thought about this and are thinking to provide the apk with a json/xml which will contain all these changes.
My question is will it be possible to re-draw the objects again dynamically and change the content?
Yes this is possible. You can dynamically design what has to be displayed in your Activity UI screen. If you feel there are only 2 or 3 different UI screens that would be repeatedly used, then you can have XMLs for these screens and you can just change their labels in OnCreate() of Activity class before rendering. LayoutInflater class would be helpful here.
When you design a Android Application with Activities and Fragments your XML layout definition is always static. If you want a true dynamic layout structure you should use a Web View with a HTML content pointing some URL.
As Rahul says, another approach is to manage the "default cases". For me that is the standard way to design an Android Application.
The dynamic content (values) can be done with a simple http call to server you can get values for your views.
The navigation could be handled by switching Intents, but, definitively you have to associate these intents to UI elements like buttons in the most cases, and ¿How you can do that if your layout is changing over time?.
I think, that the WebView could be a very easy solution for your problem.

how to create a shared view in android

I am having one app where i created a view. And i want to use the same view in another application. Is there any way to pass the second apps context as parameter to the view. So that the view is created second application's context.
Or is there any way to create a view library so that many applications use that view library to create views.
Ron
You can create a class and call it CustomView wich extends View and customize the view. Then, you can use it in both apps.
However, since you already created your view, my suggestion is to copy-paste the code into your new app unless you are planning to use the same view in future apps.
I see two ways to interpret your question. 1) You have a custom View (like a custom control) and want to share it. The earlier answers address that interpretation of the question -- how to share the code that implements the View.
Another interpretation is you want Application "A" to bring up a screen defined by Application "B". That is you want not only the View, but the behavior behind the view.
For this use I would suggest sharing Activities or Fragments rather than Views. You can have application A use Application B's Activity (if Application B is willing) by sending an appropriate Intent.
I would suggest you follow iturki's method or just copying the same layout into each application xml layout file..I dont think that is to difficult. It is practically easier.
In Android source build system you can usually create a jar and export that jar to multiple apps to share the common functionality. Never tried doing it independently. You can check Phone app on Gingerbread. Some functionality is shared between Phone app and Contacts app. Though these are not sharing Views, Ideally you could take this idea forward and implement Views

Categories

Resources