标签: android-5.0-lollipop

如何从 MediaSessionManager 创建 MediaController 实例?

我正在尝试从 RemoteController 迁移到 Lollipop 的 MediaController,但在获取 MediaController 实例时遇到问题。在 MediaController 中它说:

如果您拥有“android.permission.MEDIA_CONTENT_CONTROL”权限或者是启用的通知侦听器,或者直接从会话所有者获取 MediaSession.Token,则可以通过 MediaSessionManager 创建 MediaController。

然而,当我查看 MediaSessionManager 时,除了 addOnActiveSessionsChangedListener、getActiveSessions 和 removeOnActiveSessionsChangedListener 之外,没有其他方法对我有任何帮助。我尝试从 MediaSession 创建令牌,但这并没有使我的回调能够从其他媒体播放器获取任何内容。

android android-5.0-lollipop

2
推荐指数
1
解决办法
5686
查看次数

AudioTrack 在 Android 5.0 上停止工作

在获得带有 Lollipop 的 Android 设备后,我注意到我们为 Kitkat(和以前的版本)工作的 AudioTrack 代码完全停止工作,完全相同的代码适用于 Lollipop 之前的设备,所以我想知道我在做什么新版本做错了。AudioTrack以下是(由属性引用mTrack)的初始化方式:

protected void onCreate(Bundle savedInstanceState) {
    int bufferSize = AudioTrack.getMinBufferSize(AUDIO_SAMPLE_RATE, AudioFormat.CHANNEL_CONFIGURATION_STEREO, AudioFormat.ENCODING_PCM_16BIT);

    mTrack = new AudioTrack(AudioManager.STREAM_MUSIC, AUDIO_SAMPLE_RATE,
                    AudioFormat.CHANNEL_CONFIGURATION_STEREO,
                    AudioFormat.ENCODING_PCM_16BIT, bufferSize,
                    AudioTrack.MODE_STREAM);
}
Run Code Online (Sandbox Code Playgroud)

以下是缓冲区的填充方式:

public void onPlayAudio(byte[] audioBuffer) {
    if (mTrack.getPlayState() != AudioTrack.PLAYSTATE_PLAYING) {
        mTrack.play();
    }

    if (audioBuffer != null) {
        mTrack.write(audioBuffer, 0, audioBuffer.length);
    }
}
Run Code Online (Sandbox Code Playgroud)

同样,这在 Lollipop 之前的设备上运行良好。Logcat 上没有错误,一切似乎都正常,但声音不出来(是的,我检查了音量,它一直开到最大)。所以我想知道我是否缺少更新或者我做错了什么。

我注意到AudioFormat.CHANNEL_CONFIGURATION_STEREO已被弃用,但尝试建议AudioFormat.CHANNEL_OUT_STEREO似乎并不能解决问题。

任何帮助将不胜感激。

android audiotrack android-5.0-lollipop android-5.1.1-lollipop

2
推荐指数
1
解决办法
1260
查看次数

检测在android中启动了哪个应用程序

如何检测用户在我的应用程序中启动了哪个应用程序,即即使我的应用程序未在前台或后台运行,当用户启动 Whatsapp 时,我的应用程序也应收到通知。

远足信使已经实现了与无障碍服务相同的功能。

我怎么解决这个问题 ?

提前致谢!!

android android-5.0-lollipop android-5.1.1-lollipop

2
推荐指数
1
解决办法
2631
查看次数

sinch force关闭应用程序启动android棒棒糖

请帮助我,我在我的应用程序中使用sinch sdk并且它在除了android lollipop之外的所有Android平台上正常运行,当我尝试打开它时强制关闭.这是日志:

