小编Sap*_*rma的帖子

在零索引处插入第一个项目时,notifyItemInserted()无效

我试图在第一个位置的回收者视图中插入一个项目,即0索引如下

 try {
       commentList.add(new Comment(
          Preferences.getProfileImageUrl(),
             "",                                       
               Preferences.getUserName(DONApplication.getInstance()),
               String.valueOf(Preferences.getUserId(DONApplication.getInstance())),
               response.getString("comment_id"),
               commentText
       ));
       commentAdapter.notifyItemInserted(commentList.size() - 1);                                      
     } catch (Exception e) {
         e.printStackTrace();                    
       }
Run Code Online (Sandbox Code Playgroud)

但它根本没有显示,但当我关闭窗口并再次打开它时,它变得可见.我不知道为什么会这样.有人能帮我吗?

android insert-update android-recyclerview

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

Android上的小米和联想设备上的应用程序被杀后,未收到GCM通知

任何人都可以帮助我接收有关小米和联想设备的通知,即使应用程序被杀后(不再在后台)?

编辑1

我添加了GCM广播接收器.这是代码

在AndroidManifest.xml中

 <receiver
       android:name="com.don.offers.broadcast_receiver.GcmBroadcastReceiver"
       android:permission="com.google.android.c2dm.permission.SEND" >
       <intent-filter>
           <!-- Receives the actual messages. -->
           <action android:name="com.google.android.c2dm.intent.RECEIVE" />
           <category android:name="com.google.android.gcm.demo.app" />
       </intent-filter>
   </receiver>
Run Code Online (Sandbox Code Playgroud)

GcmBroadcastReceiver.java

public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        ComponentName comp = new ComponentName(context.getPackageName(),
                RegistrationIntentService.class.getName());
        // Start the service, keeping the device awake while it is launching.
        startWakefulService(context, (intent.setComponent(comp)));
        setResultCode(Activity.RESULT_OK);
    }
}
Run Code Online (Sandbox Code Playgroud)

它解决了我在MI设备上的问题,但没有在联想设备上解决.

谢谢

notifications android google-cloud-messaging

5
推荐指数
0
解决办法
625
查看次数

此应用程序不支持"分屏或画中画"

我正在尝试在我的应用中支持分屏功能.

在此输入图像描述

目标SDK目前是27

 defaultConfig {
        applicationId "com.myvestige.vestigedeal"
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 46
        versionName "5.5"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
Run Code Online (Sandbox Code Playgroud)

并在应用程序标记的清单中将resizeableActivity添加到"true".

<application
        android:name=".activity.MyApplication"
        android:allowBackup="false"
        android:icon="@drawable/newicon1"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        tools:replace="android:icon"
        android:resizeableActivity="true">
Run Code Online (Sandbox Code Playgroud)

当我用三根手指向下滑动(手动屏幕分割)时,此应用程序不支持 " 分屏或画中画 ".

还附上我正在收到的错误消息的屏幕截图.我使用vivo-v9(8.1.0)进行测试,支持分屏.

请帮助我找到我做错的事.

谢谢

android multi-window split-screen

5
推荐指数
0
解决办法
524
查看次数

当缓存大小超过50 MB时,滑动,清除缓存

我正在使用Glide库进行图像加载.我的应用程序中有很多图像,所以我想在缓存大小超过50 MB时清除缓存.有人可以帮我这样做吗?

android cache-control image-loading android-glide

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