小编rha*_*ari的帖子

如何区分设备进入 Doze 维护时段和退出 Doze 维护时段

我有一个定期运行以保持网络连接活动的方法。在打瞌睡模式期间,我想禁止它定期运行,并在维护窗口期间只运行一次。当设备退出打瞌睡状态时,我希望再次定期调用该方法。我怎样才能做到这一点?

我已经注册了一个接收器,用于监听PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED广播然后调用PowerManager.isDeviceIdleMode()。但是,这两种情况都会返回 false - 在维护时段期间和设备退出 Doze 模式时。我如何区分它们?

android android-6.0-marshmallow android-doze

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

Android与依赖项appcompat的冲突

我正在尝试将espresso-contrib库添加到我的项目中.这是我的build.gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "example.com.littlebox_hari"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    /*configurations.all {
        resolutionStrategy {
            force 'com.android.support:appcompat-v7:23.4.0'
        }
    }*/
}


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.squareup.retrofit2:retrofit:2.0.0'
    compile 'com.squareup.retrofit2:converter-gson:2.0.0'
    androidTestCompile 'com.android.support.test:runner:0.4'
    androidTestCompile 'com.android.support.test:rules:0.4'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
    androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
    androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.2'
    androidTestCompile 'com.android.support.test.espresso:espresso-idling-resource:2.2.2'
    compile 'com.android.support:support-annotations:23.4.0'
    testCompile 'com.android.support:support-annotations:23.4.0'
    androidTestCompile 'com.android.support:support-annotations:23.4.0' …
Run Code Online (Sandbox Code Playgroud)

android gradle android-studio android-espresso

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

在android中选择文件的特定类型

我正在尝试制作一个用户可以使用android设备的文件管理器选择文件的应用程序。这是我正在使用的代码:

 boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
                    if (isKitKat)
                    {
                        Intent uploadIntent = new Intent();
                        uploadIntent.setType("*/*");
                        uploadIntent.setAction(Intent.ACTION_GET_CONTENT);
                        startActivityForResult(uploadIntent, REPORT_USING_FILE_MANAGER);

                    }
                    else
                    {
                        Intent uploadIntent = new Intent(Intent.ACTION_GET_CONTENT);
                        uploadIntent.setType("*/*");
                        startActivityForResult(uploadIntent, REPORT_USING_FILE_MANAGER);
                    }
Run Code Online (Sandbox Code Playgroud)

我只希望用户能够选择图像文件(.jpg,.png等)或.pdf文件。如何设置此限制?

android file-manager android-intent

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

无法将外部库添加到android studio项目中

我想在我的Android工作室项目中添加https://github.com/jkwiecien/EasyImage.当我添加行:

compile 'com.github.jkwiecien:EasyImage:1.2.1' 
Run Code Online (Sandbox Code Playgroud)

到我的应用程序的build.gradle文件,它给了我:

错误(33,13)无法解决.

android gradle

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