12-26 01:33:00.577: A/art(5423): art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: attempt to return an instance of com.sinch.android.rtc.internal.natives.jni.NativeServiceProviderImpl from com.sinch.android.rtc.internal.natives.jni.NativeServiceProviderImpl com.sinch.android.rtc.internal.natives.jni.ServiceProviderFactory.createServiceProvider(com.sinch.android.rtc.internal.service.dispatcher.Dispatcher, com.sinch.android.rtc.internal.service.http.HttpService, com.sinch.android.rtc.internal.service.pubnub.PubSubClient, com.sinch.android.rtc.internal.service.uniqueid.UniqueId, com.sinch.android.rtc.internal.service.crypto.CryptoService, com.sinch.android.rtc.internal.service.persistence.PersistenceService)
12-26 01:33:00.577: A/art(5423): art/runtime/check_jni.cc:65] from com.sinch.android.rtc.internal.natives.jni.NativeServiceProviderImpl com.sinch.android.rtc.internal.natives.jni.ServiceProviderFactory.createServiceProvider(com.sinch.android.rtc.internal.service.dispatcher.Dispatcher, com.sinch.android.rtc.internal.service.http.HttpService, com.sinch.android.rtc.internal.service.pubnub.PubSubClient, com.sinch.android.rtc.internal.service.uniqueid.UniqueId, com.sinch.android.rtc.internal.service.crypto.CryptoService, com.sinch.android.rtc.internal.service.persistence.PersistenceService)
12-26 01:33:00.577: A/art(5423): art/runtime/check_jni.cc:65] "main" prio=5 tid=1 Runnable
12-26 01:33:00.577: A/art(5423): art/runtime/check_jni.cc:65] | group="main" sCount=0 dsCount=0 obj=0x86eafef0 self=0xb4e07800
12-26 01:33:00.577: A/art(5423): art/runtime/check_jni.cc:65] | sysTid=5423 nice=-11 cgrp=apps sched=0/0 handle=0xb6f5aec8
12-26 01:33:00.577: A/art(5423): art/runtime/check_jni.cc:65] | state=R schedstat=( 284397663 94742126 1467 ) utm=18 stm=10 …
Run Code Online (Sandbox Code Playgroud)

android sinch android-5.0-lollipop

1
推荐指数
1
解决办法
731
查看次数

以编程方式更改自适应亮度级别

如何在Android Lollipop上以编程方式更改自适应亮度级别?

我知道如何更改手册brightness level,以及打开或关闭adaptive brightness.这是这样做的: Settings.System.putInt(cr, Settings.System.SCREEN_BRIGHTNESS, newLevel);

但是,adaptive brightness启用后,操作系统将其与另一个brightness level与手动操作系统不同的操作系统组合在一起.

有没有办法做到这一点?

目标/分钟/最大SDK为21.

android brightness screen-brightness android-5.0-lollipop

1
推荐指数
1
解决办法
3080
查看次数

什么是5.0许可错误的最佳解决方案?

所以我的所有应用程序在5.0上运行时都会遇到此异常...

java.lang.IllegalArgumentException:Service Intent必须是显式的:Intent {act = com.android.vending.licensing.ILicensingService}

谷歌搜索后,我发现这是由LicenseChecker.java中的Google Licensing代码中的错误引起的,但建议的更改有点不同,所以我不知道该怎么做.它让我感到震惊,我们应该为Googles代码制作mod.

我的LicenseChecker.java中的可疑代码是......

        Log.i(TAG, "Binding to licensing service.");
        try {
            boolean bindResult = mContext
                    .bindService(
                            new Intent(
                                    new String(
                                            Base64.decode("Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U="))),
                            this, // ServiceConnection.
                            Context.BIND_AUTO_CREATE);
Run Code Online (Sandbox Code Playgroud)

我们应该补充一下

serviceIntent.setPackage("com.android.vending");
Run Code Online (Sandbox Code Playgroud)

代码中的某个地方.

所以我的问题是(1)这真的是修复吗?(2)如果是这样,修改后的代码到底应该是什么样的?谢谢,迪恩

android android-lvl android-5.0-lollipop

1
推荐指数
1
解决办法
1133
查看次数

setOnEditorActionListener不适用于Android Lollipop

我一直在尝试这个 IME_ACTION

 //Listening to the keyboard action
    mSearchEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == R.id.ime_search || actionId == EditorInfo.IME_ACTION_SEARCH) {

                performSearch();
                return true;
            }
            return false;
        }
    });
Run Code Online (Sandbox Code Playgroud)

但似乎它对Lollipop设备一点都不起作用.

这是XML代码 - 我完全相信我这样做是正确的.

 <org.mapunity.widget.FloatingEditText
        android:id="@+id/fragment_search_edit_text"
        android:hint="Enter a Text to Search"
        android:layout_marginTop="@dimen/spacing_small"
        android:layout_marginBottom="@dimen/spacing_small"
        android:singleLine="true"
        app:floating_edit_text_highlighted_color="@color/color_primary"
        android:layout_marginLeft="@dimen/spacing_normal"
        android:imeActionLabel="@string/action_search"
        android:imeOptions="actionSearch"
        android:imeActionId="@+id/ime_search"
        android:inputType="text"
        android:layout_marginRight="@dimen/spacing_normal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
        <requestFocus></requestFocus>
        </org.mapunity.widget.FloatingEditText>
