android-5.0-lollipop

Dismissing MediaStyle notifications

試著忘記壹切 提交于 2019-12-04 17:13:21
New Android MediaStyle notifications in Lollipop don't have a dismiss button. Looks like there is already a bug for it on Google Code. Does anyone know what's a good workaround for this issue until the bug is resolved? Should we just delay switching to MediaStyle? Or use one of the actions as the dismiss button? One mechanism which appears to work quite well is make the notification ongoing while music is playing and make it not ongoing (allowing it to be swipe dismissed) when the music is paused. This seems to be the technique that Google Music already uses . Adding on to @ianhanniballake's

How to change DatePicker's CalendarView's background color in Lollipop?

[亡魂溺海] 提交于 2019-12-04 16:51:24
I worked so hard to change the default background color of Lollipop's DatePicker. I cannot simply use Styleable attrs to change the default style. And as mentioned in another post , I can only use reflection to find the view, and then make changes on it. e.g. if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { int monthDayYearLayoutId = Resources.getSystem().getIdentifier("date_picker_month_day_year_layout", "id", "android"); if (monthDayYearLayoutId != 0) { View monthDayYearLayout = datePicker.findViewById(monthDayYearLayoutId); if (monthDayYearLayout != null) {

How to detect if your android app is in the foreground (API 21)

独自空忆成欢 提交于 2019-12-04 16:35:36
when receiving a GCM message, the behaviour of my app depends on if it is in the foreground or not. Prior to API 21 I used the following: Boolean onForeground = this.getPackageName().equalsIgnoreCase( ((ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE)) .getRunningTasks(1).get(0).topActivity.getPackageName() ); Now getRunningTasks() is deprecated and behaving differently on API 21, what would be the best way on API 21 to detect if my app is in the foreground? Google recommends public ActivityManager.RecentTaskInfo getTaskInfo () but I do not see how I can get the information I

Android Switch widget textOn and textOff not working in Lollipop

孤街醉人 提交于 2019-12-04 14:57:07
问题 The behavior of the switch widget changed in Lollipop (5.0). <Switch android:id="@+id/switcher" android:layout_width="wrap_content" android:layout_height="0dp" android:layout_marginBottom="16dp" android:layout_marginRight="8dp" android:layout_marginEnd="8dp" android:layout_toEndOf="@id/another_view" android:layout_toRightOf="@id/another_view" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" android:layout_alignParentBottom="true" android:textOff="@string/disabled"

How to check permission SYSTEM_ALERT_WINDOW is granted on Android Lollipop?

那年仲夏 提交于 2019-12-04 14:35:03
Note that I'm talking about Android Lollipop . For android 6.0 we can use method canDrawOverlays() to check that SYSTEM_ALERT_WINDOW is granted or not. With Android Lollipop, almost devices grant this permission by default. But on some devices of Xiaomi, Meizu.. it is not granted. Users need to go to the App info to allow it. How can we check it programmatically to warn users? in MIUI use public static boolean isMiuiFloatWindowOpAllowed(@NonNull Context context) { final int version = Build.VERSION.SDK_INT; if (version >= 19) { return checkOp(context, OP_SYSTEM_ALERT_WINDOW); //See

Android L | libusb_init returns LIBUSB_ERROR_OTHER (-99)

我是研究僧i 提交于 2019-12-04 12:12:02
问题 I trying to use libusb on not rooted Nexus 5 as advised in this approach (by transferring usb file descriptor from java to native side). My application ask permission via UsbManager.requestPermission and then run native method that call libusb_init to create libusb_context . But libusb_init returns LIBUSB_ERROR_OTHER code (-99). After digging in the code I see why this happening. libusb reports 'could not find usbfs' because opendir("/dev/bus/usb") returns 0 . Also from adb shell I can't

9Patch on Lollipop shows gray oval in background

匆匆过客 提交于 2019-12-04 11:56:47
I have the following button: <Button android:layout_height="32dp" android:layout_marginTop="4dp" android:layout_marginLeft="@dimen/aecs_item_inner_padding_positive" android:id="@+id/aecsTelephone" android:layout_width="wrap_content" android:layout_gravity="center_horizontal" android:layout_below="@id/aecsServicesContainer" android:layout_alignParentLeft="true" android:text="Mobile" android:background="@drawable/selector_mobile_button" /> and it has the following background selector: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android">

Set a theme on a View programmatically on Android 5.0 Lollipop

感情迁移 提交于 2019-12-04 11:40:16
Android 5.0 Lollipop added the ability to set a theme for different views (not just the Activity). android:theme="@style/MyAwesomeTheme" Is there a way to set the theme on a view dynamically? android:theme changes specific attributes specified in the theme resource. You could instantiate specific view using any overloaded constructor, like View(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) . which basically is what inflater does. For example v7.widget.Toolbar tries to create themed context out of resource android:theme right in the super call of the constructor, which

Android Lollipop BLE scan - getting peripherals without duplications

て烟熏妆下的殇ゞ 提交于 2019-12-04 11:24:51
Android Lollipop introduced a new way to scan for BLE peripherals, via BluetoothLeScanner . From what I read, the new scanning API solved an issue that happened with the old scanning API ( BluetoothAdapter.startLeScan(UUID[],LeScanCallback) ) where on some devices the callback ( onLeScan ) was called only once per peripheral, even if the peripheral keeps advertising. This issue is handled on iOS with the CBCentralManagerScanOptionAllowDuplicatesKey option, that allows you to choose whether you want to detect only new peripherals or keep getting advertisements from previously-found peripherals.

Get WiFi captive portal info

自闭症网瘾萝莉.ら 提交于 2019-12-04 09:55:38
Is there a way to access Android's broadcast that the WiFi connection is currently a captive portal (requires web login)? Android seems to do have this built in. If not a broadcast receiver, is there a way to check for the result of the captive portal check? I believe it's using this class, which is hidden from the API: http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.L_preview/android/net/CaptivePortalTracker.java Prior to 4.2, it was probably using: http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.1.2_r1/android/net