小编Rag*_*ini的帖子

在清单中注册的广播接收器未在Android Oreo中调用

我已注册以下receiver内容未在Android Oreo中调用,但适用于较低版本的设备.

<receiver
     android:name=".common.receiver.ConsultReceiver"
     android:exported="false">
       <intent-filter>
            <action android:name="APP_STARTED" />
            <action android:name="APP_STARTED_FROM_ORGANIC" />
       </intent-filter>
</receiver>  
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激?

android broadcastreceiver android-8.0-oreo

8
推荐指数
2
解决办法
7661
查看次数

展开时如何使用工具栏创建底部表格,

我想创建底部工作表布局,当扩展到全屏时应该显示工具栏。我使用了以下代码,但它显示工具栏,即使它没有扩展到全屏。

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    app:layout_behavior="@string/bottom_sheet_behavior">

    <include
        android:id="@+id/search_tab_toolbar"
        layout="@layout/search_tablayout"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:id="@+id/search_tab_toolbar"
        android:background="@color/accent"/>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        />


</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

android toolbar android-collapsingtoolbarlayout bottom-sheet

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

如何在android中更改通知栏的字符串区域设置

在我的应用程序中,我正在动态更改语言,因此如果我在前台,通知语言将正确出现,但如果我强制关闭应用程序通知将出现在设备区域设置中。

我使用以下代码来更改上下文语言环境,但在强制关闭后它不起作用

fun wrapContext(context: Context?, locale: Locale): Context? {
    if (context == null) return null

    val configuration = context.resources.configuration
    if (getSystemLocale(configuration) === locale) {
        return context
    }

    setSystemLocale(configuration, locale)

    val res = context.resources
    res.updateConfiguration(configuration, res.displayMetrics)

    return context.createConfigurationContext(configuration)
}
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激。

notifications android push-notification setlocale android-notification-bar

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

如何更改 Android Oreo 中的通知点颜色

如何更改 Android Oreo 中的通知点颜色。

new NotificationCompat.Builder(context)
                .setSmallIcon(R.drawable.ic_notification_white)
                .setColor(ContextCompat.getColor(context, R.color.accent))
Run Code Online (Sandbox Code Playgroud)

我尝试使用 setColor() 但它不起作用。

android android-notifications

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

Notification.addAction在Android O中无效

下面提到的代码适用于android O verison下面的所有设备.对于Android O,addAction()方法不起作用,即按钮单击在Android O中不起作用.
任何帮助将不胜感激.

 NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

            Intent mediaPlayerReceiver = new Intent("com.consult.news.receiver.ACTION_PLAY");
            mediaPlayerReceiver.putExtra("NewsArticle", news);
            PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, mediaPlayerReceiver, PendingIntent.FLAG_UPDATE_CURRENT);

            Intent dismissNotification = new Intent("com.consult.news.receiver.DISMISS");
            dismissNotification.putExtra("Notification_ID", 1);
            PendingIntent dismissNotificationIntent = PendingIntent.getBroadcast(context, 0, dismissNotification, PendingIntent.FLAG_UPDATE_CURRENT);

            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
                String CHANNEL_ID = "my_channel_01";
                String CHANNEL_NAME = "my Channel Name";

                NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH);
                notificationChannel.enableLights(true);
                notificationChannel.setLightColor(Color.RED);
                notificationChannel.setShowBadge(true);
                notificationChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
                notificationManager.createNotificationChannel(notificationChannel);
            }

            NotificationCompat.Builder builder = new NotificationCompat.Builder(context, "my_channel_01")
                    .setSmallIcon(R.drawable.ic_notification_white)
                    .setColor(ContextCompat.getColor(context, R.color.accent))
                    .setContentTitle(context.getString(R.string.Consult_Univadis_Title))
                    .setStyle(new NotificationCompat.BigTextStyle().bigText(news))
                    .addAction(isPlaying …
Run Code Online (Sandbox Code Playgroud)

notifications android push-notification android-8.0-oreo

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

如何在Android中为进度条设置动画

我想创建 1 分钟的计时器进度条。我使用了以下代码,但它从 60 到 0 开始,而使用相同的过程,我必须从 0 到 60 开始。

public static void animateTimerProgress(int currentTimeDuration, final int maxTimeDuration, boolean withStartDelay, final DonutProgress timeOutProgressView, Runnable endAction) {
    final int duration = currentTimeDuration < 0 ? 1 : currentTimeDuration;
    timeOutProgressView.setMax(maxTimeDuration);
    timeOutProgressView.setProgress(duration);
    timeOutProgressView.animate()
            .setDuration(duration * SECOND_IN_MILLIS)
            .setInterpolator(new LinearInterpolator())
            .setStartDelay(withStartDelay ? TIMEOUT_START_DELAY : 0)
            .setUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator valueAnimator) {
                    int progress = 1 + (int) ((1f - valueAnimator.getAnimatedFraction()) * (duration - 1f));

                    timeOutProgressView.setProgress(progress);
                }
            })
            .withEndAction(endAction)
            .start();
}
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激。

android android-animation android-progressbar

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