android-5.0-lollipop

Android CardView doesn't work on Api 21

落花浮王杯 提交于 2019-12-07 18:08:53
问题 I am using android CardView and it works perfectly below Api 21. But when I use it on Api 21 i.e. Lollipop the xml attributes like cardElevation , cornerRadius doesn't work. What am I doing wrong? This is my XML layout: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <!-- A CardView that contains a TextView

Get foreground activity from package name?

旧街凉风 提交于 2019-12-07 16:28:57
问题 I am trying to get running activity name (Foreground activity name) from package name as you all know that we can get currently running activity name via this line mActivityManager.getRunningTasks(1).get(0).topActivity.getClassName() but this work only bellow android 5.0 i need same thing in above 5.0 i am able to get current package name but not activity 回答1: security is enhanced from android Lollipop; see this article for more details: getAppTask You could get foreground activities via

Change adaptive brightness level programmatically

允我心安 提交于 2019-12-07 16:22:24
How can I change the adaptive brightness level programmatically, on Android Lollipop? I know how to change the manual brightness level , and to toggle on or off the adaptive brightness . It is done like that: Settings.System.putInt(cr, Settings.System.SCREEN_BRIGHTNESS, newLevel); However, with adaptive brightness is enabled, the OS combines it with another brightness level which is different than the manual one. Is there a way to do this? Target/min/max SDK is 21. Don't know why but there is a hidden constant SCREEN_AUTO_BRIGHTNESS_ADJ in Android API to adjust adaptive brightness. But you can

Set navigationBar color on Android Lollipop with Full screen activity

时光总嘲笑我的痴心妄想 提交于 2019-12-07 15:28:09
问题 Is there a way to set the navigationbar color in a fullscreen activity? if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getWindow().setNavigationBarColor(getResources().getColor(R.color.Theme_color)); And this line in my theme-style: <item name="android:navigationBarColor" tools:targetApi="21">#E64A19</item> Both resulting in the same transparant navbar above my activities layout... Code: Acitivity : @Override protected void onCreate(Bundle savedInstanceState) { super

java.lang.StackOverflow Error for Android L preview running art

馋奶兔 提交于 2019-12-07 12:20:57
问题 Jumping straight to the topic, Android L introduces a ART as default runtime. I have a Sample Application, basically a document viewer. Most of the document viewing code including back buttons, Search,etc are written in C and the Android App uses JNI interface. I updated my code to make it build for Android L and it seems to open the document just fine. However, when pressing back button and closing the document, the Application seem to crash and the following backtrace is seen: I/DEBUG (

Locale not set Programatically in Android 5.0 Lollipop

强颜欢笑 提交于 2019-12-07 12:16:12
问题 My application set locale according to selected language in application. Up to Kitkat my code works fine. After update to Lollipop locale was not set. Here i paste my code to set locale.. Locale locale = new Locale("de_DE"); Locale.setDefault(locale); Configuration config = new Configuration(); config.locale = locale; getBaseContext().getResources().updateConfiguration(config, null); 回答1: You have to change the way of the locale initialization. From this: Locale locale = new Locale("de_DE");

Material tabs with toolbar like design

微笑、不失礼 提交于 2019-12-07 11:59:03
问题 I saw this sample code for android playstore like layout on stackoverflow post, but due to low reputation i was not able to comment there. i am trying to achieve similar design for my project and would like if someone can help me get full code for this design apart from the layout file shared here. Thanks. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="match_parent"

How to get android permission of android.Manifest.permission.MEDIA_CONTENT_CONTROL

早过忘川 提交于 2019-12-07 11:49:22
问题 i am trying to use MediaSessionManager in API21, to control the music play on the device. For the usage, it says need to held the android.Manifest.permission.MEDIA_CONTENT_CONTROL: public void addOnActiveSessionsChangedListener (MediaSessionManager.OnActiveSessionsChangedListener sessionListener, ComponentName notificationListener, Handler handler) Added in API level 21 Add a listener to be notified when the list of active sessions changes.***This requires the android.Manifest.permission

Default Alpha value of navigation bar in Lollipop

僤鯓⒐⒋嵵緔 提交于 2019-12-07 09:44:20
问题 If you set android:windowTranslucentNavigation to true in your theme in Lollipop the navigation bar won't be fully translucent like in KitKat. Instead it's a dark semi-transparant background. Does anyone here know what the alpha value is of that background? 回答1: I've made some test with navigation bar and found that alpha of navBar when android:windowTranslucentNavigation = true is 40% of black color. So color in hex would be: #66000000 Here is steps how I calculated this value: I made

setColorFilter doesn't seem to work on kitkat

房东的猫 提交于 2019-12-07 08:40:28
问题 I'm attempting to colorize a graphic using setColorFilter . The following code seems to work fine on lollipop, but it seems to have no effect on kitkat, the icon is rendered in it's original colors: Drawable icon = ContextCompat.getDrawable(context, R.drawable.ic_chat_button).mutate(); icon.setColorFilter(context.getResources().getColor(R.color.control_tint_color), PorterDuff.Mode.SRC_ATOP); icon.invalidateSelf(); The mutate and invalidateSelf calls don't seem to have any effect on the