android-5.0-lollipop

Change AppBarLayout height programmatically in Android

你说的曾经没有我的故事 提交于 2019-12-05 18:43:20
问题 I'm trying to implement Flexible Space with image pattern, using this tutorial. Everything works fine. Notice the height definition of the AppBarLayout which is 192dp. I'd like to make the height 1/3 of the screen instead, to match this google example for the pattern here. Here's the code in the activity's onCreate (the layout xml is exactly the same as in the tutorial): AppBarLayout appbar = (AppBarLayout)findViewById(R.id.appbar); float density = getResources().getDisplayMetrics().density;

Check Android user's “when device is locked” notification settings

荒凉一梦 提交于 2019-12-05 18:18:49
On Android L, I would like show the user a notification on the lock screen only if the user settings is set to "show all notification content", otherwise the content will be pointless and I just prefer not to show the notification at all. Any idea how to verify in code the user notification settings? Thanks! You need to read Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS = "lock_screen_allow_private_notifications" Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS = "lock_screen_show_notifications" only if both are 1 then you need to show your notifications. But since these values are not

How to customize the “up” button when the searchView is being expanded?

非 Y 不嫁゛ 提交于 2019-12-05 16:03:16
问题 Background My app has the ability to search for items (which are other apps) using the SearchView on the ActionBar. The app uses the support library of Google, and it works well on all versions of Android from API 9 . The problem On Lollipop, when I click the search action item in order to start searching, I notice that the up/back button on the top-left corner gets to be white, which is bad for this case since the actionbar background is also quite white: Weird thing is that it doesn't

Should I change the existing Listview in my app to RecyclerView?

谁都会走 提交于 2019-12-05 14:34:02
问题 Is there any advantages of converting the existing Listview in my app to RecyclerView?? Also when should I be using RecyclerView?? 回答1: That's a tough question to answer. First of all: Think of the RecyclerView as the successor of the AdapterViews which comes with alot of useful improvement especially in the fields of animations for each item. Actually that's also what the Docs say: RecyclerView is a more advanced and flexible version of ListView. This widget is a container for large sets of

Android: unable to change color of back arrow navigation icon

我与影子孤独终老i 提交于 2019-12-05 13:13:11
I'm using new android appcompat toolbar. I need to set the same custom color to both burger icon and back arrow icons. Using drawerArrowStyle allows me to change burger icon but not the arrow. The issue is only on Lollipop devices, anything pre-lollipop is fine. Here is the code: Toolbar: <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:local="http://schemas.android.com/apk/res-auto" android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="?attr

BLuetooth Gatt Callback not working with new API for Lollipop

大兔子大兔子 提交于 2019-12-05 12:59:15
问题 I currently have a method which writes to the BLE devices to beep it. My Bluetooth Callback goes as follows : ReadCharacteristic rc = new ReadCharacteristic(context, ds.getMacAddress(), serviceUUID, UUID.fromString(myUUID), "") { @Override public void onRead() { Log.w(TAG, "callDevice onRead"); try{Thread.sleep(1000);}catch(InterruptedException ex){} WriteCharacteristic wc = new WriteCharacteristic(activity, context, getMacAddress(), serviceUUID, UUID.fromString(myUUID), ""){ @Override public

MediaPlayer.prepare() throws IllegalStateException on Android L

时光怂恿深爱的人放手 提交于 2019-12-05 12:53:57
I have code that plays mp3 file from assets directory: MediaPlayer mediaPlayer = new MediaPlayer(); descriptor = context.getAssets().openFd("beep.mp3"); mediaPlayer.setDataSource(descriptor.getFileDescriptor(), descriptor.getStartOffset(), descriptor.getLength()); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mediaPlayer.setVolume(soundLevel, soundLevel); descriptor.close(); mediaPlayer.setLooping(false); mediaPlayer.prepare(); mediaPlayer.start(); This code was working fine on every device and every Android version. Until after Android L preview came available. mediaPlayer

How to remove this gray color from topbar/status bar

不想你离开。 提交于 2019-12-05 12:40:52
I have an app where I have set the top bar / status bar to ascent colors, its working for most screens on lollipop but having an issue on one of the screen its an activity. The code is as follows: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.realsales.reatsalesapp.activities.EditContactActivity"> <android.support.v7.widget.Toolbar xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/toolbarEC" android:layout

How to exit from Screen Pinning - Android 5 (Emulator)

荒凉一梦 提交于 2019-12-05 11:50:12
Screen Pinning ( as mentioned on this page ) is a new feature introduced in Android 5 (Lollipop) which lets its users to temporarily lock only one Activity to the screen. All other notifications are hidden when screen pinning is activated. Following steps can be taken to activate Screen Pinning Users can enable screen pinning in Settings > Security > Screen Pinning, and select the tasks they want to pin by touching the green pin icon in the recents screen. And to exit from Screen Pinning user can do the following the user can exit by holding both the Back and Recent buttons What I wanted to

Toolbar don´t work with pre-lollipops devices using appcompat v7

*爱你&永不变心* 提交于 2019-12-05 11:22:42
I'm doing a simple code for a toolbar and menu drawer, using material appcompatv7. Everything works perfectly on the Nexus 5 with lollipop , but in a pre-lollipop (4.1 or 4.4) device crashes. The problem comes in defining the style. I put my code if anyone can tell me where the fault is. This is my main activity: import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.widget.Toolbar; import android.content.res.Configuration; import android.os.Bundle; import android.view