Run Code Online (Sandbox Code Playgroud)

请提供一个输入:

知道有很多类似的问题,但我的是Lollipop,即Android 5.0+.

android keyboard-events android-5.0-lollipop

1
推荐指数
1
解决办法
1221
查看次数

使用windowTranslucentStatus = true时摆脱Android L自动不透明色

有谁知道当您使用windowTranslucentStatus = true时如何摆脱这种自动色调?我已经将状态栏颜色设置为透明,但是当启用windowTranslucentStatus时,它似乎将其覆盖。如果禁用windowTranslucentStatus,则可以得到所需的状态栏颜色,但无法再在状态栏下绘制导航抽屉。我可以使用ScrimInsetFrameLayout实现我想要的功能,但这引起了其他问题。

在此处输入图片说明

android android-4.4-kitkat android-5.0-lollipop android-statusbar

1
推荐指数
1
解决办法
478
查看次数

在Android Lollipop中输入类android.support.v7.widget.Toolbar时出错

我为我的项目使用android.support库,我使用android 4.4开发了我的应用程序并且一切正常但我的问题出现在我尝试在Android Lollipop设备中运行应用程序时.

当它使用工具栏加载Activity时,应用程序将停止并返回此错误.

扩展类android.support.v7.widget.Toolbar时出错

我在互联网上发现了同样的问题,但我没有在答案中找到解决方案.

这是我的styles.xml

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
<!-- Base theme applied no matter what API -->
    <item name="android:windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/dark_primary</item>
    <item name="colorAccent">@color/accent_color</item>
</style>
Run Code Online (Sandbox Code Playgroud)

这是我的styles.xml(v22)

<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="android:Theme.Material.Light.NoActionBar">
        <item name="colorPrimary">@color/primary</item>
        <item name="colorPrimaryDark">@color/dark_primary</item>
        <item name="colorAccent">@color/accent_color</item>
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>
</resources>
Run Code Online (Sandbox Code Playgroud)

在.xml中定义工具栏

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/mitoolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    local:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    tools:showIn="@layout/activity_main" /> …
Run Code Online (Sandbox Code Playgroud)

android android-support-library android-styles android-5.0-lollipop

1
推荐指数
1
解决办法
9638
查看次数

TextInputEditText不适用于Android 5.1

我希望你能帮助我解决我现在面临的问题.

我使用TextInputEditText创建了一个自定义搜索视图,它实际上非常简单,并且除了5.1(Lollipop)之外的所有Android版本都能正常工作,EditText在写入时甚至不会隐藏提示甚至显示光标,文本也不是可见.

我已经尝试过我所知道的一切,但我无法想象它会是什么.

非常感谢您的参与.

这是我的自定义类视图:

public class CustomSearchView extends RelativeLayout {

@BindView(R.id.csvIcon) ImageView csvIcon;
public @BindView(R.id.csvEditText) TextInputEditText editText;

public CustomSearchView(Context context) {
    super(context);
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.custom_search_view, this, true);
    ButterKnife.bind(this);
}

public CustomSearchView(Context context, AttributeSet attrs) {
    super(context, attrs);
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.custom_search_view, this, true);
    ButterKnife.bind(this);
    TypedArray typedArray = context.getTheme().obtainStyledAttributes(
            attrs,
            R.styleable.CustomSearchView,
            0, 0);
    String hintText = typedArray.getString(R.styleable.CustomSearchView_hintText);
    try {
        int max = typedArray.getInteger(R.styleable.CustomSearchView_csv_length, 17);
        editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(max)});
        editText.setInputType(typedArray.getInt(R.styleable.CustomSearchView_android_inputType, InputType.TYPE_CLASS_TEXT));
        editText.setHint(hintText);
        csvIcon.setImageDrawable(typedArray.getDrawable(R.styleable.CustomSearchView_csv_icon));
    } catch (Exception e) …
Run Code Online (Sandbox Code Playgroud)

java android android-edittext android-5.0-lollipop android-textinputedittext

1
推荐指数
1
解决办法
388
查看次数